From 3a4992633ee62d5edfbb484d9c6bcb3cf158489d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 31 Jul 2023 14:34:36 +0200 Subject: [PATCH] Migrate server to ESM Sorry for the very big commit that may lead to git log issues and merge conflicts, but it's a major step forward: * Server can be faster at startup because imports() are async and we can easily lazy import big modules * Angular doesn't seem to support ES import (with .js extension), so we had to correctly organize peertube into a monorepo: * Use yarn workspace feature * Use typescript reference projects for dependencies * Shared projects have been moved into "packages", each one is now a node module (with a dedicated package.json/tsconfig.json) * server/tools have been moved into apps/ and is now a dedicated app bundled and published on NPM so users don't have to build peertube cli tools manually * server/tests have been moved into packages/ so we don't compile them every time we want to run the server * Use isolatedModule option: * Had to move from const enum to const (https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums) * Had to explictely specify "type" imports when used in decorators * Prefer tsx (that uses esbuild under the hood) instead of ts-node to load typescript files (tests with mocha or scripts): * To reduce test complexity as esbuild doesn't support decorator metadata, we only test server files that do not import server models * We still build tests files into js files for a faster CI * Remove unmaintained peertube CLI import script * Removed some barrels to speed up execution (less imports) --- .eslintrc.json | 23 +- .github/CONTRIBUTING.md | 31 +- .../action.yml | 10 +- .github/workflows/benchmark.yml | 2 +- .github/workflows/codeql/codeql-config.yml | 2 +- .github/workflows/stats.yml | 4 +- .gitignore | 16 +- .mocharc.cjs | 10 + apps/peertube-cli/.npmignore | 4 + apps/peertube-cli/README.md | 43 + apps/peertube-cli/package.json | 19 + apps/peertube-cli/scripts/build.js | 27 + apps/peertube-cli/scripts/watch.js | 7 + apps/peertube-cli/src/peertube-auth.ts | 171 +++ .../src/peertube-get-access-token.ts | 39 + apps/peertube-cli/src/peertube-plugins.ts | 167 +++ apps/peertube-cli/src/peertube-redundancy.ts | 186 +++ apps/peertube-cli/src/peertube-upload.ts | 167 +++ .../peertube-cli/src}/peertube.ts | 36 +- .../peertube-cli/src}/shared/cli.ts | 111 +- apps/peertube-cli/src/shared/index.ts | 1 + apps/peertube-cli/tsconfig.json | 15 + {server/tools => apps/peertube-cli}/yarn.lock | 103 +- {packages => apps}/peertube-runner/.gitignore | 0 apps/peertube-runner/.npmignore | 4 + apps/peertube-runner/README.md | 43 + .../peertube-runner/package.json | 5 +- apps/peertube-runner/scripts/build.js | 26 + .../peertube-runner/src}/peertube-runner.ts | 10 +- apps/peertube-runner/src/register/index.ts | 1 + .../peertube-runner/src}/register/register.ts | 2 +- apps/peertube-runner/src/server/index.ts | 1 + .../src/server/process/index.ts | 2 + .../src}/server/process/process.ts | 10 +- .../src}/server/process/shared/common.ts | 14 +- .../src/server/process/shared/index.ts | 3 + .../server/process/shared/process-live.ts | 16 +- .../server/process/shared/process-studio.ts | 14 +- .../src}/server/process/shared/process-vod.ts | 12 +- .../process/shared/transcoding-logger.ts | 2 +- .../peertube-runner/src}/server/server.ts | 19 +- .../src/server/shared/index.ts | 1 + .../src}/server/shared/supported-job.ts | 2 +- .../src}/shared/config-manager.ts | 11 +- .../peertube-runner/src}/shared/http.ts | 5 +- apps/peertube-runner/src/shared/index.ts | 3 + apps/peertube-runner/src/shared/ipc/index.ts | 2 + .../src}/shared/ipc/ipc-client.ts | 6 +- .../src}/shared/ipc/ipc-server.ts | 12 +- .../src/shared/ipc/shared/index.ts | 2 + .../shared/ipc/shared/ipc-request.model.ts | 0 .../shared/ipc/shared/ipc-response.model.ts | 0 .../peertube-runner/src}/shared/logger.ts | 2 +- apps/peertube-runner/tsconfig.json | 16 + {packages => apps}/peertube-runner/yarn.lock | 0 client/.eslintrc.json | 1 + client/e2e/wdio.main.conf.ts | 8 - client/package.json | 10 +- .../about-follows/about-follows.component.ts | 2 +- .../about-instance.component.ts | 2 +- .../about-instance/about-instance.resolver.ts | 2 +- .../contact-admin-modal.component.ts | 2 +- .../instance-statistics.component.ts | 2 +- .../account-video-channels.component.ts | 2 +- .../account-videos.component.ts | 2 +- .../src/app/+accounts/accounts.component.ts | 2 +- client/src/app/+admin/admin.component.ts | 2 +- client/src/app/+admin/config/config.routes.ts | 2 +- .../edit-basic-configuration.component.ts | 2 +- .../edit-custom-config.component.ts | 2 +- .../edit-live-configuration.component.ts | 2 +- .../edit-vod-transcoding.component.ts | 2 +- .../+admin/config/shared/config.service.ts | 2 +- .../followers-list.component.ts | 2 +- .../following-list.component.ts | 2 +- .../src/app/+admin/follows/follows.routes.ts | 2 +- .../video-redundancies-list.component.ts | 3 +- .../video-redundancy-information.component.ts | 2 +- .../+admin/moderation/moderation.routes.ts | 2 +- .../admin-registration.service.ts | 4 +- .../process-registration-modal.component.ts | 2 +- .../registration-list.component.ts | 2 +- .../video-block-list.component.ts | 6 +- .../comments/video-comment-list.component.ts | 2 +- .../overview/comments/video-comment.routes.ts | 2 +- .../users/user-edit/user-create.component.ts | 2 +- .../overview/users/user-edit/user-edit.ts | 5 +- .../user-edit/user-password.component.ts | 2 +- .../users/user-edit/user-update.component.ts | 2 +- .../users/user-list/user-list.component.ts | 4 +- .../app/+admin/overview/users/users.routes.ts | 2 +- .../overview/videos/video-admin.service.ts | 4 +- .../overview/videos/video-list.component.ts | 4 +- .../+admin/overview/videos/video.routes.ts | 2 +- .../plugin-list-installed.component.ts | 8 +- .../plugin-search/plugin-search.component.ts | 6 +- .../plugin-show-installed.component.ts | 2 +- .../src/app/+admin/plugins/plugins.routes.ts | 2 +- .../plugins/shared/plugin-api.service.ts | 19 +- .../plugins/shared/plugin-card.component.ts | 4 +- .../shared/plugin-navigation.component.ts | 4 +- .../shared/user-email-info.component.ts | 2 +- .../shared/user-real-quota-info.component.ts | 2 +- .../+admin/system/debug/debug.component.ts | 2 +- .../app/+admin/system/debug/debug.service.ts | 2 +- .../src/app/+admin/system/jobs/job.service.ts | 2 +- .../app/+admin/system/jobs/jobs.component.ts | 4 +- .../app/+admin/system/logs/log-row.model.ts | 2 +- .../app/+admin/system/logs/logs.component.ts | 2 +- .../app/+admin/system/logs/logs.service.ts | 2 +- .../runner-job-list.component.ts | 2 +- .../runner-list/runner-list.component.ts | 2 +- ...unner-registration-token-list.component.ts | 2 +- .../+admin/system/runners/runner.service.ts | 5 +- .../+admin/system/runners/runners.routes.ts | 2 +- client/src/app/+admin/system/system.routes.ts | 2 +- .../app/+error-page/error-page.component.ts | 4 +- client/src/app/+login/login.component.ts | 4 +- .../video-channel-create.component.ts | 2 +- .../video-channel-update.component.ts | 4 +- .../my-account-applications.component.ts | 3 +- .../my-account-change-email.component.ts | 2 +- .../my-account-change-password.component.ts | 2 +- .../my-account-email-preferences.component.ts | 2 +- ...ount-notification-preferences.component.ts | 6 +- .../my-account-settings.component.ts | 2 +- .../my-follows/my-followers.component.ts | 2 +- .../app/+my-library/my-library.component.ts | 2 +- .../my-accept-ownership.component.ts | 2 +- .../my-ownership/my-ownership.component.ts | 4 +- .../my-video-channel-syncs.component.ts | 5 +- .../video-channel-sync-edit.component.ts | 2 +- .../my-video-imports.component.ts | 4 +- .../my-video-playlist-create.component.ts | 3 +- .../my-video-playlist-edit.ts | 5 +- .../my-video-playlist-elements.component.ts | 2 +- .../my-video-playlist-update.component.ts | 2 +- .../my-video-playlists.component.ts | 2 +- .../my-videos/my-videos.component.ts | 2 +- .../app/+search/search-filters.component.ts | 2 +- client/src/app/+search/search.component.ts | 2 +- .../shared/abstract-lazy-load.resolver.ts | 2 +- .../+signup/+register/register.component.ts | 3 +- .../src/app/+signup/shared/signup.service.ts | 2 +- .../app/+stats/video/video-stats.component.ts | 6 +- .../app/+stats/video/video-stats.service.ts | 2 +- .../video-channel-videos.component.ts | 2 +- .../video-channels.component.ts | 2 +- .../edit/video-studio-edit.component.ts | 4 +- .../shared/video-studio.service.ts | 2 +- .../video-caption-add-modal.component.ts | 2 +- ...eo-caption-edit-modal-content.component.ts | 2 +- .../shared/video-edit.component.ts | 15 +- .../shared/video-upload.service.ts | 2 +- .../video-go-live.component.ts | 2 +- .../video-import-torrent.component.ts | 2 +- .../video-import-url.component.ts | 2 +- .../video-add-components/video-send.ts | 8 +- .../video-upload.component.ts | 2 +- .../+video-edit/video-add.component.ts | 2 +- .../+video-edit/video-update.component.ts | 5 +- .../+video-edit/video-update.resolver.ts | 4 +- .../action-buttons.component.ts | 2 +- .../action-buttons/video-rate.component.ts | 2 +- .../comment/video-comment-add.component.ts | 2 +- .../shared/comment/video-comment.component.ts | 2 +- .../comment/video-comments.component.ts | 2 +- .../information/privacy-concerns.component.ts | 2 +- .../information/video-alert.component.ts | 2 +- .../video-watch-playlist.component.ts | 2 +- .../recent-videos-recommendation.service.ts | 2 +- .../+video-watch/video-watch.component.ts | 13 +- .../video-list/overview/overview.service.ts | 5 +- .../overview/videos-overview.model.ts | 2 +- .../video-user-subscriptions.component.ts | 2 +- .../videos-list-common-page.component.ts | 2 +- client/src/app/app-routing.module.ts | 2 +- client/src/app/app.component.ts | 4 +- client/src/app/core/auth/auth-user.model.ts | 10 +- client/src/app/core/auth/auth.service.ts | 2 +- client/src/app/core/menu/menu.service.ts | 2 +- .../notification/peertube-socket.service.ts | 2 +- client/src/app/core/plugins/hooks.service.ts | 2 +- client/src/app/core/plugins/plugin.service.ts | 10 +- .../core/renderer/html-renderer.service.ts | 2 +- .../src/app/core/renderer/markdown.service.ts | 5 +- .../app/core/rest/rest-extractor.service.ts | 10 +- .../routing/homepage-redirect.component.ts | 2 +- client/src/app/core/routing/meta.service.ts | 2 +- .../scoped-tokens/scoped-tokens.service.ts | 2 +- client/src/app/core/server/server.service.ts | 22 +- client/src/app/core/theme/theme.service.ts | 2 +- .../core/users/user-local-storage.service.ts | 10 +- client/src/app/core/users/user.model.ts | 15 +- client/src/app/core/users/user.service.ts | 2 +- .../app/header/search-typeahead.component.ts | 2 +- client/src/app/helpers/utils/channel.ts | 2 +- client/src/app/helpers/utils/upload.ts | 2 +- .../app/menu/language-chooser.component.ts | 3 +- client/src/app/menu/menu.component.ts | 4 +- ...instance-config-warning-modal.component.ts | 2 +- .../video-playlist-validators.ts | 4 +- .../abuse-details.component.ts | 2 +- .../abuse-list-table.component.ts | 4 +- .../abuse-message-modal.component.ts | 2 +- .../moderation-comment-modal.component.ts | 2 +- .../processed-abuse.model.ts | 2 +- .../actor-avatar.component.ts | 2 +- .../custom-markup.service.ts | 2 +- .../dynamic-element.service.ts | 2 +- .../channel-miniature-markup.component.ts | 2 +- .../embed-markup.component.ts | 2 +- .../video-miniature-markup.component.ts | 2 +- .../videos-list-markup.component.ts | 4 +- .../dynamic-form-field.component.ts | 2 +- .../shared-forms/form-validator.service.ts | 2 +- .../markdown-textarea.component.ts | 2 +- .../shared-forms/preview-upload.component.ts | 2 +- .../shared-forms/timestamp-input.component.ts | 2 +- .../instance-about-accordion.component.ts | 3 +- .../instance-features-table.component.ts | 2 +- .../instance-follow.service.ts | 4 +- .../shared-instance/instance.service.ts | 5 +- .../shared-main/account/account.model.ts | 2 +- .../shared-main/account/account.service.ts | 2 +- .../shared/shared-main/account/actor.model.ts | 2 +- .../auth/auth-interceptor.service.ts | 3 +- .../custom-page/custom-page.service.ts | 2 +- .../shared-main/feeds/syndication.model.ts | 4 +- .../shared/shared-main/misc/help.component.ts | 2 +- .../plugins/plugin-placeholder.component.ts | 2 +- .../plugins/plugin-selector.directive.ts | 2 +- .../shared-main/users/user-history.service.ts | 2 +- .../users/user-notification.model.ts | 15 +- .../users/user-notification.service.ts | 2 +- .../users/user-notifications.component.ts | 2 +- .../video-caption/video-caption.service.ts | 4 +- .../video-channel-sync.service.ts | 3 +- .../video-channel/video-channel.model.ts | 2 +- .../video-channel/video-channel.service.ts | 2 +- .../shared-main/video/embed.component.ts | 4 +- .../shared-main/video/redundancy.service.ts | 2 +- .../shared-main/video/video-details.model.ts | 6 +- .../shared-main/video/video-edit.model.ts | 6 +- .../video/video-file-token.service.ts | 2 +- .../shared-main/video/video-import.service.ts | 4 +- .../video/video-ownership.service.ts | 2 +- .../video/video-password.service.ts | 2 +- .../shared/shared-main/video/video.model.ts | 11 +- .../shared/shared-main/video/video.service.ts | 17 +- .../shared/shared-moderation/abuse.service.ts | 2 +- .../shared-moderation/account-block.model.ts | 2 +- .../shared-moderation/blocklist.service.ts | 4 +- .../shared/shared-moderation/bulk.service.ts | 2 +- .../report-modals/account-report.component.ts | 4 +- .../report-modals/comment-report.component.ts | 4 +- .../report-modals/video-report.component.ts | 4 +- .../server-blocklist.component.ts | 2 +- .../user-ban-modal.component.ts | 2 +- .../user-moderation-dropdown.component.ts | 2 +- .../shared-moderation/video-block.service.ts | 6 +- .../shared-search/advanced-search.model.ts | 2 +- .../shared-search/find-in-bulk.service.ts | 4 +- .../shared/shared-search/search.service.ts | 2 +- .../video-share.component.ts | 4 +- .../support-modal.component.ts | 2 +- .../video-thumbnail.component.ts | 2 +- .../user-interface-settings.component.ts | 2 +- .../user-video-settings.component.ts | 3 +- .../subscribe-button.component.ts | 2 +- .../user-subscription.service.ts | 2 +- .../shared/shared-users/two-factor.service.ts | 2 +- .../shared/shared-users/user-admin.service.ts | 4 +- .../video-comment-thread-tree.model.ts | 2 +- .../video-comment.model.ts | 2 +- .../video-comment.service.ts | 2 +- .../live-stream-information.component.ts | 4 +- .../shared-video-live/live-video.service.ts | 2 +- .../video-actions-dropdown.component.ts | 2 +- .../video-download.component.ts | 4 +- .../video-filters-header.component.ts | 2 +- .../video-filters.model.ts | 18 +- .../video-miniature.component.ts | 2 +- .../videos-list.component.ts | 4 +- .../videos-selection.component.ts | 4 +- .../video-add-to-playlist.component.ts | 4 +- ...eo-playlist-element-miniature.component.ts | 4 +- .../video-playlist-element.model.ts | 4 +- .../video-playlist.model.ts | 14 +- .../video-playlist.service.ts | 2 +- client/src/assets/player/peertube-player.ts | 10 +- .../src/assets/player/shared/common/utils.ts | 2 +- .../control-bar/peertube-link-button.ts | 2 +- .../player/shared/metrics/metrics-plugin.ts | 4 +- .../p2p-media-loader-plugin.ts | 2 +- .../p2p-media-loader/segment-validator.ts | 2 +- .../player/shared/peertube/peertube-plugin.ts | 4 +- .../hls-options-builder.ts | 2 +- .../shared/playlist/playlist-menu-item.ts | 4 +- .../player/shared/playlist/playlist-menu.ts | 2 +- .../assets/player/shared/stats/stats-card.ts | 2 +- .../shared/web-video/web-video-plugin.ts | 4 +- .../src/assets/player/translations-manager.ts | 2 +- .../player/types/peertube-player-options.ts | 4 +- .../player/types/peertube-videojs-typings.ts | 2 +- client/src/assets/player/utils.ts | 2 +- client/src/root-helpers/logger.ts | 2 +- client/src/root-helpers/plugins-manager.ts | 7 +- client/src/root-helpers/video.ts | 8 +- client/src/standalone/videos/embed.ts | 2 +- .../src/standalone/videos/shared/auth-http.ts | 4 +- .../standalone/videos/shared/live-manager.ts | 4 +- .../videos/shared/peertube-plugin.ts | 4 +- .../standalone/videos/shared/player-html.ts | 2 +- .../videos/shared/player-options-builder.ts | 4 +- .../videos/shared/playlist-fetcher.ts | 2 +- .../videos/shared/playlist-tracker.ts | 2 +- .../standalone/videos/shared/video-fetcher.ts | 2 +- client/src/types/job-state-client.type.ts | 2 +- client/src/types/job-type-client.type.ts | 2 +- .../src/types/register-client-option.model.ts | 2 +- client/src/types/server-error.model.ts | 6 +- client/tsconfig.eslint.json | 5 + client/tsconfig.json | 28 +- client/tsconfig.types.json | 7 +- client/webpack/webpack.video-embed.js | 4 +- client/yarn.lock | 118 +- config/default.yaml | 1 + config/production.yaml.example | 1 + package.json | 89 +- packages/core-utils/package.json | 19 + .../src}/abuse/abuse-predefined-reasons.ts | 6 +- packages/core-utils/src/abuse/index.ts | 1 + .../core-utils/src}/common/array.ts | 0 .../core-utils/src}/common/date.ts | 0 packages/core-utils/src/common/index.ts | 10 + .../core-utils/src}/common/number.ts | 0 .../core-utils/src}/common/object.ts | 0 .../core-utils/src}/common/promises.ts | 0 .../core-utils/src}/common/random.ts | 0 .../core-utils/src}/common/regexp.ts | 0 .../core-utils/src}/common/time.ts | 0 .../core-utils/src}/common/url.ts | 4 +- .../core-utils/src}/common/version.ts | 0 .../core-utils/src}/i18n/i18n.ts | 0 packages/core-utils/src/i18n/index.ts | 1 + packages/core-utils/src/index.ts | 7 + .../core-utils/src}/plugins/hooks.ts | 7 +- packages/core-utils/src/plugins/index.ts | 1 + .../core-utils/src}/renderer/html.ts | 0 packages/core-utils/src/renderer/index.ts | 2 + .../core-utils/src}/renderer/markdown.ts | 0 packages/core-utils/src/users/index.ts | 1 + .../core-utils/src}/users/user-role.ts | 8 +- .../core-utils/src}/videos/bitrate.ts | 12 +- .../core-utils/src}/videos/common.ts | 4 +- packages/core-utils/src/videos/index.ts | 2 + packages/core-utils/tsconfig.json | 11 + packages/ffmpeg/package.json | 19 + .../ffmpeg/src}/ffmpeg-command-wrapper.ts | 8 +- .../ffmpeg-default-transcoding-profile.ts | 8 +- .../ffmpeg/src}/ffmpeg-edition.ts | 6 +- .../ffmpeg/src}/ffmpeg-images.ts | 4 +- .../ffmpeg/src}/ffmpeg-live.ts | 8 +- .../ffmpeg/src}/ffmpeg-utils.ts | 2 +- .../ffmpeg/src}/ffmpeg-version.ts | 0 .../ffmpeg/src}/ffmpeg-vod.ts | 12 +- .../ffmpeg => packages/ffmpeg/src}/ffprobe.ts | 8 +- packages/ffmpeg/src/index.ts | 9 + .../ffmpeg/src}/shared/encoder-options.ts | 4 +- packages/ffmpeg/src/shared/index.ts | 2 + .../ffmpeg/src}/shared/presets.ts | 10 +- packages/ffmpeg/tsconfig.json | 12 + packages/models/package.json | 19 + .../models/src}/activitypub/activity.ts | 6 +- .../src}/activitypub/activitypub-actor.ts | 2 +- .../activitypub/activitypub-collection.ts | 2 +- .../activitypub-ordered-collection.ts | 0 .../src}/activitypub/activitypub-root.ts | 6 +- .../src}/activitypub/activitypub-signature.ts | 0 .../models/src}/activitypub/context.ts | 0 packages/models/src/activitypub/index.ts | 9 + .../src}/activitypub/objects/abuse-object.ts | 2 +- .../activitypub/objects/activitypub-object.ts | 17 + .../activitypub/objects/cache-file-object.ts | 2 +- .../activitypub/objects/common-objects.ts | 2 +- .../models/src/activitypub/objects/index.ts | 9 + .../objects/playlist-element-object.ts | 0 .../activitypub/objects/playlist-object.ts | 2 +- .../objects/video-comment-object.ts | 2 +- .../src}/activitypub/objects/video-object.ts | 8 +- .../objects/watch-action-object.ts | 0 .../models/src}/activitypub/webfinger.ts | 0 .../models/src}/actors/account.model.ts | 4 +- .../models/src}/actors/actor-image.model.ts | 0 .../models/src/actors/actor-image.type.ts | 6 + .../models/src}/actors/actor.model.ts | 2 +- .../models/src}/actors/custom-page.model.ts | 0 .../models/src}/actors/follow.model.ts | 2 +- packages/models/src/actors/index.ts | 6 + .../bulk-remove-comments-of-body.model.ts | 0 packages/models/src/bulk/index.ts | 1 + packages/models/src/common/index.ts | 1 + .../models/src}/common/result-list.model.ts | 0 .../custom-markup/custom-markup-data.model.ts | 0 packages/models/src/custom-markup/index.ts | 1 + packages/models/src/feeds/feed-format.enum.ts | 7 + packages/models/src/feeds/index.ts | 1 + .../models/src}/http/http-methods.ts | 24 +- .../models/src/http/http-status-codes.ts | 96 +- packages/models/src/http/index.ts | 2 + packages/models/src/index.ts | 20 + packages/models/src/joinpeertube/index.ts | 1 + .../src}/joinpeertube/versions.model.ts | 0 packages/models/src/metrics/index.ts | 1 + .../metrics/playback-metric-create.model.ts | 4 +- .../moderation/abuse/abuse-create.model.ts | 2 +- .../moderation/abuse/abuse-filter.type.ts | 0 .../moderation/abuse/abuse-message.model.ts | 2 +- .../moderation/abuse/abuse-reason.model.ts | 22 + .../src/moderation/abuse/abuse-state.model.ts | 7 + .../moderation/abuse/abuse-update.model.ts | 7 + .../moderation/abuse/abuse-video-is.type.ts | 0 .../src}/moderation/abuse/abuse.model.ts | 12 +- packages/models/src/moderation/abuse/index.ts | 8 + .../src}/moderation/account-block.model.ts | 2 +- .../src}/moderation/block-status.model.ts | 0 packages/models/src/moderation/index.ts | 4 + .../src}/moderation/server-block.model.ts | 2 +- packages/models/src/nodeinfo/index.ts | 1 + .../models/src}/nodeinfo/nodeinfo.model.ts | 0 packages/models/src/overviews/index.ts | 1 + .../src}/overviews/videos-overview.model.ts | 2 +- .../src}/plugins/client/client-hook.model.ts | 0 packages/models/src/plugins/client/index.ts | 8 + .../client/plugin-client-scope.type.ts | 0 .../client/plugin-element-placeholder.type.ts | 0 .../plugins/client/plugin-selector-id.type.ts | 0 .../register-client-form-field.model.ts | 0 .../client/register-client-hook.model.ts | 2 +- .../client/register-client-route.model.ts | 0 .../register-client-settings-script.model.ts | 2 +- packages/models/src/plugins/hook-type.enum.ts | 7 + packages/models/src/plugins/index.ts | 6 + .../models/src/plugins/plugin-index/index.ts | 3 + .../peertube-plugin-index-list.model.ts | 4 +- .../peertube-plugin-index.model.ts | 0 .../peertube-plugin-latest-version.model.ts | 0 .../src}/plugins/plugin-package-json.model.ts | 2 +- packages/models/src/plugins/plugin.type.ts | 6 + .../models/src/plugins/server/api/index.ts | 3 + .../server/api/install-plugin.model.ts | 0 .../plugins/server/api/manage-plugin.model.ts | 0 .../server/api/peertube-plugin.model.ts | 4 +- packages/models/src/plugins/server/index.ts | 7 + .../src/plugins/server/managers/index.ts | 9 + .../plugin-playlist-privacy-manager.model.ts | 8 +- .../managers/plugin-settings-manager.model.ts | 0 .../managers/plugin-storage-manager.model.ts | 0 .../plugin-transcoding-manager.model.ts | 2 +- .../plugin-video-category-manager.model.ts | 2 +- .../plugin-video-language-manager.model.ts | 2 +- .../plugin-video-licence-manager.model.ts | 2 +- .../plugin-video-privacy-manager.model.ts | 8 +- .../server/plugin-constant-manager.model.ts | 0 .../server/plugin-translation.model.ts | 0 .../server/register-server-hook.model.ts | 2 +- .../src}/plugins/server/server-hook.model.ts | 0 .../src/plugins/server/settings/index.ts | 2 + .../server/settings/public-server.setting.ts | 2 +- .../settings/register-server-setting.model.ts | 2 +- packages/models/src/redundancy/index.ts | 4 + .../video-redundancies-filters.model.ts | 0 .../video-redundancy-config-filter.type.ts | 0 .../src}/redundancy/video-redundancy.model.ts | 0 .../videos-redundancy-strategy.model.ts | 0 .../runners/abort-runner-job-body.model.ts | 0 .../runners/accept-runner-job-body.model.ts | 0 .../runners/accept-runner-job-result.model.ts | 4 +- .../runners/error-runner-job-body.model.ts | 0 packages/models/src/runners/index.ts | 21 + .../runners/list-runner-jobs-query.model.ts | 4 +- .../list-runner-registration-tokens.model.ts | 0 .../src}/runners/list-runners-query.model.ts | 0 .../runners/register-runner-body.model.ts | 0 .../runners/register-runner-result.model.ts | 0 .../runners/request-runner-job-body.model.ts | 0 .../request-runner-job-result.model.ts | 4 +- .../src}/runners/runner-job-payload.model.ts | 2 +- .../runner-job-private-payload.model.ts | 2 +- .../src/runners/runner-job-state.model.ts | 13 + .../runners/runner-job-success-body.model.ts | 0 .../src}/runners/runner-job-type.type.ts | 0 .../runners/runner-job-update-body.model.ts | 0 .../models/src}/runners/runner-job.model.ts | 14 +- .../src}/runners/runner-registration-token.ts | 0 .../models/src}/runners/runner.model.ts | 0 .../runners/unregister-runner-body.model.ts | 0 .../src}/search/boolean-both-query.model.ts | 0 packages/models/src/search/index.ts | 6 + .../src}/search/search-target-query.model.ts | 0 .../video-channels-search-query.model.ts | 2 +- .../video-playlists-search-query.model.ts | 2 +- .../src}/search/videos-common-query.model.ts | 10 +- .../src}/search/videos-search-query.model.ts | 4 +- .../models/src}/server/about.model.ts | 0 .../server/broadcast-message-level.type.ts | 0 .../src}/server/client-log-create.model.ts | 2 +- .../src}/server/client-log-level.type.ts | 0 .../models/src}/server/contact-form.model.ts | 0 .../models/src}/server/custom-config.model.ts | 4 +- .../models/src}/server/debug.model.ts | 0 .../models/src}/server/emailer.model.ts | 0 packages/models/src/server/index.ts | 16 + .../models/src}/server/job.model.ts | 17 +- .../server/peertube-problem-document.model.ts | 10 +- .../models/src}/server/server-config.model.ts | 10 +- .../models/src}/server/server-debug.model.ts | 0 .../src}/server/server-error-code.enum.ts | 57 +- .../src}/server/server-follow-create.model.ts | 0 .../src}/server/server-log-level.type.ts | 0 .../models/src}/server/server-stats.model.ts | 4 +- packages/models/src/tokens/index.ts | 1 + .../src}/tokens/oauth-client-local.model.ts | 0 packages/models/src/users/index.ts | 16 + .../models/src/users/registration/index.ts | 5 + .../users/registration/user-register.model.ts | 0 .../user-registration-request.model.ts | 2 +- .../user-registration-state.model.ts | 7 + .../user-registration-update-state.model.ts | 0 .../registration/user-registration.model.ts | 4 +- .../users/two-factor-enable-result.model.ts | 0 .../src}/users/user-create-result.model.ts | 0 .../models/src}/users/user-create.model.ts | 8 +- packages/models/src/users/user-flag.model.ts | 6 + .../models/src}/users/user-login.model.ts | 0 .../users/user-notification-setting.model.ts | 34 + .../src}/users/user-notification.model.ts | 58 +- .../src}/users/user-refresh-token.model.ts | 0 packages/models/src/users/user-right.enum.ts | 53 + packages/models/src/users/user-role.ts | 8 + .../models/src}/users/user-scoped-token.ts | 0 .../models/src}/users/user-update-me.model.ts | 2 +- .../models/src}/users/user-update.model.ts | 8 +- .../src}/users/user-video-quota.model.ts | 0 .../models/src}/users/user.model.ts | 20 +- packages/models/src/videos/blacklist/index.ts | 3 + .../blacklist/video-blacklist-create.model.ts | 0 .../blacklist/video-blacklist-update.model.ts | 0 .../videos/blacklist/video-blacklist.model.ts | 20 + packages/models/src/videos/caption/index.ts | 2 + .../caption/video-caption-update.model.ts | 0 .../videos/caption/video-caption.model.ts | 2 +- .../src/videos/change-ownership/index.ts | 3 + .../video-change-ownership-accept.model.ts | 0 .../video-change-ownership-create.model.ts | 0 .../video-change-ownership.model.ts | 19 + .../models/src/videos/channel-sync/index.ts | 3 + .../video-channel-sync-create.model.ts | 0 .../video-channel-sync-state.enum.ts | 8 + .../channel-sync/video-channel-sync.model.ts | 8 +- packages/models/src/videos/channel/index.ts | 4 + .../video-channel-create-result.model.ts | 0 .../channel/video-channel-create.model.ts | 0 .../channel/video-channel-update.model.ts | 0 .../videos/channel/video-channel.model.ts | 4 +- packages/models/src/videos/comment/index.ts | 2 + .../comment/video-comment-create.model.ts | 0 .../videos/comment/video-comment.model.ts | 4 +- packages/models/src/videos/file/index.ts | 3 + .../videos/file/video-file-metadata.model.ts | 0 .../src}/videos/file/video-file.model.ts | 7 +- .../src/videos/file/video-resolution.enum.ts | 13 + packages/models/src/videos/import/index.ts | 4 + .../import/video-import-create.model.ts | 2 +- .../videos/import/video-import-state.enum.ts | 10 + .../src}/videos/import/video-import.model.ts | 8 +- .../videos-import-in-channel-create.model.ts | 0 packages/models/src/videos/index.ts | 43 + packages/models/src/videos/live/index.ts | 8 + .../videos/live/live-video-create.model.ts | 11 + .../src/videos/live/live-video-error.enum.ts | 11 + .../live/live-video-event-payload.model.ts | 7 + .../src}/videos/live/live-video-event.type.ts | 0 .../live/live-video-latency-mode.enum.ts | 7 + .../videos/live/live-video-session.model.ts | 8 +- .../videos/live/live-video-update.model.ts | 9 + .../src/videos/live/live-video.model.ts | 14 + .../models/src}/videos/nsfw-policy.type.ts | 0 packages/models/src/videos/playlist/index.ts | 12 + .../playlist/video-exist-in-playlist.model.ts | 0 .../video-playlist-create-result.model.ts | 0 .../playlist/video-playlist-create.model.ts | 4 +- ...eo-playlist-element-create-result.model.ts | 0 .../video-playlist-element-create.model.ts | 0 .../video-playlist-element-update.model.ts | 0 .../playlist/video-playlist-element.model.ts | 21 + .../playlist/video-playlist-privacy.model.ts | 7 + .../playlist/video-playlist-reorder.model.ts | 0 .../playlist/video-playlist-type.model.ts | 6 + .../playlist/video-playlist-update.model.ts | 4 +- .../videos/playlist/video-playlist.model.ts | 35 + .../videos/rate/account-video-rate.model.ts | 7 + packages/models/src/videos/rate/index.ts | 5 + .../rate/user-video-rate-update.model.ts | 2 +- .../src}/videos/rate/user-video-rate.model.ts | 2 +- .../src}/videos/rate/user-video-rate.type.ts | 0 packages/models/src/videos/stats/index.ts | 6 + .../stats/video-stats-overall-query.model.ts | 0 .../videos/stats/video-stats-overall.model.ts | 0 .../stats/video-stats-retention.model.ts | 0 .../video-stats-timeserie-metric.type.ts | 0 .../video-stats-timeserie-query.model.ts | 0 .../stats/video-stats-timeserie.model.ts | 0 .../models/src}/videos/storyboard.model.ts | 0 packages/models/src/videos/studio/index.ts | 1 + .../studio/video-studio-create-edit.model.ts | 0 packages/models/src/videos/thumbnail.type.ts | 6 + .../models/src/videos/transcoding/index.ts | 3 + .../video-transcoding-create.model.ts | 0 .../video-transcoding-fps.model.ts | 0 .../transcoding/video-transcoding.model.ts | 4 +- .../src}/videos/video-constant.model.ts | 0 .../src}/videos/video-create-result.model.ts | 0 .../models/src}/videos/video-create.model.ts | 6 +- .../models/src/videos/video-include.enum.ts | 10 + .../src}/videos/video-password.model.ts | 0 .../models/src/videos/video-privacy.enum.ts | 9 + .../models/src}/videos/video-rate.type.ts | 0 .../src/videos/video-schedule-update.model.ts | 7 + .../src}/videos/video-sort-field.type.ts | 0 .../models/src/videos/video-source.model.ts | 0 .../models/src/videos/video-state.enum.ts | 13 + .../models/src/videos/video-storage.enum.ts | 6 + .../videos/video-streaming-playlist.model.ts | 6 +- .../videos/video-streaming-playlist.type.ts | 5 + .../models/src}/videos/video-token.model.ts | 0 .../models/src}/videos/video-update.model.ts | 6 +- .../models/src}/videos/video-view.model.ts | 0 .../models/src}/videos/video.model.ts | 22 +- packages/models/tsconfig.json | 8 + .../models}/tsconfig.types.json | 8 +- packages/node-utils/package.json | 19 + .../node-utils/src}/crypto.ts | 0 .../common => packages/node-utils/src}/env.ts | 34 +- .../node-utils/src}/file.ts | 2 +- packages/node-utils/src/index.ts | 5 + packages/node-utils/src/path.ts | 50 + .../node-utils/src}/uuid.ts | 4 +- packages/node-utils/tsconfig.json | 8 + packages/peertube-runner/.npmignore | 6 - packages/peertube-runner/README.md | 29 - packages/peertube-runner/register/index.ts | 1 - packages/peertube-runner/server/index.ts | 1 - .../peertube-runner/server/process/index.ts | 2 - .../server/process/shared/index.ts | 3 - .../peertube-runner/server/shared/index.ts | 1 - packages/peertube-runner/shared/index.ts | 3 - packages/peertube-runner/shared/ipc/index.ts | 2 - .../shared/ipc/shared/index.ts | 2 - packages/peertube-runner/tsconfig.json | 9 - packages/server-commands/package.json | 19 + .../server-commands/src}/bulk/bulk-command.ts | 4 +- packages/server-commands/src/bulk/index.ts | 1 + .../server-commands/src}/cli/cli-command.ts | 2 +- packages/server-commands/src/cli/index.ts | 1 + .../src}/custom-pages/custom-pages-command.ts | 4 +- .../server-commands/src/custom-pages/index.ts | 1 + .../src}/feeds/feeds-command.ts | 6 +- packages/server-commands/src/feeds/index.ts | 1 + packages/server-commands/src/index.ts | 14 + packages/server-commands/src/logs/index.ts | 1 + .../server-commands/src}/logs/logs-command.ts | 4 +- .../src}/moderation/abuses-command.ts | 14 +- .../server-commands/src/moderation/index.ts | 1 + .../server-commands/src/overviews/index.ts | 1 + .../src}/overviews/overviews-command.ts | 4 +- .../server-commands/src/requests/index.ts | 1 + .../server-commands/src}/requests/requests.ts | 13 +- packages/server-commands/src/runners/index.ts | 3 + .../src}/runners/runner-jobs-command.ts | 25 +- .../runner-registration-tokens-command.ts | 6 +- .../src}/runners/runners-command.ts | 17 +- packages/server-commands/src/search/index.ts | 1 + .../src}/search/search-command.ts | 4 +- .../src}/server/config-command.ts | 8 +- .../src}/server/contact-form-command.ts | 5 +- .../src}/server/debug-command.ts | 4 +- .../src}/server/follows-command.ts | 8 +- .../server-commands/src}/server/follows.ts | 4 +- packages/server-commands/src/server/index.ts | 15 + .../src}/server/jobs-command.ts | 6 +- .../server-commands/src}/server/jobs.ts | 7 +- .../src}/server/metrics-command.ts | 4 +- .../src}/server/object-storage-command.ts | 4 +- .../src}/server/plugins-command.ts | 19 +- .../src}/server/redundancy-command.ts | 4 +- .../server-commands/src}/server/server.ts | 57 +- .../src}/server/servers-command.ts | 11 +- .../server-commands/src}/server/servers.ts | 6 +- .../src}/server/stats-command.ts | 4 +- .../src}/shared/abstract-command.ts | 16 +- packages/server-commands/src/shared/index.ts | 1 + packages/server-commands/src/socket/index.ts | 1 + .../src}/socket/socket-io-command.ts | 2 +- .../src}/users/accounts-command.ts | 4 +- .../server-commands/src}/users/accounts.ts | 2 +- .../src}/users/blocklist-command.ts | 4 +- packages/server-commands/src/users/index.ts | 10 + .../src}/users/login-command.ts | 6 +- .../server-commands/src}/users/login.ts | 2 +- .../src}/users/notifications-command.ts | 4 +- .../src}/users/registrations-command.ts | 14 +- .../src}/users/subscriptions-command.ts | 4 +- .../src}/users/two-factor-command.ts | 6 +- .../src}/users/users-command.ts | 23 +- .../src}/videos/blacklist-command.ts | 7 +- .../src}/videos/captions-command.ts | 6 +- .../src}/videos/change-ownership-command.ts | 5 +- .../src}/videos/channel-syncs-command.ts | 8 +- .../src}/videos/channels-command.ts | 8 +- .../server-commands/src}/videos/channels.ts | 2 +- .../src}/videos/comments-command.ts | 8 +- .../src}/videos/history-command.ts | 4 +- .../src}/videos/imports-command.ts | 7 +- packages/server-commands/src/videos/index.ts | 22 + .../src}/videos/live-command.ts | 22 +- .../server-commands/src}/videos/live.ts | 9 +- .../src}/videos/playlists-command.ts | 16 +- .../src}/videos/services-command.ts | 4 +- .../src}/videos/storyboard-command.ts | 4 +- .../videos/streaming-playlists-command.ts | 8 +- .../src}/videos/video-passwords-command.ts | 5 +- .../src}/videos/video-stats-command.ts | 12 +- .../src}/videos/video-studio-command.ts | 4 +- .../src}/videos/video-token-command.ts | 6 +- .../src}/videos/videos-command.ts | 36 +- .../src}/videos/views-command.ts | 4 +- packages/server-commands/tsconfig.json | 14 + .../tests/fixtures/60fps_720p_small.mp4 | Bin .../mastodon/bad-body-http-signature.json | 0 .../ap-json/mastodon/bad-http-signature.json | 0 .../ap-json/mastodon/bad-public-key.json | 0 .../mastodon/create-bad-signature.json | 0 .../fixtures/ap-json/mastodon/create.json | 0 .../ap-json/mastodon/http-signature.json | 0 .../fixtures/ap-json/mastodon/public-key.json | 0 .../peertube/announce-without-context.json | 0 .../ap-json/peertube/invalid-keys.json | 0 .../tests/fixtures/ap-json/peertube/keys.json | 0 .../tests/fixtures/avatar-big.png | Bin .../tests/fixtures/avatar-resized-120x120.gif | Bin .../tests/fixtures/avatar-resized-120x120.png | Bin .../tests/fixtures/avatar-resized-48x48.gif | Bin .../tests/fixtures/avatar-resized-48x48.png | Bin .../tests/fixtures/avatar.gif | Bin .../tests/fixtures/avatar.png | Bin .../fixtures/avatar2-resized-120x120.png | Bin .../tests/fixtures/avatar2-resized-48x48.png | Bin .../tests/fixtures/avatar2.png | Bin .../tests/fixtures/banner-resized.jpg | Bin .../tests/fixtures/banner.jpg | Bin .../tests/fixtures/custom-preview-big.png | Bin .../tests/fixtures/custom-preview.jpg | Bin .../tests/fixtures/custom-thumbnail-big.jpg | Bin .../tests/fixtures/custom-thumbnail.jpg | Bin .../tests/fixtures/custom-thumbnail.png | Bin {server => packages}/tests/fixtures/exif.jpg | Bin {server => packages}/tests/fixtures/exif.png | Bin .../tests/fixtures/live/0-000067.ts | Bin .../tests/fixtures/live/0-000068.ts | Bin .../tests/fixtures/live/0-000069.ts | Bin .../tests/fixtures/live/0-000070.ts | Bin .../tests/fixtures/live/0.m3u8 | 0 .../tests/fixtures/live/1-000067.ts | Bin .../tests/fixtures/live/1-000068.ts | Bin .../tests/fixtures/live/1-000069.ts | Bin .../tests/fixtures/live/1-000070.ts | Bin .../tests/fixtures/live/1.m3u8 | 0 .../tests/fixtures/live/master.m3u8 | 0 .../tests/fixtures/low-bitrate.mp4 | Bin .../peertube-plugin-test-broken/main.js | 0 .../peertube-plugin-test-broken/package.json | 0 .../main.js | 0 .../package.json | 0 .../main.js | 0 .../package.json | 0 .../main.js | 0 .../package.json | 0 .../languages/fr.json | 0 .../languages/it.json | 0 .../main.js | 0 .../package.json | 0 .../peertube-plugin-test-five/main.js | 0 .../peertube-plugin-test-five/package.json | 0 .../peertube-plugin-test-four/main.js | 0 .../peertube-plugin-test-four/package.json | 0 .../main.js | 0 .../package.json | 0 .../main.js | 0 .../package.json | 0 .../main.js | 0 .../package.json | 0 .../peertube-plugin-test-native/main.js | 0 .../peertube-plugin-test-native/package.json | 0 .../main.js | 0 .../package.json | 0 .../fixtures/peertube-plugin-test-six/main.js | 0 .../peertube-plugin-test-six/package.json | 0 .../main.js | 0 .../package.json | 0 .../main.js | 0 .../package.json | 0 .../peertube-plugin-test-unloading/lib.js | 0 .../peertube-plugin-test-unloading/main.js | 0 .../package.json | 0 .../main.js | 0 .../package.json | 0 .../peertube-plugin-test-websocket/main.js | 0 .../package.json | 0 .../peertube-plugin-test/languages/fr.json | 0 .../fixtures/peertube-plugin-test/main.js | 0 .../peertube-plugin-test/package.json | 0 .../tests/fixtures/rtmps.cert | 0 {server => packages}/tests/fixtures/rtmps.key | 0 .../tests/fixtures/sample.ogg | Bin .../tests/fixtures/subtitle-bad.txt | 0 .../tests/fixtures/subtitle-good.srt | 0 .../tests/fixtures/subtitle-good1.vtt | 0 .../tests/fixtures/subtitle-good2.vtt | 0 .../tests/fixtures/thumbnail-playlist.jpg | Bin .../tests/fixtures/video-720p.torrent | Bin .../tests/fixtures/video_import_preview.jpg | Bin .../fixtures/video_import_preview_yt_dlp.jpg | Bin .../tests/fixtures/video_import_thumbnail.jpg | Bin .../video_import_thumbnail_yt_dlp.jpg | Bin .../tests/fixtures/video_short.avi | Bin .../tests/fixtures/video_short.mkv | Bin .../tests/fixtures/video_short.mp4 | Bin .../tests/fixtures/video_short.mp4.jpg | Bin .../tests/fixtures/video_short.ogv | Bin .../tests/fixtures/video_short.ogv.jpg | Bin .../tests/fixtures/video_short.webm | Bin .../tests/fixtures/video_short.webm.jpg | Bin .../fixtures/video_short1-preview.webm.jpg | Bin .../tests/fixtures/video_short1.webm | Bin .../tests/fixtures/video_short1.webm.jpg | Bin .../tests/fixtures/video_short2.webm | Bin .../tests/fixtures/video_short2.webm.jpg | Bin .../tests/fixtures/video_short3.webm | Bin .../tests/fixtures/video_short3.webm.jpg | Bin .../tests/fixtures/video_short_0p.mp4 | Bin .../tests/fixtures/video_short_144p.m3u8 | 0 .../tests/fixtures/video_short_144p.mp4 | Bin .../tests/fixtures/video_short_240p.m3u8 | 0 .../tests/fixtures/video_short_240p.mp4 | Bin .../tests/fixtures/video_short_360p.m3u8 | 0 .../tests/fixtures/video_short_360p.mp4 | Bin .../tests/fixtures/video_short_480.webm | Bin .../tests/fixtures/video_short_480p.m3u8 | 0 .../tests/fixtures/video_short_480p.mp4 | Bin .../tests/fixtures/video_short_4k.mp4 | Bin .../tests/fixtures/video_short_720p.m3u8 | 0 .../tests/fixtures/video_short_720p.mp4 | Bin .../tests/fixtures/video_short_fake.webm | 0 .../tests/fixtures/video_short_mp3_256k.mp4 | Bin .../tests/fixtures/video_short_no_audio.mp4 | Bin .../tests/fixtures/video_very_long_10p.mp4 | Bin .../tests/fixtures/video_very_short_240p.mp4 | Bin packages/tests/package.json | 12 + .../tests/src}/api/activitypub/cleaner.ts | 6 +- .../tests/src}/api/activitypub/client.ts | 6 +- .../tests/src}/api/activitypub/fetch.ts | 4 +- packages/tests/src/api/activitypub/index.ts | 5 + .../tests/src}/api/activitypub/refresher.ts | 10 +- .../tests/src}/api/activitypub/security.ts | 76 +- .../tests/src}/api/check-params/abuses.ts | 8 +- .../tests/src}/api/check-params/accounts.ts | 6 +- .../tests/src}/api/check-params/blocklist.ts | 6 +- .../tests/src}/api/check-params/bulk.ts | 10 +- .../api/check-params/channel-import-videos.ts | 8 +- .../tests/src}/api/check-params/config.ts | 8 +- .../src}/api/check-params/contact-form.ts | 6 +- .../src}/api/check-params/custom-pages.ts | 4 +- .../tests/src}/api/check-params/debug.ts | 10 +- .../tests/src}/api/check-params/follows.ts | 6 +- packages/tests/src/api/check-params/index.ts | 45 + .../tests/src}/api/check-params/jobs.ts | 6 +- .../tests/src}/api/check-params/live.ts | 11 +- .../tests/src}/api/check-params/logs.ts | 10 +- .../tests/src}/api/check-params/metrics.ts | 12 +- .../tests/src}/api/check-params/my-user.ts | 9 +- .../tests/src}/api/check-params/plugins.ts | 6 +- .../tests/src}/api/check-params/redundancy.ts | 6 +- .../src}/api/check-params/registrations.ts | 10 +- .../tests/src}/api/check-params/runners.ts | 15 +- .../tests/src}/api/check-params/search.ts | 12 +- .../tests/src}/api/check-params/services.ts | 18 +- .../src}/api/check-params/transcoding.ts | 4 +- .../tests/src}/api/check-params/two-factor.ts | 10 +- .../src}/api/check-params/upload-quota.ts | 8 +- .../api/check-params/user-notifications.ts | 8 +- .../api/check-params/user-subscriptions.ts | 6 +- .../src}/api/check-params/users-admin.ts | 9 +- .../src}/api/check-params/users-emails.ts | 10 +- .../src}/api/check-params/video-blacklist.ts | 6 +- .../src}/api/check-params/video-captions.ts | 6 +- .../api/check-params/video-channel-syncs.ts | 7 +- .../src}/api/check-params/video-channels.ts | 9 +- .../src}/api/check-params/video-comments.ts | 6 +- .../src}/api/check-params/video-files.ts | 6 +- .../src}/api/check-params/video-imports.ts | 10 +- .../src}/api/check-params/video-passwords.ts | 27 +- .../src}/api/check-params/video-playlists.ts | 6 +- .../src}/api/check-params/video-source.ts | 4 +- .../api/check-params/video-storyboards.ts | 4 +- .../src}/api/check-params/video-studio.ts | 16 +- .../src}/api/check-params/video-token.ts | 4 +- .../api/check-params/videos-common-filters.ts | 18 +- .../src}/api/check-params/videos-history.ts | 6 +- .../src}/api/check-params/videos-overviews.ts | 2 +- .../tests/src}/api/check-params/videos.ts | 44 +- .../tests/src}/api/check-params/views.ts | 4 +- packages/tests/src/api/live/index.ts | 7 + .../tests/src}/api/live/live-constraints.ts | 8 +- .../tests/src}/api/live/live-fast-restream.ts | 6 +- .../tests/src}/api/live/live-permanent.ts | 10 +- .../tests/src}/api/live/live-rtmps.ts | 6 +- .../tests/src}/api/live/live-save-replay.ts | 35 +- .../src}/api/live/live-socket-messages.ts | 12 +- .../tests/src}/api/live/live.ts | 12 +- .../tests/src}/api/moderation/abuses.ts | 4 +- .../api/moderation/blocklist-notification.ts | 6 +- .../tests/src}/api/moderation/blocklist.ts | 4 +- packages/tests/src/api/moderation/index.ts | 4 + .../src}/api/moderation/video-blacklist.ts | 8 +- .../api/notifications/admin-notifications.ts | 19 +- .../notifications/comments-notifications.ts | 13 +- packages/tests/src/api/notifications/index.ts | 6 + .../notifications/moderation-notifications.ts | 36 +- .../api/notifications/notifications-api.ts | 14 +- .../registrations-notifications.ts | 13 +- .../api/notifications/user-notifications.ts | 32 +- .../tests/src/api/object-storage/index.ts | 4 + .../tests/src}/api/object-storage/live.ts | 11 +- .../src}/api/object-storage/video-imports.ts | 9 +- .../video-static-file-privacy.ts | 11 +- .../tests/src}/api/object-storage/videos.ts | 26 +- packages/tests/src/api/redundancy/index.ts | 3 + .../src}/api/redundancy/manage-redundancy.ts | 4 +- .../api/redundancy/redundancy-constraints.ts | 4 +- .../tests/src}/api/redundancy/redundancy.ts | 11 +- packages/tests/src/api/runners/index.ts | 5 + .../tests/src}/api/runners/runner-common.ts | 15 +- .../api/runners/runner-live-transcoding.ts | 12 +- .../tests/src}/api/runners/runner-socket.ts | 4 +- .../api/runners/runner-studio-transcoding.ts | 11 +- .../api/runners/runner-vod-transcoding.ts | 10 +- packages/tests/src/api/search/index.ts | 7 + .../search-activitypub-video-channels.ts | 6 +- .../search-activitypub-video-playlists.ts | 6 +- .../api/search/search-activitypub-videos.ts | 6 +- .../tests/src}/api/search/search-channels.ts | 4 +- .../tests/src}/api/search/search-index.ts | 10 +- .../tests/src}/api/search/search-playlists.ts | 4 +- .../tests/src}/api/search/search-videos.ts | 6 +- .../tests/src}/api/server/auto-follows.ts | 6 +- .../tests/src}/api/server/bulk.ts | 2 +- .../tests/src}/api/server/config-defaults.ts | 12 +- .../tests/src}/api/server/config.ts | 6 +- .../tests/src}/api/server/contact-form.ts | 8 +- .../tests/src}/api/server/email.ts | 6 +- .../src}/api/server/follow-constraints.ts | 4 +- .../src}/api/server/follows-moderation.ts | 6 +- .../tests/src}/api/server/follows.ts | 9 +- .../tests/src}/api/server/handle-down.ts | 9 +- .../tests/src}/api/server/homepage.ts | 4 +- packages/tests/src/api/server/index.ts | 22 + .../tests/src}/api/server/jobs.ts | 6 +- .../tests/src}/api/server/logs.ts | 4 +- .../tests/src}/api/server/no-client.ts | 4 +- .../tests/src}/api/server/open-telemetry.ts | 13 +- .../tests/src}/api/server/plugins.ts | 11 +- .../tests/src}/api/server/proxy.ts | 12 +- .../tests/src}/api/server/reverse-proxy.ts | 6 +- .../tests/src}/api/server/services.ts | 10 +- .../tests/src}/api/server/slow-follows.ts | 4 +- .../tests/src}/api/server/stats.ts | 6 +- .../tests/src}/api/server/tracker.ts | 8 +- .../tests/src}/api/transcoding/audio-only.ts | 4 +- .../api/transcoding/create-transcoding.ts | 9 +- .../tests/src}/api/transcoding/hls.ts | 11 +- packages/tests/src/api/transcoding/index.ts | 6 + .../tests/src}/api/transcoding/transcoder.ts | 14 +- .../transcoding/update-while-transcoding.ts | 9 +- .../src}/api/transcoding/video-studio.ts | 10 +- packages/tests/src/api/users/index.ts | 8 + .../tests/src}/api/users/oauth.ts | 14 +- .../tests/src}/api/users/registrations.ts | 6 +- .../tests/src}/api/users/two-factor.ts | 14 +- .../src}/api/users/user-subscriptions.ts | 4 +- .../tests/src}/api/users/user-videos.ts | 4 +- .../api/users/users-email-verification.ts | 6 +- .../src}/api/users/users-multiple-servers.ts | 15 +- .../tests/src}/api/users/users.ts | 6 +- .../src}/api/videos/channel-import-videos.ts | 6 +- packages/tests/src/api/videos/index.ts | 23 + .../tests/src}/api/videos/multiple-servers.ts | 20 +- .../tests/src}/api/videos/resumable-upload.ts | 18 +- .../tests/src}/api/videos/single-server.ts | 11 +- .../tests/src}/api/videos/video-captions.ts | 7 +- .../src}/api/videos/video-change-ownership.ts | 6 +- .../src}/api/videos/video-channel-syncs.ts | 9 +- .../tests/src}/api/videos/video-channels.ts | 11 +- .../tests/src}/api/videos/video-comments.ts | 4 +- .../src}/api/videos/video-description.ts | 2 +- .../tests/src}/api/videos/video-files.ts | 4 +- .../tests/src}/api/videos/video-imports.ts | 15 +- .../tests/src}/api/videos/video-nsfw.ts | 4 +- .../tests/src}/api/videos/video-passwords.ts | 4 +- .../api/videos/video-playlist-thumbnails.ts | 6 +- .../tests/src}/api/videos/video-playlists.ts | 14 +- .../tests/src}/api/videos/video-privacy.ts | 13 +- .../src}/api/videos/video-schedule-update.ts | 10 +- .../tests/src}/api/videos/video-source.ts | 11 +- .../api/videos/video-static-file-privacy.ts | 14 +- .../tests/src}/api/videos/video-storyboard.ts | 10 +- .../src}/api/videos/videos-common-filters.ts | 28 +- .../tests/src}/api/videos/videos-history.ts | 12 +- .../tests/src}/api/videos/videos-overview.ts | 6 +- packages/tests/src/api/views/index.ts | 5 + .../src}/api/views/video-views-counter.ts | 6 +- .../api/views/video-views-overall-stats.ts | 8 +- .../api/views/video-views-retention-stats.ts | 4 +- .../api/views/video-views-timeserie-stats.ts | 6 +- .../src}/api/views/videos-views-cleaner.ts | 8 +- .../cli/create-generate-storyboard-job.ts | 9 +- .../src}/cli/create-import-video-file-job.ts | 20 +- .../src}/cli/create-move-video-storage-job.ts | 9 +- .../tests => packages/tests/src}/cli/index.ts | 0 .../tests/src}/cli/peertube.ts | 84 +- .../tests/src}/cli/plugins.ts | 2 +- .../tests/src}/cli/prune-storage.ts | 11 +- .../tests/src}/cli/regenerate-thumbnails.ts | 6 +- .../tests/src}/cli/reset-password.ts | 2 +- .../tests/src}/cli/update-host.ts | 6 +- .../tests => packages/tests/src}/client.ts | 6 +- .../tests/src}/external-plugins/akismet.ts | 4 +- .../tests/src}/external-plugins/auth-ldap.ts | 4 +- .../external-plugins/auto-block-videos.ts | 8 +- .../tests/src}/external-plugins/auto-mute.ts | 8 +- .../tests/src}/external-plugins/index.ts | 0 .../tests/src}/feeds/feeds.ts | 10 +- .../tests/src}/feeds/index.ts | 0 .../tests/src}/misc-endpoints.ts | 14 +- .../tests/src}/peertube-runner/client-cli.ts | 10 +- packages/tests/src/peertube-runner/index.ts | 4 + .../src}/peertube-runner/live-transcoding.ts | 19 +- .../peertube-runner/studio-transcoding.ts | 9 +- .../src}/peertube-runner/vod-transcoding.ts | 17 +- .../tests/src}/plugins/action-hooks.ts | 4 +- .../tests/src}/plugins/external-auth.ts | 10 +- .../tests/src}/plugins/filter-hooks.ts | 6 +- .../tests/src}/plugins/html-injection.ts | 2 +- .../tests/src}/plugins/id-and-pass-auth.ts | 12 +- .../tests/src}/plugins/index.ts | 0 .../tests/src}/plugins/plugin-helpers.ts | 8 +- .../tests/src}/plugins/plugin-router.ts | 4 +- .../tests/src}/plugins/plugin-storage.ts | 7 +- .../tests/src}/plugins/plugin-transcoding.ts | 6 +- .../tests/src}/plugins/plugin-unloading.ts | 4 +- .../tests/src}/plugins/plugin-websocket.ts | 8 +- .../tests/src}/plugins/translations.ts | 8 +- .../tests/src}/plugins/video-constants.ts | 6 +- .../tests/src/server-helpers/activitypub.ts | 59 +- .../tests/src/server-helpers}/core-utils.ts | 10 +- .../tests/src/server-helpers}/crypto.ts | 2 +- .../tests/src/server-helpers}/dns.ts | 2 +- .../tests/src/server-helpers}/image.ts | 9 +- packages/tests/src/server-helpers/index.ts | 10 + .../tests/src/server-helpers}/markdown.ts | 2 +- packages/tests/src/server-helpers/mentions.ts | 17 + .../tests/src/server-helpers}/request.ts | 10 +- .../tests/src/server-helpers}/validator.ts | 5 +- .../tests/src/server-helpers}/version.ts | 2 +- packages/tests/src/server-lib/index.ts | 1 + .../video-constant-registry-factory.ts | 13 +- .../tests/src}/shared/actors.ts | 7 +- .../tests/src}/shared/captions.ts | 2 +- .../tests/src}/shared/checks.ts | 21 +- .../tests/src}/shared/directories.ts | 7 +- .../tests/src}/shared/generate.ts | 13 +- .../tests/src}/shared/live.ts | 13 +- .../tests/src/shared/mock-servers/index.ts | 8 + .../src}/shared/mock-servers/mock-429.ts | 2 +- .../src}/shared/mock-servers/mock-email.ts | 3 +- .../src}/shared/mock-servers/mock-http.ts | 2 +- .../mock-servers/mock-instances-index.ts | 2 +- .../mock-joinpeertube-versions.ts | 2 +- .../mock-servers/mock-object-storage.ts | 4 +- .../mock-servers/mock-plugin-blocklist.ts | 2 +- .../src}/shared/mock-servers/mock-proxy.ts | 2 +- .../tests/src}/shared/mock-servers/shared.ts | 0 .../tests/src}/shared/notifications.ts | 24 +- .../src}/shared/peertube-runner-process.ts | 24 +- .../tests/src}/shared/plugins.ts | 2 +- .../tests/src}/shared/requests.ts | 2 +- .../tests/src}/shared/sql-command.ts | 4 +- .../tests/src}/shared/streaming-playlists.ts | 20 +- .../tests/src}/shared/tests.ts | 0 .../tests/src}/shared/tracker.ts | 4 +- .../tests/src}/shared/video-playlists.ts | 4 +- .../tests/src}/shared/videos.ts | 32 +- .../tests/src}/shared/views.ts | 8 +- .../tests/src}/shared/webtorrent.ts | 16 +- packages/tests/tsconfig.json | 27 + packages/{types => types-generator}/README.md | 0 .../generate-package.ts | 23 +- packages/types-generator/package.json | 9 + packages/types-generator/src/client/index.ts | 1 + .../src/client/tsconfig.types.json} | 8 +- packages/types-generator/src/index.ts | 3 + .../{types => types-generator}/tests/test.ts | 4 +- packages/types-generator/tsconfig.dist.json | 17 + packages/types-generator/tsconfig.json | 11 + .../tsconfig.types.json} | 14 +- packages/types/src/client/index.ts | 1 - packages/types/src/index.ts | 3 - packages/types/tsconfig.dist.json | 16 - packages/typescript-utils/package.json | 19 + packages/typescript-utils/src/index.ts | 1 + .../typescript-utils/src}/types.ts | 0 packages/typescript-utils/tsconfig.json | 8 + packages/typescript-utils/tsconfig.types.json | 10 + scripts/benchmark.ts | 12 +- scripts/build/peertube-cli.sh | 12 + scripts/build/peertube-runner.sh | 5 +- scripts/build/server.sh | 9 +- scripts/build/tests.sh | 9 + scripts/ci.sh | 104 +- scripts/client-build-stats.ts | 4 +- scripts/dev/cli.sh | 16 - scripts/dev/peertube-cli.sh | 11 + scripts/dev/peertube-runner.sh | 6 +- scripts/dev/server.sh | 8 +- scripts/generate-code-contributors.ts | 2 +- scripts/i18n/create-custom-files.ts | 14 +- scripts/nightly.sh | 11 + scripts/release.sh | 13 +- scripts/setup/cli.sh | 17 - scripts/simulate-many-viewers.ts | 4 +- scripts/tsconfig.json | 5 +- server/controllers/api/search/shared/index.ts | 1 - server/controllers/feeds/shared/index.ts | 2 - server/controllers/index.ts | 14 - server/helpers/ffmpeg/index.ts | 4 - server/helpers/youtube-dl/index.ts | 3 - server/lib/activitypub/actors/index.ts | 6 - server/lib/activitypub/actors/shared/index.ts | 3 - server/lib/activitypub/playlists/index.ts | 3 - .../lib/activitypub/playlists/shared/index.ts | 2 - server/lib/activitypub/process/index.ts | 1 - server/lib/activitypub/send/index.ts | 10 - server/lib/activitypub/send/shared/index.ts | 2 - server/lib/activitypub/videos/index.ts | 4 - server/lib/activitypub/videos/shared/index.ts | 6 - server/lib/files-cache/index.ts | 6 - server/lib/files-cache/shared/index.ts | 2 - server/lib/job-queue/index.ts | 1 - server/lib/live/index.ts | 4 - server/lib/live/shared/index.ts | 1 - .../live/shared/transcoding-wrapper/index.ts | 3 - server/lib/model-loaders/index.ts | 2 - server/lib/notifier/index.ts | 1 - server/lib/notifier/shared/abuse/index.ts | 4 - server/lib/notifier/shared/blacklist/index.ts | 3 - server/lib/notifier/shared/comment/index.ts | 2 - server/lib/notifier/shared/common/index.ts | 1 - server/lib/notifier/shared/follow/index.ts | 3 - server/lib/notifier/shared/index.ts | 7 - server/lib/notifier/shared/instance/index.ts | 4 - .../shared/video-publication/index.ts | 6 - server/lib/object-storage/index.ts | 5 - server/lib/object-storage/shared/client.ts | 71 -- server/lib/object-storage/shared/index.ts | 3 - .../lib/opentelemetry/metric-helpers/index.ts | 7 - server/lib/opentelemetry/tracing.ts | 94 -- server/lib/runners/index.ts | 3 - server/lib/runners/job-handlers/index.ts | 7 - .../lib/runners/job-handlers/shared/index.ts | 1 - server/lib/transcoding/shared/index.ts | 2 - .../transcoding/shared/job-builders/index.ts | 2 - server/lib/views/shared/index.ts | 3 - server/lib/worker/workers/image-processor.ts | 7 - server/middlewares/cache/index.ts | 1 - server/middlewares/cache/shared/index.ts | 1 - server/middlewares/index.ts | 15 - .../validators/activitypub/index.ts | 3 - server/middlewares/validators/index.ts | 31 - .../middlewares/validators/runners/index.ts | 3 - server/middlewares/validators/shared/index.ts | 14 - server/middlewares/validators/videos/index.ts | 19 - .../validators/videos/shared/index.ts | 2 - server/models/migrations.ts | 27 - server/models/shared/index.ts | 8 - server/models/video/formatter/index.ts | 2 - server/models/video/formatter/shared/index.ts | 1 - server/models/video/sql/video/index.ts | 3 - server/package.json | 12 + .../create-generate-storyboard-job.ts | 10 +- .../scripts}/create-import-video-file-job.ts | 8 +- .../scripts}/create-move-video-storage-job.ts | 14 +- .../scripts}/migrations/peertube-4.0.ts | 22 +- .../scripts}/migrations/peertube-4.2.ts | 31 +- .../scripts}/migrations/peertube-5.0.ts | 16 +- {scripts => server/scripts}/parse-log.ts | 7 +- {scripts => server/scripts}/plugin/install.ts | 4 +- .../scripts}/plugin/uninstall.ts | 4 +- {scripts => server/scripts}/prune-storage.ts | 41 +- .../scripts}/regenerate-thumbnails.ts | 14 +- {scripts => server/scripts}/reset-password.ts | 10 +- {scripts => server/scripts}/update-host.ts | 24 +- {scripts => server/scripts}/upgrade.sh | 0 server.ts => server/server.ts | 144 +-- .../assets/default-audio-background.jpg | Bin .../assets/default-live-background.jpg | Bin .../controllers/activitypub/client.ts | 99 +- .../controllers/activitypub/inbox.ts | 13 +- .../controllers/activitypub/index.ts | 6 +- .../controllers/activitypub/outbox.ts | 26 +- .../controllers/activitypub/utils.ts | 0 server/{ => server}/controllers/api/abuse.ts | 24 +- .../{ => server}/controllers/api/accounts.ts | 34 +- .../{ => server}/controllers/api/blocklist.ts | 16 +- server/{ => server}/controllers/api/bulk.ts | 11 +- server/{ => server}/controllers/api/config.ts | 26 +- .../controllers/api/custom-page.ts | 8 +- server/{ => server}/controllers/api/index.ts | 42 +- server/{ => server}/controllers/api/jobs.ts | 10 +- .../{ => server}/controllers/api/metrics.ts | 8 +- .../controllers/api/oauth-clients.ts | 12 +- .../{ => server}/controllers/api/overviews.ts | 18 +- .../{ => server}/controllers/api/plugins.ts | 16 +- .../controllers/api/runners/index.ts | 8 +- .../controllers/api/runners/jobs-files.ts | 16 +- .../controllers/api/runners/jobs.ts | 24 +- .../controllers/api/runners/manage-runners.ts | 16 +- .../api/runners/registration-tokens.ts | 12 +- .../controllers/api/search/index.ts | 8 +- .../api/search/search-video-channels.ts | 37 +- .../api/search/search-video-playlists.ts | 36 +- .../controllers/api/search/search-videos.ts | 39 +- .../controllers/api/search/shared/index.ts | 1 + .../controllers/api/search/shared/utils.ts | 0 .../controllers/api/server/contact.ts | 11 +- .../controllers/api/server/debug.ts | 18 +- .../controllers/api/server/follows.ts | 28 +- .../controllers/api/server/index.ts | 16 +- .../controllers/api/server/logs.ts | 20 +- .../controllers/api/server/redundancy.ts | 15 +- .../api/server/server-blocklist.ts | 26 +- .../controllers/api/server/stats.ts | 10 +- .../api/users/email-verification.ts | 10 +- .../controllers/api/users/index.ts | 54 +- .../{ => server}/controllers/api/users/me.ts | 48 +- .../controllers/api/users/my-abuses.ts | 4 +- .../controllers/api/users/my-blocklist.ts | 23 +- .../controllers/api/users/my-history.ts | 12 +- .../controllers/api/users/my-notifications.ts | 15 +- .../controllers/api/users/my-subscriptions.ts | 30 +- .../api/users/my-video-playlists.ts | 12 +- .../controllers/api/users/registrations.ts | 22 +- .../controllers/api/users/token.ts | 20 +- .../controllers/api/users/two-factor.ts | 14 +- .../controllers/api/video-channel-sync.ts | 12 +- .../controllers/api/video-channel.ts | 58 +- .../controllers/api/video-playlist.ts | 66 +- .../controllers/api/videos/blacklist.ts | 14 +- .../controllers/api/videos/captions.ts | 26 +- .../controllers/api/videos/comment.ts | 34 +- .../controllers/api/videos/files.ts | 18 +- .../controllers/api/videos/import.ts | 36 +- .../controllers/api/videos/index.ts | 70 +- .../controllers/api/videos/live.ts | 50 +- .../controllers/api/videos/ownership.ts | 23 +- .../controllers/api/videos/passwords.ts | 17 +- .../controllers/api/videos/rate.ts | 16 +- .../controllers/api/videos/source.ts | 36 +- .../controllers/api/videos/stats.ts | 6 +- .../controllers/api/videos/storyboard.ts | 6 +- .../controllers/api/videos/studio.ts | 12 +- .../controllers/api/videos/token.ts | 6 +- .../controllers/api/videos/transcoding.ts | 14 +- .../controllers/api/videos/update.ts | 48 +- .../controllers/api/videos/upload.ts | 54 +- .../controllers/api/videos/view.ts | 18 +- server/{ => server}/controllers/client.ts | 22 +- server/{ => server}/controllers/download.ts | 20 +- .../controllers/feeds/comment-feeds.ts | 14 +- .../{ => server}/controllers/feeds/index.ts | 10 +- .../feeds/shared/common-feed-utils.ts | 18 +- .../server/controllers/feeds/shared/index.ts | 2 + .../feeds/shared/video-feed-utils.ts | 20 +- .../controllers/feeds/video-feeds.ts | 14 +- .../controllers/feeds/video-podcast-feeds.ts | 28 +- server/server/controllers/index.ts | 14 + .../{ => server}/controllers/lazy-static.ts | 10 +- server/{ => server}/controllers/misc.ts | 23 +- .../controllers/object-storage-proxy.ts | 8 +- server/{ => server}/controllers/plugins.ts | 23 +- server/{ => server}/controllers/services.ts | 11 +- .../controllers/shared/m3u8-playlist.ts | 0 server/{ => server}/controllers/sitemap.ts | 20 +- server/{ => server}/controllers/static.ts | 14 +- server/{ => server}/controllers/tracker.ts | 10 +- server/{ => server}/controllers/well-known.ts | 10 +- .../helpers/activity-pub-utils.ts} | 48 +- server/{ => server}/helpers/actors.ts | 2 +- server/{ => server}/helpers/audit-logger.ts | 63 +- server/{ => server}/helpers/captions-utils.ts | 16 +- server/{ => server}/helpers/core-utils.ts | 31 +- .../helpers/custom-jsonld-signature.ts | 11 +- .../helpers/custom-validators/abuses.ts | 16 +- .../helpers/custom-validators/accounts.ts | 4 +- .../custom-validators/activitypub/activity.ts | 22 +- .../custom-validators/activitypub/actor.ts | 20 +- .../activitypub/cache-file.ts | 8 +- .../custom-validators/activitypub/misc.ts | 10 +- .../custom-validators/activitypub/playlist.ts | 12 +- .../activitypub/signature.ts | 4 +- .../activitypub/video-comments.ts | 8 +- .../custom-validators/activitypub/videos.ts | 50 +- .../activitypub/watch-action.ts | 8 +- .../helpers/custom-validators/actor-images.ts | 4 +- .../helpers/custom-validators/bulk.ts | 0 .../helpers/custom-validators/feeds.ts | 2 +- .../helpers/custom-validators/follows.ts | 4 +- .../helpers/custom-validators/jobs.ts | 6 +- .../helpers/custom-validators/logs.ts | 14 +- .../helpers/custom-validators/metrics.ts | 0 .../helpers/custom-validators/misc.ts | 22 +- .../helpers/custom-validators/plugins.ts | 23 +- .../helpers/custom-validators/runners/jobs.ts | 14 +- .../custom-validators/runners/runners.ts | 12 +- .../helpers/custom-validators/search.ts | 8 +- .../helpers/custom-validators/servers.ts | 12 +- .../custom-validators/user-notifications.ts | 8 +- .../custom-validators/user-registration.ts | 8 +- .../helpers/custom-validators/users.ts | 30 +- .../custom-validators/video-blacklist.ts | 8 +- .../custom-validators/video-captions.ts | 10 +- .../custom-validators/video-channel-syncs.ts | 4 +- .../custom-validators/video-channels.ts | 12 +- .../custom-validators/video-comments.ts | 4 +- .../custom-validators/video-imports.ts | 8 +- .../helpers/custom-validators/video-lives.ts | 2 +- .../custom-validators/video-ownership.ts | 6 +- .../custom-validators/video-playlists.ts | 12 +- .../helpers/custom-validators/video-rates.ts | 0 .../custom-validators/video-redundancies.ts | 2 +- .../helpers/custom-validators/video-stats.ts | 2 +- .../helpers/custom-validators/video-studio.ts | 16 +- .../custom-validators/video-transcoding.ts | 2 +- .../helpers/custom-validators/video-view.ts | 2 +- .../helpers/custom-validators/videos.ts | 38 +- .../helpers/custom-validators/webfinger.ts | 6 +- server/{ => server}/helpers/database-utils.ts | 6 +- server/{ => server}/helpers/debounce.ts | 0 server/{ => server}/helpers/decache.ts | 19 +- server/{ => server}/helpers/dns.ts | 4 +- server/{ => server}/helpers/express-utils.ts | 14 +- server/{ => server}/helpers/ffmpeg/codecs.ts | 6 +- .../helpers/ffmpeg/ffmpeg-image.ts | 4 +- .../helpers/ffmpeg/ffmpeg-options.ts | 10 +- .../{ => server}/helpers/ffmpeg/framerate.ts | 5 +- server/server/helpers/ffmpeg/index.ts | 4 + server/{ => server}/helpers/geo-ip.ts | 9 +- server/{ => server}/helpers/image-utils.ts | 23 +- server/{ => server}/helpers/logger.ts | 12 +- server/{ => server}/helpers/markdown.ts | 9 +- server/{ => server}/helpers/memoize.ts | 0 server/server/helpers/mentions.ts | 42 + server/{ => server}/helpers/otp.ts | 6 +- .../{ => server}/helpers/peertube-crypto.ts | 48 +- server/{ => server}/helpers/promise-cache.ts | 0 server/{ => server}/helpers/proxy.ts | 0 server/{ => server}/helpers/query.ts | 4 +- server/{ => server}/helpers/regexp.ts | 0 server/{ => server}/helpers/requests.ts | 48 +- .../{ => server}/helpers/stream-replacer.ts | 0 .../{ => server}/helpers/token-generator.ts | 2 +- server/{ => server}/helpers/upload.ts | 2 +- server/{ => server}/helpers/utils.ts | 12 +- server/{ => server}/helpers/version.ts | 4 +- server/{ => server}/helpers/video.ts | 12 +- server/{ => server}/helpers/webtorrent.ts | 45 +- server/server/helpers/youtube-dl/index.ts | 3 + .../helpers/youtube-dl/youtube-dl-cli.ts | 17 +- .../youtube-dl/youtube-dl-info-builder.ts | 17 +- .../helpers/youtube-dl/youtube-dl-wrapper.ts | 18 +- .../initializers/checker-after-init.ts | 27 +- .../initializers/checker-before-init.ts | 13 +- server/{ => server}/initializers/config.ts | 31 +- server/{ => server}/initializers/constants.ts | 73 +- server/{ => server}/initializers/database.ts | 119 +- server/{ => server}/initializers/installer.ts | 29 +- .../migrations/0505-user-last-login-date.ts | 0 .../migrations/0510-video-file-metadata.ts | 0 .../0515-video-abuse-reason-timestamps.ts | 0 .../migrations/0520-abuses-split.ts | 0 .../migrations/0525-abuse-messages.ts | 0 .../0530-playlist-multiple-video.ts | 2 +- .../migrations/0535-video-live.ts | 0 .../migrations/0540-video-file-infohash.ts | 0 .../migrations/0545-video-live-save-replay.ts | 0 .../migrations/0550-actor-follow-cleanup.ts | 0 .../migrations/0555-actor-follow-url.ts | 0 .../migrations/0560-user-feed-token.ts | 2 +- .../migrations/0565-actor-follow-local-url.ts | 0 .../migrations/0570-permanent-live.ts | 0 .../migrations/0575-duplicate-thumbnail.ts | 0 .../migrations/0580-caption-filename.ts | 0 .../migrations/0585-video-file-names.ts | 0 .../initializers/migrations/0590-trackers.ts | 0 .../migrations/0595-remote-url.ts | 0 .../migrations/0600-duplicate-video-files.ts | 0 .../migrations/0605-actor-missing-keys.ts | 4 +- .../migrations/0610-views-index copy.ts | 0 .../migrations/0612-captions-unique.ts | 0 ...5-latest-versions-notification-settings.ts | 0 .../0620-latest-versions-application.ts | 0 .../0625-latest-versions-notification.ts | 0 .../initializers/migrations/0630-banner.ts | 0 .../migrations/0635-actor-image-size.ts | 0 .../migrations/0640-unique-keys.ts | 0 .../0645-actor-remote-creation-date.ts | 0 .../migrations/0650-actor-custom-pages.ts | 0 .../0655-streaming-playlist-filenames.ts | 0 .../migrations/0660-object-storage.ts | 2 +- .../0665-no-account-warning-modal.ts | 0 .../migrations/0670-pending-job-default.ts | 0 .../migrations/0675-p2p-enabled.ts | 0 .../migrations/0680-files-storage-default.ts | 0 .../migrations/0685-multiple-actor-images.ts | 0 .../migrations/0690-live-latency-mode.ts | 2 +- .../migrations/0695-remove-remote-rates.ts | 0 .../0700-edition-finished-notification.ts | 0 .../migrations/0705-local-video-viewers.ts | 0 .../migrations/0710-live-sessions.ts | 0 .../migrations/0715-video-source.ts | 0 .../0720-session-ending-processed.ts | 0 .../migrations/0725-node-version.ts | 0 .../migrations/0730-video-channel-sync.ts | 0 ...5-video-channel-sync-import-foreign-key.ts | 0 .../migrations/0740-fix-old-enums.ts | 0 .../initializers/migrations/0745-user-otp.ts | 0 .../migrations/0750-user-registration.ts | 0 .../migrations/0755-unique-viewer-url.ts | 0 .../0760-video-live-replay-setting.ts | 0 .../migrations/0765-remote-transcoding.ts | 0 .../0770-actor-preferred-username.ts | 0 .../0775-add-user-is-email-public.ts | 0 .../0780-notification-registration.ts | 0 .../0785-video-password-protection.ts | 0 .../migrations/0790-thumbnail-disk.ts | 0 .../migrations/0795-duplicate-runner-name.ts | 0 .../migrations/0800-video-replace-file.ts | 0 server/{ => server}/initializers/migrator.ts | 13 +- .../{ => server}/lib/activitypub/activity.ts | 8 +- .../lib/activitypub/actors/get.ts | 28 +- .../lib/activitypub/actors/image.ts | 22 +- server/server/lib/activitypub/actors/index.ts | 6 + .../lib/activitypub/actors/keys.ts | 4 +- .../lib/activitypub/actors/refresh.ts | 20 +- .../lib/activitypub/actors/shared/creator.ts | 31 +- .../lib/activitypub/actors/shared/index.ts | 3 + .../shared/object-to-model-attributes.ts | 15 +- .../actors/shared/url-to-object.ts | 10 +- .../lib/activitypub/actors/updater.ts | 20 +- .../lib/activitypub/actors/webfinger.ts | 12 +- .../{ => server}/lib/activitypub/audience.ts | 6 +- .../lib/activitypub/cache-file.ts | 6 +- .../lib/activitypub/collection.ts | 10 +- server/server/lib/activitypub/context.ts | 10 + server/{ => server}/lib/activitypub/crawl.ts | 10 +- server/{ => server}/lib/activitypub/follow.ts | 14 +- .../lib/activitypub/inbox-manager.ts | 12 +- .../lib/activitypub/local-video-viewer.ts | 10 +- server/{ => server}/lib/activitypub/outbox.ts | 8 +- .../activitypub/playlists/create-update.ts | 40 +- .../lib/activitypub/playlists/get.ts | 14 +- .../server/lib/activitypub/playlists/index.ts | 3 + .../lib/activitypub/playlists/refresh.ts | 14 +- .../lib/activitypub/playlists/shared/index.ts | 2 + .../shared/object-to-model-attributes.ts | 12 +- .../playlists/shared/url-to-object.ts | 12 +- .../server/lib/activitypub/process/index.ts | 1 + .../lib/activitypub/process/process-accept.ts | 10 +- .../activitypub/process/process-announce.ts | 22 +- .../lib/activitypub/process/process-create.ts | 34 +- .../lib/activitypub/process/process-delete.ts | 22 +- .../activitypub/process/process-dislike.ts | 16 +- .../lib/activitypub/process/process-flag.ts | 24 +- .../lib/activitypub/process/process-follow.ts | 34 +- .../lib/activitypub/process/process-like.ts | 18 +- .../lib/activitypub/process/process-reject.ts | 10 +- .../lib/activitypub/process/process-undo.ts | 30 +- .../lib/activitypub/process/process-update.ts | 41 +- .../lib/activitypub/process/process-view.ts | 12 +- .../lib/activitypub/process/process.ts | 40 +- .../{ => server}/lib/activitypub/send/http.ts | 43 +- server/server/lib/activitypub/send/index.ts | 10 + .../lib/activitypub/send/send-accept.ts | 12 +- .../lib/activitypub/send/send-announce.ts | 14 +- .../lib/activitypub/send/send-create.ts | 14 +- .../lib/activitypub/send/send-delete.ts | 24 +- .../lib/activitypub/send/send-dislike.ts | 12 +- .../lib/activitypub/send/send-flag.ts | 12 +- .../lib/activitypub/send/send-follow.ts | 8 +- .../lib/activitypub/send/send-like.ts | 12 +- .../lib/activitypub/send/send-reject.ts | 12 +- .../lib/activitypub/send/send-undo.ts | 24 +- .../lib/activitypub/send/send-update.ts | 22 +- .../lib/activitypub/send/send-view.ts | 14 +- .../activitypub/send/shared/audience-utils.ts | 12 +- .../lib/activitypub/send/shared/index.ts | 2 + .../lib/activitypub/send/shared/send-utils.ts | 29 +- server/{ => server}/lib/activitypub/share.ts | 22 +- server/{ => server}/lib/activitypub/url.ts | 10 +- .../lib/activitypub/video-comments.ts | 27 +- .../lib/activitypub/video-rates.ts | 12 +- .../lib/activitypub/videos/federate.ts | 8 +- .../lib/activitypub/videos/get.ts | 18 +- server/server/lib/activitypub/videos/index.ts | 4 + .../lib/activitypub/videos/refresh.ts | 18 +- .../videos/shared/abstract-builder.ts | 32 +- .../lib/activitypub/videos/shared/creator.ts | 18 +- .../lib/activitypub/videos/shared/index.ts | 6 + .../shared/object-to-model-attributes.ts | 39 +- .../lib/activitypub/videos/shared/trackers.ts | 16 +- .../videos/shared/url-to-object.ts | 10 +- .../videos/shared/video-sync-attributes.ts | 38 +- .../lib/activitypub/videos/updater.ts | 28 +- .../lib/actor-follow-health-cache.ts | 4 +- server/{ => server}/lib/actor-image.ts | 2 +- server/{ => server}/lib/auth/external-auth.ts | 21 +- server/{ => server}/lib/auth/oauth-model.ts | 34 +- server/{ => server}/lib/auth/oauth.ts | 27 +- server/{ => server}/lib/auth/tokens-cache.ts | 4 +- server/{ => server}/lib/blocklist.ts | 10 +- server/{ => server}/lib/client-html.ts | 52 +- server/{ => server}/lib/emailer.ts | 29 +- .../lib/emails/abuse-new-message/html.pug | 0 .../lib/emails/abuse-state-change/html.pug | 0 .../lib/emails/account-abuse-new/html.pug | 0 .../{ => server}/lib/emails/common/base.pug | 0 .../lib/emails/common/greetings.pug | 0 .../{ => server}/lib/emails/common/html.pug | 0 .../{ => server}/lib/emails/common/mixins.pug | 0 .../lib/emails/contact-form/html.pug | 0 .../lib/emails/follower-on-channel/html.pug | 0 .../lib/emails/password-create/html.pug | 0 .../lib/emails/password-reset/html.pug | 0 .../lib/emails/peertube-version-new/html.pug | 0 .../lib/emails/plugin-version-new/html.pug | 0 .../lib/emails/user-registered/html.pug | 0 .../html.pug | 0 .../html.pug | 0 .../emails/user-registration-request/html.pug | 0 .../lib/emails/verify-email/html.pug | 0 .../lib/emails/video-abuse-new/html.pug | 0 .../emails/video-auto-blacklist-new/html.pug | 0 .../emails/video-comment-abuse-new/html.pug | 0 .../lib/emails/video-comment-mention/html.pug | 0 .../lib/emails/video-comment-new/html.pug | 0 .../avatar-permanent-file-cache.ts | 10 +- server/server/lib/files-cache/index.ts | 6 + .../shared/abstract-permanent-file-cache.ts | 10 +- .../shared/abstract-simple-file-cache.ts | 4 +- server/server/lib/files-cache/shared/index.ts | 2 + .../video-captions-simple-file-cache.ts | 14 +- .../video-miniature-permanent-file-cache.ts | 12 +- .../video-previews-simple-file-cache.ts | 14 +- .../video-storyboards-simple-file-cache.ts | 10 +- .../video-torrents-simple-file-cache.ts | 16 +- server/{ => server}/lib/hls.ts | 47 +- .../lib/internal-event-emitter.ts | 2 +- .../job-queue/handlers/activitypub-cleaner.ts | 34 +- .../job-queue/handlers/activitypub-follow.ts | 26 +- .../handlers/activitypub-http-broadcast.ts | 13 +- .../handlers/activitypub-http-fetcher.ts | 22 +- .../handlers/activitypub-http-unicast.ts | 13 +- .../handlers/activitypub-refresher.ts | 16 +- .../lib/job-queue/handlers/actor-keys.ts | 8 +- .../handlers/after-video-channel-import.ts | 6 +- .../lib/job-queue/handlers/email.ts | 6 +- .../lib/job-queue/handlers/federate-video.ts | 12 +- .../job-queue/handlers/generate-storyboard.ts | 30 +- .../handlers/manage-video-torrent.ts | 16 +- .../handlers/move-to-object-storage.ts | 26 +- .../lib/job-queue/handlers/notify.ts | 8 +- .../handlers/transcoding-job-builder.ts | 16 +- .../handlers/video-channel-import.ts | 14 +- .../job-queue/handlers/video-file-import.ts | 31 +- .../lib/job-queue/handlers/video-import.ts | 76 +- .../job-queue/handlers/video-live-ending.ts | 47 +- .../job-queue/handlers/video-redundancy.ts | 6 +- .../handlers/video-studio-edition.ts | 30 +- .../job-queue/handlers/video-transcoding.ts | 24 +- .../job-queue/handlers/video-views-stats.ts | 10 +- server/server/lib/job-queue/index.ts | 1 + .../{ => server}/lib/job-queue/job-queue.ts | 67 +- server/server/lib/live/index.ts | 4 + server/{ => server}/lib/live/live-manager.ts | 67 +- .../{ => server}/lib/live/live-quota-store.ts | 0 .../lib/live/live-segment-sha-store.ts | 13 +- server/{ => server}/lib/live/live-utils.ts | 17 +- server/server/lib/live/shared/index.ts | 1 + .../lib/live/shared/muxing-session.ts | 39 +- .../abstract-transcoding-wrapper.ts | 13 +- .../ffmpeg-transcoding-wrapper.ts | 16 +- .../live/shared/transcoding-wrapper/index.ts | 3 + .../remote-transcoding-wrapper.ts | 4 +- server/{ => server}/lib/local-actor.ts | 31 +- .../{ => server}/lib/model-loaders/actor.ts | 7 +- server/server/lib/model-loaders/index.ts | 2 + .../{ => server}/lib/model-loaders/video.ts | 8 +- server/{ => server}/lib/moderation.ts | 35 +- server/server/lib/notifier/index.ts | 1 + server/{ => server}/lib/notifier/notifier.ts | 34 +- .../abuse/abstract-new-abuse-message.ts | 18 +- .../abuse/abuse-state-change-for-reporter.ts | 16 +- .../server/lib/notifier/shared/abuse/index.ts | 4 + .../shared/abuse/new-abuse-for-moderators.ts | 16 +- .../abuse/new-abuse-message-for-moderators.ts | 12 +- .../abuse/new-abuse-message-for-reporter.ts | 10 +- .../lib/notifier/shared/blacklist/index.ts | 3 + .../new-auto-blacklist-for-moderators.ts | 21 +- .../blacklist/new-blacklist-for-owner.ts | 21 +- .../shared/blacklist/unblacklist-for-owner.ts | 16 +- .../shared/comment/comment-mention.ts | 22 +- .../lib/notifier/shared/comment/index.ts | 2 + .../comment/new-comment-for-video-owner.ts | 18 +- .../shared/common/abstract-notification.ts | 6 +- .../lib/notifier/shared/common/index.ts | 1 + .../shared/follow/auto-follow-for-instance.ts | 12 +- .../shared/follow/follow-for-instance.ts | 16 +- .../notifier/shared/follow/follow-for-user.ts | 14 +- .../lib/notifier/shared/follow/index.ts | 3 + server/server/lib/notifier/shared/index.ts | 7 + .../direct-registration-for-moderators.ts | 14 +- .../lib/notifier/shared/instance/index.ts | 4 + .../new-peertube-version-for-admins.ts | 12 +- .../instance/new-plugin-version-for-admins.ts | 14 +- .../registration-request-for-moderators.ts | 12 +- .../abstract-owned-video-publication.ts | 14 +- .../import-finished-for-owner.ts | 14 +- .../shared/video-publication/index.ts | 6 + .../new-video-for-subscribers.ts | 14 +- ...wned-publication-after-auto-unblacklist.ts | 4 +- ...owned-publication-after-schedule-update.ts | 4 +- .../owned-publication-after-transcoding.ts | 2 +- .../studio-edition-finished-for-owner.ts | 14 +- server/server/lib/object-storage/index.ts | 5 + .../{ => server}/lib/object-storage/keys.ts | 2 +- .../lib/object-storage/pre-signed-urls.ts | 22 +- .../{ => server}/lib/object-storage/proxy.ts | 17 +- .../lib/object-storage/shared/client.ts | 78 ++ .../server/lib/object-storage/shared/index.ts | 3 + .../lib/object-storage/shared/logger.ts | 2 +- .../shared/object-storage-helpers.ts | 79 +- .../{ => server}/lib/object-storage/urls.ts | 8 +- .../{ => server}/lib/object-storage/videos.ts | 14 +- .../bittorrent-tracker-observers-builder.ts | 0 .../lib/opentelemetry/metric-helpers/index.ts | 7 + .../job-queue-observers-builder.ts | 2 +- .../metric-helpers/lives-observers-builder.ts | 2 +- .../nodejs-observers-builder.ts | 6 +- .../metric-helpers/playback-metrics.ts | 4 +- .../metric-helpers/stats-observers-builder.ts | 6 +- .../viewers-observers-builder.ts | 4 +- .../{ => server}/lib/opentelemetry/metrics.ts | 10 +- server/server/lib/opentelemetry/tracing.ts | 140 +++ server/{ => server}/lib/paths.ts | 12 +- server/{ => server}/lib/peertube-socket.ts | 16 +- server/{ => server}/lib/plugins/hooks.ts | 6 +- .../lib/plugins/plugin-helpers-builder.ts | 42 +- .../{ => server}/lib/plugins/plugin-index.ts | 16 +- .../lib/plugins/plugin-manager.ts | 59 +- .../lib/plugins/register-helpers.ts | 38 +- .../{ => server}/lib/plugins/theme-utils.ts | 6 +- .../plugins/video-constant-manager-factory.ts | 6 +- server/{ => server}/lib/plugins/yarn.ts | 12 +- server/{ => server}/lib/redis.ts | 16 +- server/{ => server}/lib/redundancy.ts | 16 +- server/server/lib/runners/index.ts | 3 + .../job-handlers/abstract-job-handler.ts | 29 +- .../abstract-vod-transcoding-job-handler.ts | 24 +- .../server/lib/runners/job-handlers/index.ts | 7 + .../live-rtmp-hls-transcoding-job-handler.ts | 24 +- .../job-handlers/runner-job-handlers.ts | 16 +- .../lib/runners/job-handlers/shared/index.ts | 1 + .../job-handlers/shared/vod-helpers.ts | 18 +- .../video-studio-transcoding-job-handler.ts | 39 +- ...vod-audio-merge-transcoding-job-handler.ts | 22 +- .../vod-hls-transcoding-job-handler.ts | 32 +- .../vod-web-video-transcoding-job-handler.ts | 20 +- .../{ => server}/lib/runners/runner-urls.ts | 2 +- server/{ => server}/lib/runners/runner.ts | 14 +- .../lib/schedulers/abstract-scheduler.ts | 2 +- .../lib/schedulers/actor-follow-scheduler.ts | 12 +- .../schedulers/auto-follow-index-instances.ts | 18 +- .../lib/schedulers/geo-ip-update-scheduler.ts | 6 +- .../peertube-version-check-scheduler.ts | 18 +- .../lib/schedulers/plugins-check-scheduler.ts | 18 +- ...ve-dangling-resumable-uploads-scheduler.ts | 8 +- .../remove-old-history-scheduler.ts | 10 +- .../schedulers/remove-old-views-scheduler.ts | 10 +- .../runner-job-watch-dog-scheduler.ts | 12 +- .../lib/schedulers/update-videos-scheduler.ts | 26 +- .../video-channel-sync-latest-scheduler.ts | 14 +- .../video-views-buffer-scheduler.ts | 12 +- .../schedulers/videos-redundancy-scheduler.ts | 34 +- .../schedulers/youtube-dl-update-scheduler.ts | 6 +- server/{ => server}/lib/search.ts | 10 +- .../{ => server}/lib/server-config-manager.ts | 30 +- server/{ => server}/lib/signup.ts | 27 +- server/{ => server}/lib/stat-manager.ts | 24 +- server/{ => server}/lib/sync-channel.ts | 20 +- server/{ => server}/lib/thumbnail.ts | 32 +- server/{ => server}/lib/timeserie.ts | 2 +- .../lib/transcoding/create-transcoding-job.ts | 6 +- .../default-transcoding-profiles.ts | 6 +- .../lib/transcoding/ended-transcoding.ts | 8 +- .../lib/transcoding/hls-transcoding.ts | 38 +- .../lib/transcoding/shared/ffmpeg-builder.ts | 8 +- server/server/lib/transcoding/shared/index.ts | 2 + .../job-builders/abstract-job-builder.ts | 2 +- .../transcoding/shared/job-builders/index.ts | 2 + .../transcoding-job-queue-builder.ts | 30 +- .../transcoding-runner-job-builder.ts | 30 +- .../lib/transcoding/transcoding-priority.ts | 6 +- .../transcoding-quick-transcode.ts | 4 +- .../transcoding/transcoding-resolutions.ts | 8 +- .../lib/transcoding/web-transcoding.ts | 35 +- server/{ => server}/lib/uploadx.ts | 6 +- server/{ => server}/lib/user.ts | 53 +- server/{ => server}/lib/video-blacklist.ts | 25 +- server/{ => server}/lib/video-channel.ts | 14 +- server/{ => server}/lib/video-comment.ts | 19 +- server/{ => server}/lib/video-file.ts | 19 +- server/{ => server}/lib/video-path-manager.ts | 28 +- server/{ => server}/lib/video-playlist.ts | 11 +- server/{ => server}/lib/video-pre-import.ts | 54 +- server/{ => server}/lib/video-privacy.ts | 18 +- server/{ => server}/lib/video-state.ts | 30 +- server/{ => server}/lib/video-studio.ts | 30 +- .../{ => server}/lib/video-tokens-manager.ts | 8 +- server/{ => server}/lib/video-urls.ts | 4 +- server/{ => server}/lib/video.ts | 44 +- server/server/lib/views/shared/index.ts | 3 + .../lib/views/shared/video-viewer-counters.ts | 17 +- .../lib/views/shared/video-viewer-stats.ts | 28 +- .../lib/views/shared/video-views.ts | 14 +- .../lib/views/video-views-manager.ts | 8 +- .../{ => server}/lib/worker/parent-process.ts | 16 +- .../lib/worker/workers/http-broadcast.ts | 16 +- .../lib/worker/workers/image-downloader.ts | 14 +- .../lib/worker/workers/image-processor.ts | 3 + .../{ => server}/middlewares/activitypub.ts | 16 +- server/{ => server}/middlewares/async.ts | 4 +- server/{ => server}/middlewares/auth.ts | 15 +- .../{ => server}/middlewares/cache/cache.ts | 4 +- server/server/middlewares/cache/index.ts | 1 + .../middlewares/cache/shared/api-cache.ts | 15 +- .../server/middlewares/cache/shared/index.ts | 1 + server/{ => server}/middlewares/csp.ts | 2 +- server/{ => server}/middlewares/dnt.ts | 0 server/{ => server}/middlewares/doc.ts | 0 server/{ => server}/middlewares/error.ts | 4 +- server/server/middlewares/index.ts | 15 + server/{ => server}/middlewares/pagination.ts | 4 +- .../{ => server}/middlewares/rate-limiter.ts | 10 +- server/{ => server}/middlewares/robots.ts | 0 server/{ => server}/middlewares/servers.ts | 4 +- server/{ => server}/middlewares/sort.ts | 0 server/{ => server}/middlewares/user-right.ts | 6 +- .../middlewares/validators/abuse.ts | 15 +- .../middlewares/validators/account.ts | 4 +- .../validators/activitypub/activity.ts | 8 +- .../validators/activitypub/index.ts | 3 + .../validators/activitypub/pagination.ts | 4 +- .../validators/activitypub/signature.ts | 8 +- .../middlewares/validators/actor-image.ts | 8 +- .../middlewares/validators/blocklist.ts | 20 +- .../middlewares/validators/bulk.ts | 7 +- .../middlewares/validators/config.ts | 15 +- .../middlewares/validators/express.ts | 0 .../middlewares/validators/feeds.ts | 10 +- .../middlewares/validators/follows.ts | 29 +- server/server/middlewares/validators/index.ts | 32 + .../middlewares/validators/jobs.ts | 6 +- .../middlewares/validators/logs.ts | 16 +- .../middlewares/validators/metrics.ts | 10 +- .../validators/object-storage-proxy.ts | 4 +- .../middlewares/validators/oembed.ts | 15 +- .../middlewares/validators/pagination.ts | 4 +- .../middlewares/validators/plugins.ts | 18 +- .../middlewares/validators/redundancy.ts | 16 +- .../middlewares/validators/runners/index.ts | 3 + .../validators/runners/job-files.ts | 6 +- .../middlewares/validators/runners/jobs.ts | 41 +- .../validators/runners/registration-token.ts | 10 +- .../middlewares/validators/runners/runners.ts | 14 +- .../middlewares/validators/search.ts | 8 +- .../middlewares/validators/server.ts | 16 +- .../middlewares/validators/shared/abuses.ts | 6 +- .../middlewares/validators/shared/accounts.ts | 10 +- .../middlewares/validators/shared/index.ts | 14 + .../validators/shared/user-registrations.ts | 8 +- .../middlewares/validators/shared/users.ts | 10 +- .../middlewares/validators/shared/utils.ts | 4 +- .../validators/shared/video-blacklists.ts | 4 +- .../validators/shared/video-captions.ts | 6 +- .../validators/shared/video-channel-syncs.ts | 4 +- .../validators/shared/video-channels.ts | 6 +- .../validators/shared/video-comments.ts | 8 +- .../validators/shared/video-imports.ts | 4 +- .../validators/shared/video-ownerships.ts | 6 +- .../validators/shared/video-passwords.ts | 8 +- .../validators/shared/video-playlists.ts | 6 +- .../middlewares/validators/shared/videos.ts | 26 +- .../middlewares/validators/sort.ts | 4 +- .../middlewares/validators/static.ts | 16 +- .../middlewares/validators/themes.ts | 10 +- .../middlewares/validators/two-factor.ts | 6 +- .../validators/user-email-verification.ts | 12 +- .../middlewares/validators/user-history.ts | 4 +- .../validators/user-notifications.ts | 6 +- .../validators/user-registrations.ts | 22 +- .../validators/user-subscriptions.ts | 13 +- .../middlewares/validators/users.ts | 22 +- .../middlewares/validators/videos/index.ts | 19 + .../validators/videos/shared/index.ts | 2 + .../validators/videos/shared/upload.ts | 6 +- .../videos/shared/video-validators.ts | 23 +- .../validators/videos/video-blacklist.ts | 8 +- .../validators/videos/video-captions.ts | 10 +- .../validators/videos/video-channel-sync.ts | 12 +- .../validators/videos/video-channels.ts | 21 +- .../validators/videos/video-comments.ts | 18 +- .../validators/videos/video-files.ts | 8 +- .../validators/videos/video-imports.ts | 35 +- .../validators/videos/video-live.ts | 30 +- .../videos/video-ownership-changes.ts | 12 +- .../validators/videos/video-passwords.ts | 8 +- .../validators/videos/video-playlists.ts | 34 +- .../validators/videos/video-rates.ts | 15 +- .../validators/videos/video-shares.ts | 8 +- .../validators/videos/video-source.ts | 20 +- .../validators/videos/video-stats.ts | 10 +- .../validators/videos/video-studio.ts | 18 +- .../validators/videos/video-token.ts | 5 +- .../validators/videos/video-transcoding.ts | 12 +- .../validators/videos/video-view.ts | 12 +- .../middlewares/validators/videos/videos.ts | 40 +- .../middlewares/validators/webfinger.ts | 10 +- .../models/abuse/abuse-message.ts | 18 +- server/{ => server}/models/abuse/abuse.ts | 83 +- .../models/abuse/sql/abuse-query-builder.ts | 10 +- .../{ => server}/models/abuse/video-abuse.ts | 12 +- .../models/abuse/video-comment-abuse.ts | 10 +- .../models/account/account-blocklist.ts | 20 +- .../models/account/account-video-rate.ts | 28 +- server/{ => server}/models/account/account.ts | 54 +- .../models/account/actor-custom-page.ts | 8 +- .../{ => server}/models/actor/actor-follow.ts | 57 +- .../{ => server}/models/actor/actor-image.ts | 27 +- server/{ => server}/models/actor/actor.ts | 60 +- .../instance-list-followers-query-builder.ts | 10 +- .../instance-list-following-query-builder.ts | 10 +- .../shared/actor-follow-table-attributes.ts | 10 +- .../instance-list-follows-query-builder.ts | 8 +- .../models/application/application.ts | 8 +- .../{ => server}/models/oauth/oauth-client.ts | 6 +- .../{ => server}/models/oauth/oauth-token.ts | 26 +- .../models/redundancy/video-redundancy.ts | 42 +- .../{ => server}/models/runner/runner-job.ts | 33 +- .../runner/runner-registration-token.ts | 12 +- server/{ => server}/models/runner/runner.ts | 14 +- server/{ => server}/models/server/plugin.ts | 38 +- .../models/server/server-blocklist.ts | 16 +- server/{ => server}/models/server/server.ts | 16 +- server/{ => server}/models/server/tracker.ts | 12 +- .../models/server/video-tracker.ts | 6 +- .../models/shared/abstract-run-query.ts | 0 server/server/models/shared/index.ts | 8 + .../models/shared/model-builder.ts | 4 +- .../{ => server}/models/shared/model-cache.ts | 2 +- server/{ => server}/models/shared/query.ts | 8 +- .../models/shared/sequelize-helpers.ts | 0 server/{ => server}/models/shared/sort.ts | 0 server/{ => server}/models/shared/sql.ts | 11 +- server/{ => server}/models/shared/update.ts | 0 .../user-notitication-list-query-builder.ts | 8 +- .../models/user/user-notification-setting.ts | 50 +- .../models/user/user-notification.ts | 66 +- .../models/user/user-registration.ts | 32 +- .../models/user/user-video-history.ts | 16 +- server/{ => server}/models/user/user.ts | 94 +- server/server/models/video/formatter/index.ts | 2 + .../models/video/formatter/shared/index.ts | 1 + .../formatter/shared/video-format-utils.ts | 2 +- .../formatter/video-activity-pub-format.ts | 22 +- .../video/formatter/video-api-format.ts | 22 +- .../models/video/schedule-video-update.ts | 16 +- .../video-comment-list-query-builder.ts | 8 +- .../comment/video-comment-table-attributes.ts | 12 +- server/server/models/video/sql/video/index.ts | 3 + .../shared/abstract-video-query-builder.ts | 12 +- .../video/shared/video-file-query-builder.ts | 2 +- .../sql/video/shared/video-model-builder.ts | 43 +- .../video/shared/video-table-attributes.ts | 0 .../video/video-model-get-query-builder.ts | 10 +- .../sql/video/videos-id-list-query-builder.ts | 24 +- .../video/videos-model-list-query-builder.ts | 12 +- .../{ => server}/models/video/storyboard.ts | 18 +- server/{ => server}/models/video/tag.ts | 16 +- server/{ => server}/models/video/thumbnail.ts | 34 +- .../models/video/video-blacklist.ts | 24 +- .../models/video/video-caption.ts | 30 +- .../models/video/video-change-ownership.ts | 20 +- .../models/video/video-channel-sync.ts | 42 +- .../models/video/video-channel.ts | 49 +- .../models/video/video-comment.ts | 81 +- .../{ => server}/models/video/video-file.ts | 60 +- .../{ => server}/models/video/video-import.ts | 30 +- .../models/video/video-job-info.ts | 8 +- .../models/video/video-live-replay-setting.ts | 10 +- .../models/video/video-live-session.ts | 20 +- .../{ => server}/models/video/video-live.ts | 22 +- .../models/video/video-password.ts | 16 +- .../models/video/video-playlist-element.ts | 39 +- .../models/video/video-playlist.ts | 60 +- .../{ => server}/models/video/video-share.ts | 22 +- .../{ => server}/models/video/video-source.ts | 10 +- .../models/video/video-streaming-playlist.ts | 48 +- server/{ => server}/models/video/video-tag.ts | 6 +- server/{ => server}/models/video/video.ts | 244 ++-- .../view/local-video-viewer-watch-section.ts | 8 +- .../models/view/local-video-viewer.ts | 24 +- server/{ => server}/models/view/video-view.ts | 6 +- .../static/dnt-policy/dnt-policy-1.0.txt | 0 .../types/activitypub-processor.model.ts | 4 +- server/{ => server}/types/express-handler.ts | 0 server/{ => server}/types/express.d.ts | 26 +- server/server/types/index.ts | 3 + server/{ => server}/types/lib.d.ts | 0 .../types/models/abuse/abuse-message.ts | 8 +- .../{ => server}/types/models/abuse/abuse.ts | 16 +- server/server/types/models/abuse/index.ts | 2 + .../types/models/account/account-blocklist.ts | 6 +- .../types/models/account/account.ts | 10 +- .../types/models/account/actor-custom-page.ts | 2 +- server/server/types/models/account/index.ts | 3 + .../types/models/actor/actor-follow.ts | 6 +- .../types/models/actor/actor-image.ts | 4 +- .../{ => server}/types/models/actor/actor.ts | 12 +- server/server/types/models/actor/index.ts | 3 + .../types/models/application/application.ts | 2 +- .../server/types/models/application/index.ts | 1 + server/server/types/models/index.ts | 8 + server/server/types/models/oauth/index.ts | 2 + .../types/models/oauth/oauth-client.ts | 2 +- .../types/models/oauth/oauth-token.ts | 6 +- server/server/types/models/runners/index.ts | 3 + .../types/models/runners/runner-job.ts | 6 +- .../runners/runner-registration-token.ts | 2 +- .../types/models/runners/runner.ts | 2 +- server/server/types/models/server/index.ts | 3 + .../types/models/server/plugin.ts | 2 +- .../types/models/server/server-blocklist.ts | 8 +- .../types/models/server/server.ts | 6 +- .../types/models/server/tracker.ts | 2 +- server/server/types/models/user/index.ts | 5 + .../models/user/user-notification-setting.ts | 2 +- .../types/models/user/user-notification.ts | 36 +- .../types/models/user/user-registration.ts | 6 +- .../types/models/user/user-video-history.ts | 2 +- server/{ => server}/types/models/user/user.ts | 14 +- server/server/types/models/video/index.ts | 26 + .../video/local-video-viewer-watch-section.ts | 2 +- .../types/models/video/local-video-viewer.ts | 8 +- .../models/video/schedule-video-update.ts | 2 +- .../types/models/video/storyboard.ts | 6 +- server/server/types/models/video/tag.ts | 3 + .../types/models/video/thumbnail.ts | 6 +- .../types/models/video/video-blacklist.ts | 6 +- .../types/models/video/video-caption.ts | 6 +- .../models/video/video-change-ownership.ts | 8 +- .../types/models/video/video-channel-sync.ts | 6 +- .../types/models/video/video-channels.ts | 10 +- .../types/models/video/video-comment.ts | 8 +- .../types/models/video/video-file.ts | 10 +- .../types/models/video/video-import.ts | 8 +- .../models/video/video-live-replay-setting.ts | 2 +- .../types/models/video/video-live-session.ts | 8 +- .../types/models/video/video-live.ts | 8 +- .../types/models/video/video-password.ts | 2 +- .../models/video/video-playlist-element.ts | 8 +- .../types/models/video/video-playlist.ts | 12 +- .../types/models/video/video-rate.ts | 8 +- .../types/models/video/video-redundancy.ts | 14 +- .../types/models/video/video-share.ts | 8 +- .../types/models/video/video-source.ts | 2 +- .../models/video/video-streaming-playlist.ts | 10 +- .../{ => server}/types/models/video/video.ts | 28 +- server/server/types/plugins/index.ts | 4 + .../types/plugins/plugin-library.model.ts | 2 +- .../plugins/register-server-auth.model.ts | 8 +- .../plugins/register-server-option.model.ts | 14 +- .../register-server-websocket-route.model.ts | 0 server/{ => server}/types/sequelize.ts | 2 +- server/tests/api/activitypub/index.ts | 6 - server/tests/api/check-params/index.ts | 45 - server/tests/api/index.ts | 13 - server/tests/api/live/index.ts | 7 - server/tests/api/moderation/index.ts | 4 - server/tests/api/notifications/index.ts | 6 - server/tests/api/object-storage/index.ts | 4 - server/tests/api/redundancy/index.ts | 3 - server/tests/api/runners/index.ts | 5 - server/tests/api/search/index.ts | 7 - server/tests/api/server/index.ts | 22 - server/tests/api/transcoding/index.ts | 6 - server/tests/api/users/index.ts | 8 - server/tests/api/videos/index.ts | 23 - server/tests/api/views/index.ts | 5 - server/tests/helpers/comment-model.ts | 24 - server/tests/helpers/index.ts | 9 - server/tests/index.ts | 10 - server/tests/lib/index.ts | 1 - server/tests/peertube-runner/index.ts | 4 - server/tests/shared/index.ts | 19 - server/tests/shared/mock-servers/index.ts | 8 - server/tools/README.md | 3 - server/tools/package.json | 11 - server/tools/peertube-auth.ts | 171 --- server/tools/peertube-get-access-token.ts | 34 - server/tools/peertube-import-videos.ts | 351 ------ server/tools/peertube-plugins.ts | 165 --- server/tools/peertube-redundancy.ts | 172 --- server/tools/peertube-upload.ts | 77 -- server/tools/shared/index.ts | 1 - server/tools/tsconfig.json | 12 - server/tsconfig.json | 19 +- server/tsconfig.lib.json | 12 + server/tsconfig.types.json | 11 +- server/types/index.ts | 3 - server/types/models/abuse/index.ts | 2 - server/types/models/account/index.ts | 3 - server/types/models/actor/index.ts | 3 - server/types/models/application/index.ts | 1 - server/types/models/index.ts | 8 - server/types/models/oauth/index.ts | 2 - server/types/models/runners/index.ts | 3 - server/types/models/server/index.ts | 3 - server/types/models/user/index.ts | 5 - server/types/models/video/index.ts | 26 - server/types/models/video/tag.ts | 3 - server/types/plugins/index.ts | 4 - shared/core-utils/abuse/index.ts | 1 - shared/core-utils/common/index.ts | 12 - shared/core-utils/common/path.ts | 48 - shared/core-utils/i18n/index.ts | 1 - shared/core-utils/index.ts | 7 - shared/core-utils/plugins/index.ts | 1 - shared/core-utils/renderer/index.ts | 2 - shared/core-utils/users/index.ts | 1 - shared/core-utils/videos/index.ts | 2 - shared/extra-utils/index.ts | 3 - shared/ffmpeg/index.ts | 9 - shared/ffmpeg/shared/index.ts | 2 - shared/models/activitypub/index.ts | 9 - .../activitypub/objects/activitypub-object.ts | 17 - shared/models/activitypub/objects/index.ts | 9 - shared/models/actors/actor-image.type.ts | 4 - shared/models/actors/index.ts | 6 - shared/models/bulk/index.ts | 1 - shared/models/common/index.ts | 1 - shared/models/custom-markup/index.ts | 1 - shared/models/feeds/feed-format.enum.ts | 5 - shared/models/feeds/index.ts | 1 - shared/models/http/index.ts | 2 - shared/models/index.ts | 19 - shared/models/joinpeertube/index.ts | 1 - shared/models/metrics/index.ts | 1 - .../moderation/abuse/abuse-reason.model.ts | 20 - .../moderation/abuse/abuse-state.model.ts | 5 - .../moderation/abuse/abuse-update.model.ts | 7 - shared/models/moderation/abuse/index.ts | 8 - shared/models/moderation/index.ts | 4 - shared/models/nodeinfo/index.ts | 1 - shared/models/overviews/index.ts | 1 - shared/models/plugins/client/index.ts | 8 - shared/models/plugins/hook-type.enum.ts | 5 - shared/models/plugins/index.ts | 6 - shared/models/plugins/plugin-index/index.ts | 3 - shared/models/plugins/plugin.type.ts | 4 - shared/models/plugins/server/api/index.ts | 3 - shared/models/plugins/server/index.ts | 6 - .../models/plugins/server/managers/index.ts | 9 - .../models/plugins/server/settings/index.ts | 2 - shared/models/redundancy/index.ts | 4 - shared/models/runners/index.ts | 21 - .../models/runners/runner-job-state.model.ts | 11 - shared/models/search/index.ts | 6 - shared/models/server/index.ts | 16 - shared/models/tokens/index.ts | 1 - shared/models/users/index.ts | 16 - shared/models/users/registration/index.ts | 5 - .../user-registration-state.model.ts | 5 - shared/models/users/user-flag.model.ts | 4 - .../users/user-notification-setting.model.ts | 32 - shared/models/users/user-right.enum.ts | 51 - shared/models/users/user-role.ts | 6 - shared/models/videos/blacklist/index.ts | 3 - .../videos/blacklist/video-blacklist.model.ts | 18 - shared/models/videos/caption/index.ts | 2 - .../models/videos/change-ownership/index.ts | 3 - .../video-change-ownership.model.ts | 17 - shared/models/videos/channel-sync/index.ts | 3 - .../video-channel-sync-state.enum.ts | 6 - shared/models/videos/channel/index.ts | 4 - shared/models/videos/comment/index.ts | 2 - shared/models/videos/file/index.ts | 3 - .../videos/file/video-resolution.enum.ts | 11 - shared/models/videos/import/index.ts | 4 - .../videos/import/video-import-state.enum.ts | 8 - shared/models/videos/index.ts | 42 - shared/models/videos/live/index.ts | 8 - .../videos/live/live-video-create.model.ts | 11 - .../videos/live/live-video-error.enum.ts | 9 - .../live/live-video-event-payload.model.ts | 7 - .../live/live-video-latency-mode.enum.ts | 5 - .../videos/live/live-video-update.model.ts | 9 - shared/models/videos/live/live-video.model.ts | 14 - shared/models/videos/playlist/index.ts | 12 - .../playlist/video-playlist-element.model.ts | 19 - .../playlist/video-playlist-privacy.model.ts | 5 - .../playlist/video-playlist-type.model.ts | 4 - .../videos/playlist/video-playlist.model.ts | 34 - .../videos/rate/account-video-rate.model.ts | 7 - shared/models/videos/rate/index.ts | 5 - shared/models/videos/stats/index.ts | 6 - shared/models/videos/studio/index.ts | 1 - shared/models/videos/thumbnail.type.ts | 4 - shared/models/videos/transcoding/index.ts | 3 - shared/models/videos/video-include.enum.ts | 8 - shared/models/videos/video-privacy.enum.ts | 7 - .../videos/video-schedule-update.model.ts | 6 - shared/models/videos/video-state.enum.ts | 11 - shared/models/videos/video-storage.enum.ts | 4 - .../videos/video-streaming-playlist.type.ts | 3 - shared/server-commands/bulk/index.ts | 1 - shared/server-commands/cli/index.ts | 1 - shared/server-commands/custom-pages/index.ts | 1 - shared/server-commands/feeds/index.ts | 1 - shared/server-commands/index.ts | 14 - shared/server-commands/logs/index.ts | 1 - shared/server-commands/moderation/index.ts | 1 - shared/server-commands/overviews/index.ts | 1 - shared/server-commands/requests/index.ts | 1 - shared/server-commands/runners/index.ts | 3 - shared/server-commands/search/index.ts | 1 - shared/server-commands/server/index.ts | 15 - shared/server-commands/shared/index.ts | 1 - shared/server-commands/socket/index.ts | 1 - shared/server-commands/users/index.ts | 10 - shared/server-commands/videos/index.ts | 21 - shared/tsconfig.json | 6 - shared/typescript-utils/index.ts | 1 - support/doc/api/embeds.md | 2 +- support/doc/api/openapi.yaml | 4 +- support/doc/development/lib.md | 2 +- support/doc/development/localization.md | 2 +- support/doc/development/monitoring.md | 4 +- support/doc/development/server.md | 66 +- support/doc/development/tests.md | 15 +- support/doc/plugins/guide.md | 43 +- support/doc/tools.md | 544 ++++----- support/nginx/peertube | 2 +- tsconfig.base.json | 10 +- tsconfig.eslint.json | 32 + tsconfig.json | 20 - yarn.lock | 1072 +++++++++++------ 2196 files changed, 12690 insertions(+), 11574 deletions(-) create mode 100644 .mocharc.cjs create mode 100644 apps/peertube-cli/.npmignore create mode 100644 apps/peertube-cli/README.md create mode 100644 apps/peertube-cli/package.json create mode 100644 apps/peertube-cli/scripts/build.js create mode 100644 apps/peertube-cli/scripts/watch.js create mode 100644 apps/peertube-cli/src/peertube-auth.ts create mode 100644 apps/peertube-cli/src/peertube-get-access-token.ts create mode 100644 apps/peertube-cli/src/peertube-plugins.ts create mode 100644 apps/peertube-cli/src/peertube-redundancy.ts create mode 100644 apps/peertube-cli/src/peertube-upload.ts rename {server/tools => apps/peertube-cli/src}/peertube.ts (60%) rename {server/tools => apps/peertube-cli/src}/shared/cli.ts (50%) create mode 100644 apps/peertube-cli/src/shared/index.ts create mode 100644 apps/peertube-cli/tsconfig.json rename {server/tools => apps/peertube-cli}/yarn.lock (78%) rename {packages => apps}/peertube-runner/.gitignore (100%) create mode 100644 apps/peertube-runner/.npmignore create mode 100644 apps/peertube-runner/README.md rename {packages => apps}/peertube-runner/package.json (86%) create mode 100644 apps/peertube-runner/scripts/build.js rename {packages/peertube-runner => apps/peertube-runner/src}/peertube-runner.ts (93%) create mode 100644 apps/peertube-runner/src/register/index.ts rename {packages/peertube-runner => apps/peertube-runner/src}/register/register.ts (92%) create mode 100644 apps/peertube-runner/src/server/index.ts create mode 100644 apps/peertube-runner/src/server/process/index.ts rename {packages/peertube-runner => apps/peertube-runner/src}/server/process/process.ts (90%) rename {packages/peertube-runner => apps/peertube-runner/src}/server/process/shared/common.ts (84%) create mode 100644 apps/peertube-runner/src/server/process/shared/index.ts rename {packages/peertube-runner => apps/peertube-runner/src}/server/process/shared/process-live.ts (95%) rename {packages/peertube-runner => apps/peertube-runner/src}/server/process/shared/process-studio.ts (92%) rename {packages/peertube-runner => apps/peertube-runner/src}/server/process/shared/process-vod.ts (95%) rename {packages/peertube-runner => apps/peertube-runner/src}/server/process/shared/transcoding-logger.ts (76%) rename {packages/peertube-runner => apps/peertube-runner/src}/server/server.ts (93%) create mode 100644 apps/peertube-runner/src/server/shared/index.ts rename {packages/peertube-runner => apps/peertube-runner/src}/server/shared/supported-job.ts (97%) rename {packages/peertube-runner => apps/peertube-runner/src}/shared/config-manager.ts (94%) rename {packages/peertube-runner => apps/peertube-runner/src}/shared/http.ts (92%) create mode 100644 apps/peertube-runner/src/shared/index.ts create mode 100644 apps/peertube-runner/src/shared/ipc/index.ts rename {packages/peertube-runner => apps/peertube-runner/src}/shared/ipc/ipc-client.ts (95%) rename {packages/peertube-runner => apps/peertube-runner/src}/shared/ipc/ipc-server.ts (87%) create mode 100644 apps/peertube-runner/src/shared/ipc/shared/index.ts rename {packages/peertube-runner => apps/peertube-runner/src}/shared/ipc/shared/ipc-request.model.ts (100%) rename {packages/peertube-runner => apps/peertube-runner/src}/shared/ipc/shared/ipc-response.model.ts (100%) rename {packages/peertube-runner => apps/peertube-runner/src}/shared/logger.ts (77%) create mode 100644 apps/peertube-runner/tsconfig.json rename {packages => apps}/peertube-runner/yarn.lock (100%) create mode 100644 packages/core-utils/package.json rename {shared/core-utils => packages/core-utils/src}/abuse/abuse-predefined-reasons.ts (69%) create mode 100644 packages/core-utils/src/abuse/index.ts rename {shared/core-utils => packages/core-utils/src}/common/array.ts (100%) rename {shared/core-utils => packages/core-utils/src}/common/date.ts (100%) create mode 100644 packages/core-utils/src/common/index.ts rename {shared/core-utils => packages/core-utils/src}/common/number.ts (100%) rename {shared/core-utils => packages/core-utils/src}/common/object.ts (100%) rename {shared/core-utils => packages/core-utils/src}/common/promises.ts (100%) rename {shared/core-utils => packages/core-utils/src}/common/random.ts (100%) rename {shared/core-utils => packages/core-utils/src}/common/regexp.ts (100%) rename {shared/core-utils => packages/core-utils/src}/common/time.ts (100%) rename {shared/core-utils => packages/core-utils/src}/common/url.ts (97%) rename {shared/core-utils => packages/core-utils/src}/common/version.ts (100%) rename {shared/core-utils => packages/core-utils/src}/i18n/i18n.ts (100%) create mode 100644 packages/core-utils/src/i18n/index.ts create mode 100644 packages/core-utils/src/index.ts rename {shared/core-utils => packages/core-utils/src}/plugins/hooks.ts (85%) create mode 100644 packages/core-utils/src/plugins/index.ts rename {shared/core-utils => packages/core-utils/src}/renderer/html.ts (100%) create mode 100644 packages/core-utils/src/renderer/index.ts rename {shared/core-utils => packages/core-utils/src}/renderer/markdown.ts (100%) create mode 100644 packages/core-utils/src/users/index.ts rename {shared/core-utils => packages/core-utils/src}/users/user-role.ts (71%) rename {shared/core-utils => packages/core-utils/src}/videos/bitrate.ts (92%) rename {shared/core-utils => packages/core-utils/src}/videos/common.ts (75%) create mode 100644 packages/core-utils/src/videos/index.ts create mode 100644 packages/core-utils/tsconfig.json create mode 100644 packages/ffmpeg/package.json rename {shared/ffmpeg => packages/ffmpeg/src}/ffmpeg-command-wrapper.ts (96%) rename {shared/ffmpeg => packages/ffmpeg/src}/ffmpeg-default-transcoding-profile.ts (96%) rename {shared/ffmpeg => packages/ffmpeg/src}/ffmpeg-edition.ts (98%) rename {shared/ffmpeg => packages/ffmpeg/src}/ffmpeg-images.ts (96%) rename {shared/ffmpeg => packages/ffmpeg/src}/ffmpeg-live.ts (97%) rename {shared/ffmpeg => packages/ffmpeg/src}/ffmpeg-utils.ts (85%) rename {shared/ffmpeg => packages/ffmpeg/src}/ffmpeg-version.ts (100%) rename {shared/ffmpeg => packages/ffmpeg/src}/ffmpeg-vod.ts (97%) rename {shared/ffmpeg => packages/ffmpeg/src}/ffprobe.ts (96%) create mode 100644 packages/ffmpeg/src/index.ts rename {shared/ffmpeg => packages/ffmpeg/src}/shared/encoder-options.ts (92%) create mode 100644 packages/ffmpeg/src/shared/index.ts rename {shared/ffmpeg => packages/ffmpeg/src}/shared/presets.ts (89%) create mode 100644 packages/ffmpeg/tsconfig.json create mode 100644 packages/models/package.json rename {shared/models => packages/models/src}/activitypub/activity.ts (94%) rename {shared/models => packages/models/src}/activitypub/activitypub-actor.ts (96%) rename {shared/models => packages/models/src}/activitypub/activitypub-collection.ts (80%) rename {shared/models => packages/models/src}/activitypub/activitypub-ordered-collection.ts (100%) rename {shared/models => packages/models/src}/activitypub/activitypub-root.ts (56%) rename {shared/models => packages/models/src}/activitypub/activitypub-signature.ts (100%) rename {shared/models => packages/models/src}/activitypub/context.ts (100%) create mode 100644 packages/models/src/activitypub/index.ts rename {shared/models => packages/models/src}/activitypub/objects/abuse-object.ts (75%) create mode 100644 packages/models/src/activitypub/objects/activitypub-object.ts rename {shared/models => packages/models/src}/activitypub/objects/cache-file-object.ts (90%) rename {shared/models => packages/models/src}/activitypub/objects/common-objects.ts (98%) create mode 100644 packages/models/src/activitypub/objects/index.ts rename {shared/models => packages/models/src}/activitypub/objects/playlist-element-object.ts (100%) rename {shared/models => packages/models/src}/activitypub/objects/playlist-object.ts (96%) rename {shared/models => packages/models/src}/activitypub/objects/video-comment-object.ts (94%) rename {shared/models => packages/models/src}/activitypub/objects/video-object.ts (87%) rename {shared/models => packages/models/src}/activitypub/objects/watch-action-object.ts (100%) rename {shared/models => packages/models/src}/activitypub/webfinger.ts (100%) rename {shared/models => packages/models/src}/actors/account.model.ts (76%) rename {shared/models => packages/models/src}/actors/actor-image.model.ts (100%) create mode 100644 packages/models/src/actors/actor-image.type.ts rename {shared/models => packages/models/src}/actors/actor.model.ts (78%) rename {shared/models => packages/models/src}/actors/custom-page.model.ts (100%) rename {shared/models => packages/models/src}/actors/follow.model.ts (87%) create mode 100644 packages/models/src/actors/index.ts rename {shared/models => packages/models/src}/bulk/bulk-remove-comments-of-body.model.ts (100%) create mode 100644 packages/models/src/bulk/index.ts create mode 100644 packages/models/src/common/index.ts rename {shared/models => packages/models/src}/common/result-list.model.ts (100%) rename {shared/models => packages/models/src}/custom-markup/custom-markup-data.model.ts (100%) create mode 100644 packages/models/src/custom-markup/index.ts create mode 100644 packages/models/src/feeds/feed-format.enum.ts create mode 100644 packages/models/src/feeds/index.ts rename {shared/models => packages/models/src}/http/http-methods.ts (77%) rename shared/models/http/http-error-codes.ts => packages/models/src/http/http-status-codes.ts (91%) create mode 100644 packages/models/src/http/index.ts create mode 100644 packages/models/src/index.ts create mode 100644 packages/models/src/joinpeertube/index.ts rename {shared/models => packages/models/src}/joinpeertube/versions.model.ts (100%) create mode 100644 packages/models/src/metrics/index.ts rename {shared/models => packages/models/src}/metrics/playback-metric-create.model.ts (81%) rename {shared/models => packages/models/src}/moderation/abuse/abuse-create.model.ts (97%) rename {shared/models => packages/models/src}/moderation/abuse/abuse-filter.type.ts (100%) rename {shared/models => packages/models/src}/moderation/abuse/abuse-message.model.ts (69%) create mode 100644 packages/models/src/moderation/abuse/abuse-reason.model.ts create mode 100644 packages/models/src/moderation/abuse/abuse-state.model.ts create mode 100644 packages/models/src/moderation/abuse/abuse-update.model.ts rename {shared/models => packages/models/src}/moderation/abuse/abuse-video-is.type.ts (100%) rename {shared/models => packages/models/src}/moderation/abuse/abuse.model.ts (88%) create mode 100644 packages/models/src/moderation/abuse/index.ts rename {shared/models => packages/models/src}/moderation/account-block.model.ts (70%) rename {shared/models => packages/models/src}/moderation/block-status.model.ts (100%) create mode 100644 packages/models/src/moderation/index.ts rename {shared/models => packages/models/src}/moderation/server-block.model.ts (73%) create mode 100644 packages/models/src/nodeinfo/index.ts rename {shared/models => packages/models/src}/nodeinfo/nodeinfo.model.ts (100%) create mode 100644 packages/models/src/overviews/index.ts rename {shared/models => packages/models/src}/overviews/videos-overview.model.ts (96%) rename {shared/models => packages/models/src}/plugins/client/client-hook.model.ts (100%) create mode 100644 packages/models/src/plugins/client/index.ts rename {shared/models => packages/models/src}/plugins/client/plugin-client-scope.type.ts (100%) rename {shared/models => packages/models/src}/plugins/client/plugin-element-placeholder.type.ts (100%) rename {shared/models => packages/models/src}/plugins/client/plugin-selector-id.type.ts (100%) rename {shared/models => packages/models/src}/plugins/client/register-client-form-field.model.ts (100%) rename {shared/models => packages/models/src}/plugins/client/register-client-hook.model.ts (66%) rename {shared/models => packages/models/src}/plugins/client/register-client-route.model.ts (100%) rename {shared/models => packages/models/src}/plugins/client/register-client-settings-script.model.ts (73%) create mode 100644 packages/models/src/plugins/hook-type.enum.ts create mode 100644 packages/models/src/plugins/index.ts create mode 100644 packages/models/src/plugins/plugin-index/index.ts rename {shared/models => packages/models/src}/plugins/plugin-index/peertube-plugin-index-list.model.ts (63%) rename {shared/models => packages/models/src}/plugins/plugin-index/peertube-plugin-index.model.ts (100%) rename {shared/models => packages/models/src}/plugins/plugin-index/peertube-plugin-latest-version.model.ts (100%) rename {shared/models => packages/models/src}/plugins/plugin-package-json.model.ts (98%) create mode 100644 packages/models/src/plugins/plugin.type.ts create mode 100644 packages/models/src/plugins/server/api/index.ts rename {shared/models => packages/models/src}/plugins/server/api/install-plugin.model.ts (100%) rename {shared/models => packages/models/src}/plugins/server/api/manage-plugin.model.ts (100%) rename {shared/models => packages/models/src}/plugins/server/api/peertube-plugin.model.ts (77%) create mode 100644 packages/models/src/plugins/server/index.ts create mode 100644 packages/models/src/plugins/server/managers/index.ts rename {shared/models => packages/models/src}/plugins/server/managers/plugin-playlist-privacy-manager.model.ts (52%) rename {shared/models => packages/models/src}/plugins/server/managers/plugin-settings-manager.model.ts (100%) rename {shared/models => packages/models/src}/plugins/server/managers/plugin-storage-manager.model.ts (100%) rename {shared/models => packages/models/src}/plugins/server/managers/plugin-transcoding-manager.model.ts (97%) rename {shared/models => packages/models/src}/plugins/server/managers/plugin-video-category-manager.model.ts (98%) rename {shared/models => packages/models/src}/plugins/server/managers/plugin-video-language-manager.model.ts (98%) rename {shared/models => packages/models/src}/plugins/server/managers/plugin-video-licence-manager.model.ts (98%) rename {shared/models => packages/models/src}/plugins/server/managers/plugin-video-privacy-manager.model.ts (61%) rename {shared/models => packages/models/src}/plugins/server/plugin-constant-manager.model.ts (100%) rename {shared/models => packages/models/src}/plugins/server/plugin-translation.model.ts (100%) rename {shared/models => packages/models/src}/plugins/server/register-server-hook.model.ts (66%) rename {shared/models => packages/models/src}/plugins/server/server-hook.model.ts (100%) create mode 100644 packages/models/src/plugins/server/settings/index.ts rename {shared/models => packages/models/src}/plugins/server/settings/public-server.setting.ts (90%) rename {shared/models => packages/models/src}/plugins/server/settings/register-server-setting.model.ts (85%) create mode 100644 packages/models/src/redundancy/index.ts rename {shared/models => packages/models/src}/redundancy/video-redundancies-filters.model.ts (100%) rename {shared/models => packages/models/src}/redundancy/video-redundancy-config-filter.type.ts (100%) rename {shared/models => packages/models/src}/redundancy/video-redundancy.model.ts (100%) rename {shared/models => packages/models/src}/redundancy/videos-redundancy-strategy.model.ts (100%) rename {shared/models => packages/models/src}/runners/abort-runner-job-body.model.ts (100%) rename {shared/models => packages/models/src}/runners/accept-runner-job-body.model.ts (100%) rename {shared/models => packages/models/src}/runners/accept-runner-job-result.model.ts (54%) rename {shared/models => packages/models/src}/runners/error-runner-job-body.model.ts (100%) create mode 100644 packages/models/src/runners/index.ts rename {shared/models => packages/models/src}/runners/list-runner-jobs-query.model.ts (52%) rename {shared/models => packages/models/src}/runners/list-runner-registration-tokens.model.ts (100%) rename {shared/models => packages/models/src}/runners/list-runners-query.model.ts (100%) rename {shared/models => packages/models/src}/runners/register-runner-body.model.ts (100%) rename {shared/models => packages/models/src}/runners/register-runner-result.model.ts (100%) rename {shared/models => packages/models/src}/runners/request-runner-job-body.model.ts (100%) rename {shared/models => packages/models/src}/runners/request-runner-job-result.model.ts (58%) rename {shared/models => packages/models/src}/runners/runner-job-payload.model.ts (96%) rename {shared/models => packages/models/src}/runners/runner-job-private-payload.model.ts (95%) create mode 100644 packages/models/src/runners/runner-job-state.model.ts rename {shared/models => packages/models/src}/runners/runner-job-success-body.model.ts (100%) rename {shared/models => packages/models/src}/runners/runner-job-type.type.ts (100%) rename {shared/models => packages/models/src}/runners/runner-job-update-body.model.ts (100%) rename {shared/models => packages/models/src}/runners/runner-job.model.ts (69%) rename {shared/models => packages/models/src}/runners/runner-registration-token.ts (100%) rename {shared/models => packages/models/src}/runners/runner.model.ts (100%) rename {shared/models => packages/models/src}/runners/unregister-runner-body.model.ts (100%) rename {shared/models => packages/models/src}/search/boolean-both-query.model.ts (100%) create mode 100644 packages/models/src/search/index.ts rename {shared/models => packages/models/src}/search/search-target-query.model.ts (100%) rename {shared/models => packages/models/src}/search/video-channels-search-query.model.ts (82%) rename {shared/models => packages/models/src}/search/video-playlists-search-query.model.ts (83%) rename {shared/models => packages/models/src}/search/videos-common-query.model.ts (71%) rename {shared/models => packages/models/src}/search/videos-search-query.model.ts (79%) rename {shared/models => packages/models/src}/server/about.model.ts (100%) rename {shared/models => packages/models/src}/server/broadcast-message-level.type.ts (100%) rename {shared/models => packages/models/src}/server/client-log-create.model.ts (71%) rename {shared/models => packages/models/src}/server/client-log-level.type.ts (100%) rename {shared/models => packages/models/src}/server/contact-form.model.ts (100%) rename {shared/models => packages/models/src}/server/custom-config.model.ts (98%) rename {shared/models => packages/models/src}/server/debug.model.ts (100%) rename {shared/models => packages/models/src}/server/emailer.model.ts (100%) create mode 100644 packages/models/src/server/index.ts rename {shared/models => packages/models/src}/server/job.model.ts (94%) rename {shared/models => packages/models/src}/server/peertube-problem-document.model.ts (59%) rename {shared/models => packages/models/src}/server/server-config.model.ts (96%) rename {shared/models => packages/models/src}/server/server-debug.model.ts (100%) rename {shared/models => packages/models/src}/server/server-error-code.enum.ts (55%) rename {shared/models => packages/models/src}/server/server-follow-create.model.ts (100%) rename {shared/models => packages/models/src}/server/server-log-level.type.ts (100%) rename {shared/models => packages/models/src}/server/server-stats.model.ts (95%) create mode 100644 packages/models/src/tokens/index.ts rename {shared/models => packages/models/src}/tokens/oauth-client-local.model.ts (100%) create mode 100644 packages/models/src/users/index.ts create mode 100644 packages/models/src/users/registration/index.ts rename {shared/models => packages/models/src}/users/registration/user-register.model.ts (100%) rename {shared/models => packages/models/src}/users/registration/user-registration-request.model.ts (63%) create mode 100644 packages/models/src/users/registration/user-registration-state.model.ts rename {shared/models => packages/models/src}/users/registration/user-registration-update-state.model.ts (100%) rename {shared/models => packages/models/src}/users/registration/user-registration.model.ts (76%) rename {shared/models => packages/models/src}/users/two-factor-enable-result.model.ts (100%) rename {shared/models => packages/models/src}/users/user-create-result.model.ts (100%) rename {shared/models => packages/models/src}/users/user-create.model.ts (50%) create mode 100644 packages/models/src/users/user-flag.model.ts rename {shared/models => packages/models/src}/users/user-login.model.ts (100%) create mode 100644 packages/models/src/users/user-notification-setting.model.ts rename {shared/models => packages/models/src}/users/user-notification.model.ts (57%) rename {shared/models => packages/models/src}/users/user-refresh-token.model.ts (100%) create mode 100644 packages/models/src/users/user-right.enum.ts create mode 100644 packages/models/src/users/user-role.ts rename {shared/models => packages/models/src}/users/user-scoped-token.ts (100%) rename {shared/models => packages/models/src}/users/user-update-me.model.ts (88%) rename {shared/models => packages/models/src}/users/user-update.model.ts (51%) rename {shared/models => packages/models/src}/users/user-video-quota.model.ts (100%) rename {shared/models => packages/models/src}/users/user.model.ts (76%) create mode 100644 packages/models/src/videos/blacklist/index.ts rename {shared/models => packages/models/src}/videos/blacklist/video-blacklist-create.model.ts (100%) rename {shared/models => packages/models/src}/videos/blacklist/video-blacklist-update.model.ts (100%) create mode 100644 packages/models/src/videos/blacklist/video-blacklist.model.ts create mode 100644 packages/models/src/videos/caption/index.ts rename {shared/models => packages/models/src}/videos/caption/video-caption-update.model.ts (100%) rename {shared/models => packages/models/src}/videos/caption/video-caption.model.ts (65%) create mode 100644 packages/models/src/videos/change-ownership/index.ts rename {shared/models => packages/models/src}/videos/change-ownership/video-change-ownership-accept.model.ts (100%) rename {shared/models => packages/models/src}/videos/change-ownership/video-change-ownership-create.model.ts (100%) create mode 100644 packages/models/src/videos/change-ownership/video-change-ownership.model.ts create mode 100644 packages/models/src/videos/channel-sync/index.ts rename {shared/models => packages/models/src}/videos/channel-sync/video-channel-sync-create.model.ts (100%) create mode 100644 packages/models/src/videos/channel-sync/video-channel-sync-state.enum.ts rename {shared/models => packages/models/src}/videos/channel-sync/video-channel-sync.model.ts (52%) create mode 100644 packages/models/src/videos/channel/index.ts rename {shared/models => packages/models/src}/videos/channel/video-channel-create-result.model.ts (100%) rename {shared/models => packages/models/src}/videos/channel/video-channel-create.model.ts (100%) rename {shared/models => packages/models/src}/videos/channel/video-channel-update.model.ts (100%) rename {shared/models => packages/models/src}/videos/channel/video-channel.model.ts (82%) create mode 100644 packages/models/src/videos/comment/index.ts rename {shared/models => packages/models/src}/videos/comment/video-comment-create.model.ts (100%) rename {shared/models => packages/models/src}/videos/comment/video-comment.model.ts (88%) create mode 100644 packages/models/src/videos/file/index.ts rename {shared/models => packages/models/src}/videos/file/video-file-metadata.model.ts (100%) rename {shared/models => packages/models/src}/videos/file/video-file.model.ts (54%) create mode 100644 packages/models/src/videos/file/video-resolution.enum.ts create mode 100644 packages/models/src/videos/import/index.ts rename {shared/models => packages/models/src}/videos/import/video-import-create.model.ts (73%) create mode 100644 packages/models/src/videos/import/video-import-state.enum.ts rename {shared/models => packages/models/src}/videos/import/video-import.model.ts (59%) rename {shared/models => packages/models/src}/videos/import/videos-import-in-channel-create.model.ts (100%) create mode 100644 packages/models/src/videos/index.ts create mode 100644 packages/models/src/videos/live/index.ts create mode 100644 packages/models/src/videos/live/live-video-create.model.ts create mode 100644 packages/models/src/videos/live/live-video-error.enum.ts create mode 100644 packages/models/src/videos/live/live-video-event-payload.model.ts rename {shared/models => packages/models/src}/videos/live/live-video-event.type.ts (100%) create mode 100644 packages/models/src/videos/live/live-video-latency-mode.enum.ts rename {shared/models => packages/models/src}/videos/live/live-video-session.model.ts (52%) create mode 100644 packages/models/src/videos/live/live-video-update.model.ts create mode 100644 packages/models/src/videos/live/live-video.model.ts rename {shared/models => packages/models/src}/videos/nsfw-policy.type.ts (100%) create mode 100644 packages/models/src/videos/playlist/index.ts rename {shared/models => packages/models/src}/videos/playlist/video-exist-in-playlist.model.ts (100%) rename {shared/models => packages/models/src}/videos/playlist/video-playlist-create-result.model.ts (100%) rename {shared/models => packages/models/src}/videos/playlist/video-playlist-create.model.ts (54%) rename {shared/models => packages/models/src}/videos/playlist/video-playlist-element-create-result.model.ts (100%) rename {shared/models => packages/models/src}/videos/playlist/video-playlist-element-create.model.ts (100%) rename {shared/models => packages/models/src}/videos/playlist/video-playlist-element-update.model.ts (100%) create mode 100644 packages/models/src/videos/playlist/video-playlist-element.model.ts create mode 100644 packages/models/src/videos/playlist/video-playlist-privacy.model.ts rename {shared/models => packages/models/src}/videos/playlist/video-playlist-reorder.model.ts (100%) create mode 100644 packages/models/src/videos/playlist/video-playlist-type.model.ts rename {shared/models => packages/models/src}/videos/playlist/video-playlist-update.model.ts (54%) create mode 100644 packages/models/src/videos/playlist/video-playlist.model.ts create mode 100644 packages/models/src/videos/rate/account-video-rate.model.ts create mode 100644 packages/models/src/videos/rate/index.ts rename {shared/models => packages/models/src}/videos/rate/user-video-rate-update.model.ts (53%) rename {shared/models => packages/models/src}/videos/rate/user-video-rate.model.ts (56%) rename {shared/models => packages/models/src}/videos/rate/user-video-rate.type.ts (100%) create mode 100644 packages/models/src/videos/stats/index.ts rename {shared/models => packages/models/src}/videos/stats/video-stats-overall-query.model.ts (100%) rename {shared/models => packages/models/src}/videos/stats/video-stats-overall.model.ts (100%) rename {shared/models => packages/models/src}/videos/stats/video-stats-retention.model.ts (100%) rename {shared/models => packages/models/src}/videos/stats/video-stats-timeserie-metric.type.ts (100%) rename {shared/models => packages/models/src}/videos/stats/video-stats-timeserie-query.model.ts (100%) rename {shared/models => packages/models/src}/videos/stats/video-stats-timeserie.model.ts (100%) rename {shared/models => packages/models/src}/videos/storyboard.model.ts (100%) create mode 100644 packages/models/src/videos/studio/index.ts rename {shared/models => packages/models/src}/videos/studio/video-studio-create-edit.model.ts (100%) create mode 100644 packages/models/src/videos/thumbnail.type.ts create mode 100644 packages/models/src/videos/transcoding/index.ts rename {shared/models => packages/models/src}/videos/transcoding/video-transcoding-create.model.ts (100%) rename {shared/models => packages/models/src}/videos/transcoding/video-transcoding-fps.model.ts (100%) rename {shared/models => packages/models/src}/videos/transcoding/video-transcoding.model.ts (92%) rename {shared/models => packages/models/src}/videos/video-constant.model.ts (100%) rename {shared/models => packages/models/src}/videos/video-create-result.model.ts (100%) rename {shared/models => packages/models/src}/videos/video-create.model.ts (84%) create mode 100644 packages/models/src/videos/video-include.enum.ts rename {shared/models => packages/models/src}/videos/video-password.model.ts (100%) create mode 100644 packages/models/src/videos/video-privacy.enum.ts rename {shared/models => packages/models/src}/videos/video-rate.type.ts (100%) create mode 100644 packages/models/src/videos/video-schedule-update.model.ts rename {shared/models => packages/models/src}/videos/video-sort-field.type.ts (100%) rename shared/models/videos/video-source.ts => packages/models/src/videos/video-source.model.ts (100%) create mode 100644 packages/models/src/videos/video-state.enum.ts create mode 100644 packages/models/src/videos/video-storage.enum.ts rename {shared/models => packages/models/src}/videos/video-streaming-playlist.model.ts (50%) create mode 100644 packages/models/src/videos/video-streaming-playlist.type.ts rename {shared/models => packages/models/src}/videos/video-token.model.ts (100%) rename {shared/models => packages/models/src}/videos/video-update.model.ts (84%) rename {shared/models => packages/models/src}/videos/video-view.model.ts (100%) rename {shared/models => packages/models/src}/videos/video.model.ts (80%) create mode 100644 packages/models/tsconfig.json rename {shared => packages/models}/tsconfig.types.json (51%) create mode 100644 packages/node-utils/package.json rename {shared/extra-utils => packages/node-utils/src}/crypto.ts (100%) rename {shared/core-utils/common => packages/node-utils/src}/env.ts (58%) rename {shared/extra-utils => packages/node-utils/src}/file.ts (78%) create mode 100644 packages/node-utils/src/index.ts create mode 100644 packages/node-utils/src/path.ts rename {shared/extra-utils => packages/node-utils/src}/uuid.ts (89%) create mode 100644 packages/node-utils/tsconfig.json delete mode 100644 packages/peertube-runner/.npmignore delete mode 100644 packages/peertube-runner/README.md delete mode 100644 packages/peertube-runner/register/index.ts delete mode 100644 packages/peertube-runner/server/index.ts delete mode 100644 packages/peertube-runner/server/process/index.ts delete mode 100644 packages/peertube-runner/server/process/shared/index.ts delete mode 100644 packages/peertube-runner/server/shared/index.ts delete mode 100644 packages/peertube-runner/shared/index.ts delete mode 100644 packages/peertube-runner/shared/ipc/index.ts delete mode 100644 packages/peertube-runner/shared/ipc/shared/index.ts delete mode 100644 packages/peertube-runner/tsconfig.json create mode 100644 packages/server-commands/package.json rename {shared/server-commands => packages/server-commands/src}/bulk/bulk-command.ts (83%) create mode 100644 packages/server-commands/src/bulk/index.ts rename {shared/server-commands => packages/server-commands/src}/cli/cli-command.ts (92%) create mode 100644 packages/server-commands/src/cli/index.ts rename {shared/server-commands => packages/server-commands/src}/custom-pages/custom-pages-command.ts (90%) create mode 100644 packages/server-commands/src/custom-pages/index.ts rename {shared/server-commands => packages/server-commands/src}/feeds/feeds-command.ts (93%) create mode 100644 packages/server-commands/src/feeds/index.ts create mode 100644 packages/server-commands/src/index.ts create mode 100644 packages/server-commands/src/logs/index.ts rename {shared/server-commands => packages/server-commands/src}/logs/logs-command.ts (97%) rename {shared/server-commands => packages/server-commands/src}/moderation/abuses-command.ts (95%) create mode 100644 packages/server-commands/src/moderation/index.ts create mode 100644 packages/server-commands/src/overviews/index.ts rename {shared/server-commands => packages/server-commands/src}/overviews/overviews-command.ts (84%) create mode 100644 packages/server-commands/src/requests/index.ts rename {shared/server-commands => packages/server-commands/src}/requests/requests.ts (94%) create mode 100644 packages/server-commands/src/runners/index.ts rename {shared/server-commands => packages/server-commands/src}/runners/runner-jobs-command.ts (91%) rename {shared/server-commands => packages/server-commands/src}/runners/runner-registration-tokens-command.ts (93%) rename {shared/server-commands => packages/server-commands/src}/runners/runners-command.ts (85%) create mode 100644 packages/server-commands/src/search/index.ts rename {shared/server-commands => packages/server-commands/src}/search/search-command.ts (97%) rename {shared/server-commands => packages/server-commands/src}/server/config-command.ts (98%) rename {shared/server-commands => packages/server-commands/src}/server/contact-form-command.ts (86%) rename {shared/server-commands => packages/server-commands/src}/server/debug-command.ts (88%) rename {shared/server-commands => packages/server-commands/src}/server/follows-command.ts (94%) rename {shared/server-commands => packages/server-commands/src}/server/follows.ts (83%) create mode 100644 packages/server-commands/src/server/index.ts rename {shared/server-commands => packages/server-commands/src}/server/jobs-command.ts (95%) rename {shared/server-commands => packages/server-commands/src}/server/jobs.ts (94%) rename {shared/server-commands => packages/server-commands/src}/server/metrics-command.ts (82%) rename {shared/server-commands => packages/server-commands/src}/server/object-storage-command.ts (97%) rename {shared/server-commands => packages/server-commands/src}/server/plugins-command.ts (93%) rename {shared/server-commands => packages/server-commands/src}/server/redundancy-command.ts (96%) rename {shared/server-commands => packages/server-commands/src}/server/server.ts (90%) rename {shared/server-commands => packages/server-commands/src}/server/servers-command.ts (89%) rename {shared/server-commands => packages/server-commands/src}/server/servers.ts (90%) rename {shared/server-commands => packages/server-commands/src}/server/stats-command.ts (86%) rename {shared/server-commands => packages/server-commands/src}/shared/abstract-command.ts (92%) create mode 100644 packages/server-commands/src/shared/index.ts create mode 100644 packages/server-commands/src/socket/index.ts rename {shared/server-commands => packages/server-commands/src}/socket/socket-io-command.ts (98%) rename {shared/server-commands => packages/server-commands/src}/users/accounts-command.ts (96%) rename {shared/server-commands => packages/server-commands/src}/users/accounts.ts (86%) rename {shared/server-commands => packages/server-commands/src}/users/blocklist-command.ts (98%) create mode 100644 packages/server-commands/src/users/index.ts rename {shared/server-commands => packages/server-commands/src}/users/login-command.ts (96%) rename {shared/server-commands => packages/server-commands/src}/users/login.ts (88%) rename {shared/server-commands => packages/server-commands/src}/users/notifications-command.ts (96%) rename {shared/server-commands => packages/server-commands/src}/users/registrations-command.ts (93%) rename {shared/server-commands => packages/server-commands/src}/users/subscriptions-command.ts (94%) rename {shared/server-commands => packages/server-commands/src}/users/two-factor-command.ts (93%) rename {shared/server-commands => packages/server-commands/src}/users/users-command.ts (95%) rename {shared/server-commands => packages/server-commands/src}/videos/blacklist-command.ts (94%) rename {shared/server-commands => packages/server-commands/src}/videos/captions-command.ts (90%) rename {shared/server-commands => packages/server-commands/src}/videos/change-ownership-command.ts (97%) rename {shared/server-commands => packages/server-commands/src}/videos/channel-syncs-command.ts (89%) rename {shared/server-commands => packages/server-commands/src}/videos/channels-command.ts (97%) rename {shared/server-commands => packages/server-commands/src}/videos/channels.ts (93%) rename {shared/server-commands => packages/server-commands/src}/videos/comments-command.ts (95%) rename {shared/server-commands => packages/server-commands/src}/videos/history-command.ts (92%) rename {shared/server-commands => packages/server-commands/src}/videos/imports-command.ts (92%) create mode 100644 packages/server-commands/src/videos/index.ts rename {shared/server-commands => packages/server-commands/src}/videos/live-command.ts (95%) rename {shared/server-commands => packages/server-commands/src}/videos/live.ts (91%) rename {shared/server-commands => packages/server-commands/src}/videos/playlists-command.ts (95%) rename {shared/server-commands => packages/server-commands/src}/videos/services-command.ts (89%) rename {shared/server-commands => packages/server-commands/src}/videos/storyboard-command.ts (84%) rename {shared/server-commands => packages/server-commands/src}/videos/streaming-playlists-command.ts (94%) rename {shared/server-commands => packages/server-commands/src}/videos/video-passwords-command.ts (93%) rename {shared/server-commands => packages/server-commands/src}/videos/video-stats-command.ts (86%) rename {shared/server-commands => packages/server-commands/src}/videos/video-studio-command.ts (94%) rename {shared/server-commands => packages/server-commands/src}/videos/video-token-command.ts (86%) rename {shared/server-commands => packages/server-commands/src}/videos/videos-command.ts (96%) rename {shared/server-commands => packages/server-commands/src}/videos/views-command.ts (93%) create mode 100644 packages/server-commands/tsconfig.json rename {server => packages}/tests/fixtures/60fps_720p_small.mp4 (100%) rename {server => packages}/tests/fixtures/ap-json/mastodon/bad-body-http-signature.json (100%) rename {server => packages}/tests/fixtures/ap-json/mastodon/bad-http-signature.json (100%) rename {server => packages}/tests/fixtures/ap-json/mastodon/bad-public-key.json (100%) rename {server => packages}/tests/fixtures/ap-json/mastodon/create-bad-signature.json (100%) rename {server => packages}/tests/fixtures/ap-json/mastodon/create.json (100%) rename {server => packages}/tests/fixtures/ap-json/mastodon/http-signature.json (100%) rename {server => packages}/tests/fixtures/ap-json/mastodon/public-key.json (100%) rename {server => packages}/tests/fixtures/ap-json/peertube/announce-without-context.json (100%) rename {server => packages}/tests/fixtures/ap-json/peertube/invalid-keys.json (100%) rename {server => packages}/tests/fixtures/ap-json/peertube/keys.json (100%) rename {server => packages}/tests/fixtures/avatar-big.png (100%) rename {server => packages}/tests/fixtures/avatar-resized-120x120.gif (100%) rename {server => packages}/tests/fixtures/avatar-resized-120x120.png (100%) rename {server => packages}/tests/fixtures/avatar-resized-48x48.gif (100%) rename {server => packages}/tests/fixtures/avatar-resized-48x48.png (100%) rename {server => packages}/tests/fixtures/avatar.gif (100%) rename {server => packages}/tests/fixtures/avatar.png (100%) rename {server => packages}/tests/fixtures/avatar2-resized-120x120.png (100%) rename {server => packages}/tests/fixtures/avatar2-resized-48x48.png (100%) rename {server => packages}/tests/fixtures/avatar2.png (100%) rename {server => packages}/tests/fixtures/banner-resized.jpg (100%) rename {server => packages}/tests/fixtures/banner.jpg (100%) rename {server => packages}/tests/fixtures/custom-preview-big.png (100%) rename {server => packages}/tests/fixtures/custom-preview.jpg (100%) rename {server => packages}/tests/fixtures/custom-thumbnail-big.jpg (100%) rename {server => packages}/tests/fixtures/custom-thumbnail.jpg (100%) rename {server => packages}/tests/fixtures/custom-thumbnail.png (100%) rename {server => packages}/tests/fixtures/exif.jpg (100%) rename {server => packages}/tests/fixtures/exif.png (100%) rename {server => packages}/tests/fixtures/live/0-000067.ts (100%) rename {server => packages}/tests/fixtures/live/0-000068.ts (100%) rename {server => packages}/tests/fixtures/live/0-000069.ts (100%) rename {server => packages}/tests/fixtures/live/0-000070.ts (100%) rename {server => packages}/tests/fixtures/live/0.m3u8 (100%) rename {server => packages}/tests/fixtures/live/1-000067.ts (100%) rename {server => packages}/tests/fixtures/live/1-000068.ts (100%) rename {server => packages}/tests/fixtures/live/1-000069.ts (100%) rename {server => packages}/tests/fixtures/live/1-000070.ts (100%) rename {server => packages}/tests/fixtures/live/1.m3u8 (100%) rename {server => packages}/tests/fixtures/live/master.m3u8 (100%) rename {server => packages}/tests/fixtures/low-bitrate.mp4 (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-broken/main.js (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-broken/package.json (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-external-auth-one/main.js (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-external-auth-one/package.json (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-external-auth-three/main.js (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-external-auth-three/package.json (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-external-auth-two/main.js (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-external-auth-two/package.json (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-filter-translations/languages/fr.json (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-filter-translations/languages/it.json (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-filter-translations/main.js (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-filter-translations/package.json (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-five/main.js (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-five/package.json (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-four/main.js (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-four/package.json (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-id-pass-auth-one/main.js (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-id-pass-auth-one/package.json (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-id-pass-auth-three/main.js (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-id-pass-auth-three/package.json (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-id-pass-auth-two/main.js (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-id-pass-auth-two/package.json (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-native/main.js (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-native/package.json (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-podcast-custom-tags/main.js (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-podcast-custom-tags/package.json (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-six/main.js (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-six/package.json (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-transcoding-one/main.js (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-transcoding-one/package.json (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-transcoding-two/main.js (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-transcoding-two/package.json (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-unloading/lib.js (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-unloading/main.js (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-unloading/package.json (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-video-constants/main.js (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-video-constants/package.json (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-websocket/main.js (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test-websocket/package.json (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test/languages/fr.json (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test/main.js (100%) rename {server => packages}/tests/fixtures/peertube-plugin-test/package.json (100%) rename {server => packages}/tests/fixtures/rtmps.cert (100%) rename {server => packages}/tests/fixtures/rtmps.key (100%) rename {server => packages}/tests/fixtures/sample.ogg (100%) rename {server => packages}/tests/fixtures/subtitle-bad.txt (100%) rename {server => packages}/tests/fixtures/subtitle-good.srt (100%) rename {server => packages}/tests/fixtures/subtitle-good1.vtt (100%) rename {server => packages}/tests/fixtures/subtitle-good2.vtt (100%) rename {server => packages}/tests/fixtures/thumbnail-playlist.jpg (100%) rename {server => packages}/tests/fixtures/video-720p.torrent (100%) rename {server => packages}/tests/fixtures/video_import_preview.jpg (100%) rename {server => packages}/tests/fixtures/video_import_preview_yt_dlp.jpg (100%) rename {server => packages}/tests/fixtures/video_import_thumbnail.jpg (100%) rename {server => packages}/tests/fixtures/video_import_thumbnail_yt_dlp.jpg (100%) rename {server => packages}/tests/fixtures/video_short.avi (100%) rename {server => packages}/tests/fixtures/video_short.mkv (100%) rename {server => packages}/tests/fixtures/video_short.mp4 (100%) rename {server => packages}/tests/fixtures/video_short.mp4.jpg (100%) rename {server => packages}/tests/fixtures/video_short.ogv (100%) rename {server => packages}/tests/fixtures/video_short.ogv.jpg (100%) rename {server => packages}/tests/fixtures/video_short.webm (100%) rename {server => packages}/tests/fixtures/video_short.webm.jpg (100%) rename {server => packages}/tests/fixtures/video_short1-preview.webm.jpg (100%) rename {server => packages}/tests/fixtures/video_short1.webm (100%) rename {server => packages}/tests/fixtures/video_short1.webm.jpg (100%) rename {server => packages}/tests/fixtures/video_short2.webm (100%) rename {server => packages}/tests/fixtures/video_short2.webm.jpg (100%) rename {server => packages}/tests/fixtures/video_short3.webm (100%) rename {server => packages}/tests/fixtures/video_short3.webm.jpg (100%) rename {server => packages}/tests/fixtures/video_short_0p.mp4 (100%) rename {server => packages}/tests/fixtures/video_short_144p.m3u8 (100%) rename {server => packages}/tests/fixtures/video_short_144p.mp4 (100%) rename {server => packages}/tests/fixtures/video_short_240p.m3u8 (100%) rename {server => packages}/tests/fixtures/video_short_240p.mp4 (100%) rename {server => packages}/tests/fixtures/video_short_360p.m3u8 (100%) rename {server => packages}/tests/fixtures/video_short_360p.mp4 (100%) rename {server => packages}/tests/fixtures/video_short_480.webm (100%) rename {server => packages}/tests/fixtures/video_short_480p.m3u8 (100%) rename {server => packages}/tests/fixtures/video_short_480p.mp4 (100%) rename {server => packages}/tests/fixtures/video_short_4k.mp4 (100%) rename {server => packages}/tests/fixtures/video_short_720p.m3u8 (100%) rename {server => packages}/tests/fixtures/video_short_720p.mp4 (100%) rename {server => packages}/tests/fixtures/video_short_fake.webm (100%) rename {server => packages}/tests/fixtures/video_short_mp3_256k.mp4 (100%) rename {server => packages}/tests/fixtures/video_short_no_audio.mp4 (100%) rename {server => packages}/tests/fixtures/video_very_long_10p.mp4 (100%) rename {server => packages}/tests/fixtures/video_very_short_240p.mp4 (100%) create mode 100644 packages/tests/package.json rename {server/tests => packages/tests/src}/api/activitypub/cleaner.ts (98%) rename {server/tests => packages/tests/src}/api/activitypub/client.ts (97%) rename {server/tests => packages/tests/src}/api/activitypub/fetch.ts (95%) create mode 100644 packages/tests/src/api/activitypub/index.ts rename {server/tests => packages/tests/src}/api/activitypub/refresher.ts (94%) rename {server/tests => packages/tests/src}/api/activitypub/security.ts (82%) rename {server/tests => packages/tests/src}/api/check-params/abuses.ts (98%) rename {server/tests => packages/tests/src}/api/check-params/accounts.ts (90%) rename {server/tests => packages/tests/src}/api/check-params/blocklist.ts (99%) rename {server/tests => packages/tests/src}/api/check-params/bulk.ts (91%) rename {server/tests => packages/tests/src}/api/check-params/channel-import-videos.ts (96%) rename {server/tests => packages/tests/src}/api/check-params/config.ts (97%) rename {server/tests => packages/tests/src}/api/check-params/contact-form.ts (94%) rename {server/tests => packages/tests/src}/api/check-params/custom-pages.ts (95%) rename {server/tests => packages/tests/src}/api/check-params/debug.ts (88%) rename {server/tests => packages/tests/src}/api/check-params/follows.ts (98%) create mode 100644 packages/tests/src/api/check-params/index.ts rename {server/tests => packages/tests/src}/api/check-params/jobs.ts (95%) rename {server/tests => packages/tests/src}/api/check-params/live.ts (98%) rename {server/tests => packages/tests/src}/api/check-params/logs.ts (95%) rename {server/tests => packages/tests/src}/api/check-params/metrics.ts (95%) rename {server/tests => packages/tests/src}/api/check-params/my-user.ts (97%) rename {server/tests => packages/tests/src}/api/check-params/plugins.ts (98%) rename {server/tests => packages/tests/src}/api/check-params/redundancy.ts (97%) rename {server/tests => packages/tests/src}/api/check-params/registrations.ts (97%) rename {server/tests => packages/tests/src}/api/check-params/runners.ts (99%) rename {server/tests => packages/tests/src}/api/check-params/search.ts (97%) rename {server/tests => packages/tests/src}/api/check-params/services.ts (94%) rename {server/tests => packages/tests/src}/api/check-params/transcoding.ts (97%) rename {server/tests => packages/tests/src}/api/check-params/two-factor.ts (97%) rename {server/tests => packages/tests/src}/api/check-params/upload-quota.ts (96%) rename {server/tests => packages/tests/src}/api/check-params/user-notifications.ts (97%) rename {server/tests => packages/tests/src}/api/check-params/user-subscriptions.ts (98%) rename {server/tests => packages/tests/src}/api/check-params/users-admin.ts (97%) rename {server/tests => packages/tests/src}/api/check-params/users-emails.ts (93%) rename {server/tests => packages/tests/src}/api/check-params/video-blacklist.ts (98%) rename {server/tests => packages/tests/src}/api/check-params/video-captions.ts (98%) rename {server/tests => packages/tests/src}/api/check-params/video-channel-syncs.ts (97%) rename {server/tests => packages/tests/src}/api/check-params/video-channels.ts (97%) rename {server/tests => packages/tests/src}/api/check-params/video-comments.ts (99%) rename {server/tests => packages/tests/src}/api/check-params/video-files.ts (98%) rename {server/tests => packages/tests/src}/api/check-params/video-imports.ts (97%) rename {server/tests => packages/tests/src}/api/check-params/video-passwords.ts (97%) rename {server/tests => packages/tests/src}/api/check-params/video-playlists.ts (99%) rename {server/tests => packages/tests/src}/api/check-params/video-source.ts (97%) rename {server/tests => packages/tests/src}/api/check-params/video-storyboards.ts (92%) rename {server/tests => packages/tests/src}/api/check-params/video-studio.ts (95%) rename {server/tests => packages/tests/src}/api/check-params/video-token.ts (94%) rename {server/tests => packages/tests/src}/api/check-params/videos-common-filters.ts (94%) rename {server/tests => packages/tests/src}/api/check-params/videos-history.ts (97%) rename {server/tests => packages/tests/src}/api/check-params/videos-overviews.ts (95%) rename {server/tests => packages/tests/src}/api/check-params/videos.ts (94%) rename {server/tests => packages/tests/src}/api/check-params/views.ts (98%) create mode 100644 packages/tests/src/api/live/index.ts rename {server/tests => packages/tests/src}/api/live/live-constraints.ts (97%) rename {server/tests => packages/tests/src}/api/live/live-fast-restream.ts (96%) rename {server/tests => packages/tests/src}/api/live/live-permanent.ts (95%) rename {server/tests => packages/tests/src}/api/live/live-rtmps.ts (95%) rename {server/tests => packages/tests/src}/api/live/live-save-replay.ts (96%) rename {server/tests => packages/tests/src}/api/live/live-socket-messages.ts (93%) rename {server/tests => packages/tests/src}/api/live/live.ts (98%) rename {server/tests => packages/tests/src}/api/moderation/abuses.ts (99%) rename {server/tests => packages/tests/src}/api/moderation/blocklist-notification.ts (97%) rename {server/tests => packages/tests/src}/api/moderation/blocklist.ts (99%) create mode 100644 packages/tests/src/api/moderation/index.ts rename {server/tests => packages/tests/src}/api/moderation/video-blacklist.ts (98%) rename {server/tests => packages/tests/src}/api/notifications/admin-notifications.ts (90%) rename {server/tests => packages/tests/src}/api/notifications/comments-notifications.ts (97%) create mode 100644 packages/tests/src/api/notifications/index.ts rename {server/tests => packages/tests/src}/api/notifications/moderation-notifications.ts (97%) rename {server/tests => packages/tests/src}/api/notifications/notifications-api.ts (95%) rename {server/tests => packages/tests/src}/api/notifications/registrations-notifications.ts (87%) rename {server/tests => packages/tests/src}/api/notifications/user-notifications.ts (96%) create mode 100644 packages/tests/src/api/object-storage/index.ts rename {server/tests => packages/tests/src}/api/object-storage/live.ts (95%) rename {server/tests => packages/tests/src}/api/object-storage/video-imports.ts (90%) rename {server/tests => packages/tests/src}/api/object-storage/video-static-file-privacy.ts (98%) rename {server/tests => packages/tests/src}/api/object-storage/videos.ts (94%) create mode 100644 packages/tests/src/api/redundancy/index.ts rename {server/tests => packages/tests/src}/api/redundancy/manage-redundancy.ts (98%) rename {server/tests => packages/tests/src}/api/redundancy/redundancy-constraints.ts (97%) rename {server/tests => packages/tests/src}/api/redundancy/redundancy.ts (98%) create mode 100644 packages/tests/src/api/runners/index.ts rename {server/tests => packages/tests/src}/api/runners/runner-common.ts (98%) rename {server/tests => packages/tests/src}/api/runners/runner-live-transcoding.ts (96%) rename {server/tests => packages/tests/src}/api/runners/runner-socket.ts (97%) rename {server/tests => packages/tests/src}/api/runners/runner-studio-transcoding.ts (93%) rename {server/tests => packages/tests/src}/api/runners/runner-vod-transcoding.ts (98%) create mode 100644 packages/tests/src/api/search/index.ts rename {server/tests => packages/tests/src}/api/search/search-activitypub-video-channels.ts (98%) rename {server/tests => packages/tests/src}/api/search/search-activitypub-video-playlists.ts (97%) rename {server/tests => packages/tests/src}/api/search/search-activitypub-videos.ts (97%) rename {server/tests => packages/tests/src}/api/search/search-channels.ts (97%) rename {server/tests => packages/tests/src}/api/search/search-index.ts (98%) rename {server/tests => packages/tests/src}/api/search/search-playlists.ts (97%) rename {server/tests => packages/tests/src}/api/search/search-videos.ts (99%) rename {server/tests => packages/tests/src}/api/server/auto-follows.ts (96%) rename {server/tests => packages/tests/src}/api/server/bulk.ts (99%) rename {server/tests => packages/tests/src}/api/server/config-defaults.ts (96%) rename {server/tests => packages/tests/src}/api/server/config.ts (99%) rename {server/tests => packages/tests/src}/api/server/contact-form.ts (92%) rename {server/tests => packages/tests/src}/api/server/email.ts (98%) rename {server/tests => packages/tests/src}/api/server/follow-constraints.ts (99%) rename {server/tests => packages/tests/src}/api/server/follows-moderation.ts (98%) rename {server/tests => packages/tests/src}/api/server/follows.ts (98%) rename {server/tests => packages/tests/src}/api/server/handle-down.ts (97%) rename {server/tests => packages/tests/src}/api/server/homepage.ts (95%) create mode 100644 packages/tests/src/api/server/index.ts rename {server/tests => packages/tests/src}/api/server/jobs.ts (95%) rename {server/tests => packages/tests/src}/api/server/logs.ts (98%) rename {server/tests => packages/tests/src}/api/server/no-client.ts (85%) rename {server/tests => packages/tests/src}/api/server/open-telemetry.ts (93%) rename {server/tests => packages/tests/src}/api/server/plugins.ts (97%) rename {server/tests => packages/tests/src}/api/server/proxy.ts (89%) rename {server/tests => packages/tests/src}/api/server/reverse-proxy.ts (96%) rename {server/tests => packages/tests/src}/api/server/services.ts (95%) rename {server/tests => packages/tests/src}/api/server/slow-follows.ts (96%) rename {server/tests => packages/tests/src}/api/server/stats.ts (97%) rename {server/tests => packages/tests/src}/api/server/tracker.ts (95%) rename {server/tests => packages/tests/src}/api/transcoding/audio-only.ts (95%) rename {server/tests => packages/tests/src}/api/transcoding/create-transcoding.ts (95%) rename {server/tests => packages/tests/src}/api/transcoding/hls.ts (91%) create mode 100644 packages/tests/src/api/transcoding/index.ts rename {server/tests => packages/tests/src}/api/transcoding/transcoder.ts (97%) rename {server/tests => packages/tests/src}/api/transcoding/update-while-transcoding.ts (93%) rename {server/tests => packages/tests/src}/api/transcoding/video-studio.ts (95%) create mode 100644 packages/tests/src/api/users/index.ts rename {server/tests => packages/tests/src}/api/users/oauth.ts (95%) rename {server/tests => packages/tests/src}/api/users/registrations.ts (98%) rename {server/tests => packages/tests/src}/api/users/two-factor.ts (95%) rename {server/tests => packages/tests/src}/api/users/user-subscriptions.ts (99%) rename {server/tests => packages/tests/src}/api/users/user-videos.ts (98%) rename {server/tests => packages/tests/src}/api/users/users-email-verification.ts (96%) rename {server/tests => packages/tests/src}/api/users/users-multiple-servers.ts (94%) rename {server/tests => packages/tests/src}/api/users/users.ts (99%) rename {server/tests => packages/tests/src}/api/videos/channel-import-videos.ts (96%) create mode 100644 packages/tests/src/api/videos/index.ts rename {server/tests => packages/tests/src}/api/videos/multiple-servers.ts (98%) rename {server/tests => packages/tests/src}/api/videos/resumable-upload.ts (95%) rename {server/tests => packages/tests/src}/api/videos/single-server.ts (97%) rename {server/tests => packages/tests/src}/api/videos/video-captions.ts (96%) rename {server/tests => packages/tests/src}/api/videos/video-change-ownership.ts (98%) rename {server/tests => packages/tests/src}/api/videos/video-channel-syncs.ts (97%) rename {server/tests => packages/tests/src}/api/videos/video-channels.ts (97%) rename {server/tests => packages/tests/src}/api/videos/video-comments.ts (99%) rename {server/tests => packages/tests/src}/api/videos/video-description.ts (98%) rename {server/tests => packages/tests/src}/api/videos/video-files.ts (98%) rename {server/tests => packages/tests/src}/api/videos/video-imports.ts (97%) rename {server/tests => packages/tests/src}/api/videos/video-nsfw.ts (98%) rename {server/tests => packages/tests/src}/api/videos/video-passwords.ts (96%) rename {server/tests => packages/tests/src}/api/videos/video-playlist-thumbnails.ts (97%) rename {server/tests => packages/tests/src}/api/videos/video-playlists.ts (99%) rename {server/tests => packages/tests/src}/api/videos/video-privacy.ts (97%) rename {server/tests => packages/tests/src}/api/videos/video-schedule-update.ts (94%) rename {server/tests => packages/tests/src}/api/videos/video-source.ts (98%) rename {server/tests => packages/tests/src}/api/videos/video-static-file-privacy.ts (97%) rename {server/tests => packages/tests/src}/api/videos/video-storyboard.ts (95%) rename {server/tests => packages/tests/src}/api/videos/videos-common-filters.ts (96%) rename {server/tests => packages/tests/src}/api/videos/videos-history.ts (96%) rename {server/tests => packages/tests/src}/api/videos/videos-overview.ts (95%) create mode 100644 packages/tests/src/api/views/index.ts rename {server/tests => packages/tests/src}/api/views/video-views-counter.ts (97%) rename {server/tests => packages/tests/src}/api/views/video-views-overall-stats.ts (98%) rename {server/tests => packages/tests/src}/api/views/video-views-retention-stats.ts (94%) rename {server/tests => packages/tests/src}/api/views/video-views-timeserie-stats.ts (98%) rename {server/tests => packages/tests/src}/api/views/videos-views-cleaner.ts (93%) rename {server/tests => packages/tests/src}/cli/create-generate-storyboard-job.ts (93%) rename {server/tests => packages/tests/src}/cli/create-import-video-file-job.ts (92%) rename {server/tests => packages/tests/src}/cli/create-move-video-storage-job.ts (91%) rename {server/tests => packages/tests/src}/cli/index.ts (100%) rename {server/tests => packages/tests/src}/cli/peertube.ts (73%) rename {server/tests => packages/tests/src}/cli/plugins.ts (97%) rename {server/tests => packages/tests/src}/cli/prune-storage.ts (96%) rename {server/tests => packages/tests/src}/cli/regenerate-thumbnails.ts (96%) rename {server/tests => packages/tests/src}/cli/reset-password.ts (90%) rename {server/tests => packages/tests/src}/cli/update-host.ts (96%) rename {server/tests => packages/tests/src}/client.ts (99%) rename {server/tests => packages/tests/src}/external-plugins/akismet.ts (97%) rename {server/tests => packages/tests/src}/external-plugins/auth-ldap.ts (97%) rename {server/tests => packages/tests/src}/external-plugins/auto-block-videos.ts (95%) rename {server/tests => packages/tests/src}/external-plugins/auto-mute.ts (95%) rename {server/tests => packages/tests/src}/external-plugins/index.ts (100%) rename {server/tests => packages/tests/src}/feeds/feeds.ts (99%) rename {server/tests => packages/tests/src}/feeds/index.ts (100%) rename {server/tests => packages/tests/src}/misc-endpoints.ts (96%) rename {server/tests => packages/tests/src}/peertube-runner/client-cli.ts (89%) create mode 100644 packages/tests/src/peertube-runner/index.ts rename {server/tests => packages/tests/src}/peertube-runner/live-transcoding.ts (91%) rename {server/tests => packages/tests/src}/peertube-runner/studio-transcoding.ts (88%) rename {server/tests => packages/tests/src}/peertube-runner/vod-transcoding.ts (94%) rename {server/tests => packages/tests/src}/plugins/action-hooks.ts (99%) rename {server/tests => packages/tests/src}/plugins/external-auth.ts (98%) rename {server/tests => packages/tests/src}/plugins/filter-hooks.ts (99%) rename {server/tests => packages/tests/src}/plugins/html-injection.ts (97%) rename {server/tests => packages/tests/src}/plugins/id-and-pass-auth.ts (97%) rename {server/tests => packages/tests/src}/plugins/index.ts (100%) rename {server/tests => packages/tests/src}/plugins/plugin-helpers.ts (98%) rename {server/tests => packages/tests/src}/plugins/plugin-router.ts (96%) rename {server/tests => packages/tests/src}/plugins/plugin-storage.ts (93%) rename {server/tests => packages/tests/src}/plugins/plugin-transcoding.ts (98%) rename {server/tests => packages/tests/src}/plugins/plugin-unloading.ts (95%) rename {server/tests => packages/tests/src}/plugins/plugin-websocket.ts (92%) rename {server/tests => packages/tests/src}/plugins/translations.ts (92%) rename {server/tests => packages/tests/src}/plugins/video-constants.ts (96%) rename server/tests/api/activitypub/helpers.ts => packages/tests/src/server-helpers/activitypub.ts (62%) rename {server/tests/helpers => packages/tests/src/server-helpers}/core-utils.ts (95%) rename {server/tests/helpers => packages/tests/src/server-helpers}/crypto.ts (89%) rename {server/tests/helpers => packages/tests/src/server-helpers}/dns.ts (86%) rename {server/tests/helpers => packages/tests/src/server-helpers}/image.ts (91%) create mode 100644 packages/tests/src/server-helpers/index.ts rename {server/tests/helpers => packages/tests/src/server-helpers}/markdown.ts (91%) create mode 100644 packages/tests/src/server-helpers/mentions.ts rename {server/tests/helpers => packages/tests/src/server-helpers}/request.ts (81%) rename {server/tests/helpers => packages/tests/src/server-helpers}/validator.ts (90%) rename {server/tests/helpers => packages/tests/src/server-helpers}/version.ts (96%) create mode 100644 packages/tests/src/server-lib/index.ts rename {server/tests/lib => packages/tests/src/server-lib}/video-constant-registry-factory.ts (94%) rename {server/tests => packages/tests/src}/shared/actors.ts (89%) rename {server/tests => packages/tests/src}/shared/captions.ts (89%) rename {server/tests => packages/tests/src}/shared/checks.ts (89%) rename {server/tests => packages/tests/src}/shared/directories.ts (90%) rename {server/tests => packages/tests/src}/shared/generate.ts (86%) rename {server/tests => packages/tests/src}/shared/live.ts (93%) create mode 100644 packages/tests/src/shared/mock-servers/index.ts rename {server/tests => packages/tests/src}/shared/mock-servers/mock-429.ts (99%) rename {server/tests => packages/tests/src}/shared/mock-servers/mock-email.ts (90%) rename {server/tests => packages/tests/src}/shared/mock-servers/mock-http.ts (99%) rename {server/tests => packages/tests/src}/shared/mock-servers/mock-instances-index.ts (99%) rename {server/tests => packages/tests/src}/shared/mock-servers/mock-joinpeertube-versions.ts (93%) rename {server/tests => packages/tests/src}/shared/mock-servers/mock-object-storage.ts (93%) rename {server/tests => packages/tests/src}/shared/mock-servers/mock-plugin-blocklist.ts (99%) rename {server/tests => packages/tests/src}/shared/mock-servers/mock-proxy.ts (89%) rename {server/tests => packages/tests/src}/shared/mock-servers/shared.ts (100%) rename {server/tests => packages/tests/src}/shared/notifications.ts (99%) rename {server/tests => packages/tests/src}/shared/peertube-runner-process.ts (72%) rename {server/tests => packages/tests/src}/shared/plugins.ts (89%) rename {server/tests => packages/tests/src}/shared/requests.ts (74%) rename {server/tests => packages/tests/src}/shared/sql-command.ts (97%) rename {server/tests => packages/tests/src}/shared/streaming-playlists.ts (95%) rename {server/tests => packages/tests/src}/shared/tests.ts (100%) rename {server/tests => packages/tests/src}/shared/tracker.ts (85%) rename {server/tests => packages/tests/src}/shared/video-playlists.ts (80%) rename {server/tests => packages/tests/src}/shared/videos.ts (93%) rename {server/tests => packages/tests/src}/shared/views.ts (90%) rename {server/tests => packages/tests/src}/shared/webtorrent.ts (78%) create mode 100644 packages/tests/tsconfig.json rename packages/{types => types-generator}/README.md (100%) rename packages/{types => types-generator}/generate-package.ts (84%) create mode 100644 packages/types-generator/package.json create mode 100644 packages/types-generator/src/client/index.ts rename packages/{types/src/client/tsconfig.json => types-generator/src/client/tsconfig.types.json} (74%) create mode 100644 packages/types-generator/src/index.ts rename packages/{types => types-generator}/tests/test.ts (86%) create mode 100644 packages/types-generator/tsconfig.dist.json create mode 100644 packages/types-generator/tsconfig.json rename packages/{types/tsconfig.json => types-generator/tsconfig.types.json} (57%) delete mode 100644 packages/types/src/client/index.ts delete mode 100644 packages/types/src/index.ts delete mode 100644 packages/types/tsconfig.dist.json create mode 100644 packages/typescript-utils/package.json create mode 100644 packages/typescript-utils/src/index.ts rename {shared/typescript-utils => packages/typescript-utils/src}/types.ts (100%) create mode 100644 packages/typescript-utils/tsconfig.json create mode 100644 packages/typescript-utils/tsconfig.types.json create mode 100644 scripts/build/peertube-cli.sh create mode 100755 scripts/build/tests.sh delete mode 100755 scripts/dev/cli.sh create mode 100755 scripts/dev/peertube-cli.sh delete mode 100755 scripts/setup/cli.sh delete mode 100644 server/controllers/api/search/shared/index.ts delete mode 100644 server/controllers/feeds/shared/index.ts delete mode 100644 server/controllers/index.ts delete mode 100644 server/helpers/ffmpeg/index.ts delete mode 100644 server/helpers/youtube-dl/index.ts delete mode 100644 server/lib/activitypub/actors/index.ts delete mode 100644 server/lib/activitypub/actors/shared/index.ts delete mode 100644 server/lib/activitypub/playlists/index.ts delete mode 100644 server/lib/activitypub/playlists/shared/index.ts delete mode 100644 server/lib/activitypub/process/index.ts delete mode 100644 server/lib/activitypub/send/index.ts delete mode 100644 server/lib/activitypub/send/shared/index.ts delete mode 100644 server/lib/activitypub/videos/index.ts delete mode 100644 server/lib/activitypub/videos/shared/index.ts delete mode 100644 server/lib/files-cache/index.ts delete mode 100644 server/lib/files-cache/shared/index.ts delete mode 100644 server/lib/job-queue/index.ts delete mode 100644 server/lib/live/index.ts delete mode 100644 server/lib/live/shared/index.ts delete mode 100644 server/lib/live/shared/transcoding-wrapper/index.ts delete mode 100644 server/lib/model-loaders/index.ts delete mode 100644 server/lib/notifier/index.ts delete mode 100644 server/lib/notifier/shared/abuse/index.ts delete mode 100644 server/lib/notifier/shared/blacklist/index.ts delete mode 100644 server/lib/notifier/shared/comment/index.ts delete mode 100644 server/lib/notifier/shared/common/index.ts delete mode 100644 server/lib/notifier/shared/follow/index.ts delete mode 100644 server/lib/notifier/shared/index.ts delete mode 100644 server/lib/notifier/shared/instance/index.ts delete mode 100644 server/lib/notifier/shared/video-publication/index.ts delete mode 100644 server/lib/object-storage/index.ts delete mode 100644 server/lib/object-storage/shared/client.ts delete mode 100644 server/lib/object-storage/shared/index.ts delete mode 100644 server/lib/opentelemetry/metric-helpers/index.ts delete mode 100644 server/lib/opentelemetry/tracing.ts delete mode 100644 server/lib/runners/index.ts delete mode 100644 server/lib/runners/job-handlers/index.ts delete mode 100644 server/lib/runners/job-handlers/shared/index.ts delete mode 100644 server/lib/transcoding/shared/index.ts delete mode 100644 server/lib/transcoding/shared/job-builders/index.ts delete mode 100644 server/lib/views/shared/index.ts delete mode 100644 server/lib/worker/workers/image-processor.ts delete mode 100644 server/middlewares/cache/index.ts delete mode 100644 server/middlewares/cache/shared/index.ts delete mode 100644 server/middlewares/index.ts delete mode 100644 server/middlewares/validators/activitypub/index.ts delete mode 100644 server/middlewares/validators/index.ts delete mode 100644 server/middlewares/validators/runners/index.ts delete mode 100644 server/middlewares/validators/shared/index.ts delete mode 100644 server/middlewares/validators/videos/index.ts delete mode 100644 server/middlewares/validators/videos/shared/index.ts delete mode 100644 server/models/migrations.ts delete mode 100644 server/models/shared/index.ts delete mode 100644 server/models/video/formatter/index.ts delete mode 100644 server/models/video/formatter/shared/index.ts delete mode 100644 server/models/video/sql/video/index.ts create mode 100644 server/package.json rename {scripts => server/scripts}/create-generate-storyboard-job.ts (93%) rename {scripts => server/scripts}/create-import-video-file-job.ts (90%) rename {scripts => server/scripts}/create-move-video-storage-job.ts (90%) rename {scripts => server/scripts}/migrations/peertube-4.0.ts (86%) rename {scripts => server/scripts}/migrations/peertube-4.2.ts (82%) rename {scripts => server/scripts}/migrations/peertube-5.0.ts (81%) rename {scripts => server/scripts}/parse-log.ts (94%) rename {scripts => server/scripts}/plugin/install.ts (98%) rename {scripts => server/scripts}/plugin/uninstall.ts (79%) rename {scripts => server/scripts}/prune-storage.ts (86%) rename {scripts => server/scripts}/regenerate-thumbnails.ts (85%) rename {scripts => server/scripts}/reset-password.ts (79%) rename {scripts => server/scripts}/update-host.ts (84%) rename {scripts => server/scripts}/upgrade.sh (100%) rename server.ts => server/server.ts (84%) rename server/{ => server}/assets/default-audio-background.jpg (100%) rename server/{ => server}/assets/default-live-background.jpg (100%) rename server/{ => server}/controllers/activitypub/client.ts (89%) rename server/{ => server}/controllers/activitypub/inbox.ts (91%) rename server/{ => server}/controllers/activitypub/index.ts (69%) rename server/{ => server}/controllers/activitypub/outbox.ts (80%) rename server/{ => server}/controllers/activitypub/utils.ts (100%) rename server/{ => server}/controllers/api/abuse.ts (93%) rename server/{ => server}/controllers/api/accounts.ts (92%) rename server/{ => server}/controllers/api/blocklist.ts (91%) rename server/{ => server}/controllers/api/bulk.ts (82%) rename server/{ => server}/controllers/api/config.ts (94%) rename server/{ => server}/controllers/api/custom-page.ts (90%) rename server/{ => server}/controllers/api/index.ts (61%) rename server/{ => server}/controllers/api/jobs.ts (92%) rename server/{ => server}/controllers/api/metrics.ts (82%) rename server/{ => server}/controllers/api/oauth-clients.ts (84%) rename server/{ => server}/controllers/api/overviews.ts (90%) rename server/{ => server}/controllers/api/plugins.ts (95%) rename server/{ => server}/controllers/api/runners/index.ts (74%) rename server/{ => server}/controllers/api/runners/jobs-files.ts (92%) rename server/{ => server}/controllers/api/runners/jobs.ts (96%) rename server/{ => server}/controllers/api/runners/manage-runners.ts (90%) rename server/{ => server}/controllers/api/runners/registration-tokens.ts (93%) rename server/{ => server}/controllers/api/search/index.ts (57%) rename server/{ => server}/controllers/api/search/search-video-channels.ts (83%) rename server/{ => server}/controllers/api/search/search-video-playlists.ts (83%) rename server/{ => server}/controllers/api/search/search-videos.ts (83%) create mode 100644 server/server/controllers/api/search/shared/index.ts rename server/{ => server}/controllers/api/search/shared/utils.ts (100%) rename server/{ => server}/controllers/api/server/contact.ts (71%) rename server/{ => server}/controllers/api/server/debug.ts (83%) rename server/{ => server}/controllers/api/server/follows.ts (92%) rename server/{ => server}/controllers/api/server/index.ts (54%) rename server/{ => server}/controllers/api/server/logs.ts (89%) rename server/{ => server}/controllers/api/server/redundancy.ts (89%) rename server/{ => server}/controllers/api/server/server-blocklist.ts (89%) rename server/{ => server}/controllers/api/server/stats.ts (69%) rename server/{ => server}/controllers/api/users/email-verification.ts (90%) rename server/{ => server}/controllers/api/users/index.ts (88%) rename server/{ => server}/controllers/api/users/me.ts (87%) rename server/{ => server}/controllers/api/users/my-abuses.ts (91%) rename server/{ => server}/controllers/api/users/my-blocklist.ts (89%) rename server/{ => server}/controllers/api/users/my-history.ts (89%) rename server/{ => server}/controllers/api/users/my-notifications.ts (90%) rename server/{ => server}/controllers/api/users/my-subscriptions.ts (88%) rename server/{ => server}/controllers/api/users/my-video-playlists.ts (84%) rename server/{ => server}/controllers/api/users/registrations.ts (94%) rename server/{ => server}/controllers/api/users/token.ts (89%) rename server/{ => server}/controllers/api/users/two-factor.ts (87%) rename server/{ => server}/controllers/api/video-channel-sync.ts (88%) rename server/{ => server}/controllers/api/video-channel.ts (92%) rename server/{ => server}/controllers/api/video-playlist.ts (91%) rename server/{ => server}/controllers/api/videos/blacklist.ts (93%) rename server/{ => server}/controllers/api/videos/captions.ts (85%) rename server/{ => server}/controllers/api/videos/comment.ts (90%) rename server/{ => server}/controllers/api/videos/files.ts (89%) rename server/{ => server}/controllers/api/videos/import.ts (90%) rename server/{ => server}/controllers/api/videos/index.ts (79%) rename server/{ => server}/controllers/api/videos/live.ts (87%) rename server/{ => server}/controllers/api/videos/ownership.ts (89%) rename server/{ => server}/controllers/api/videos/passwords.ts (90%) rename server/{ => server}/controllers/api/videos/rate.ts (90%) rename server/{ => server}/controllers/api/videos/source.ts (90%) rename server/{ => server}/controllers/api/videos/stats.ts (94%) rename server/{ => server}/controllers/api/videos/storyboard.ts (89%) rename server/{ => server}/controllers/api/videos/studio.ts (96%) rename server/{ => server}/controllers/api/videos/token.ts (86%) rename server/{ => server}/controllers/api/videos/transcoding.ts (89%) rename server/{ => server}/controllers/api/videos/update.ts (87%) rename server/{ => server}/controllers/api/videos/upload.ts (90%) rename server/{ => server}/controllers/api/videos/view.ts (80%) rename server/{ => server}/controllers/client.ts (92%) rename server/{ => server}/controllers/download.ts (94%) rename server/{ => server}/controllers/feeds/comment-feeds.ts (89%) rename server/{ => server}/controllers/feeds/index.ts (62%) rename server/{ => server}/controllers/feeds/shared/common-feed-utils.ts (90%) create mode 100644 server/server/controllers/feeds/shared/index.ts rename server/{ => server}/controllers/feeds/shared/video-feed-utils.ts (79%) rename server/{ => server}/controllers/feeds/video-feeds.ts (93%) rename server/{ => server}/controllers/feeds/video-podcast-feeds.ts (93%) create mode 100644 server/server/controllers/index.ts rename server/{ => server}/controllers/lazy-static.ts (95%) rename server/{ => server}/controllers/misc.ts (90%) rename server/{ => server}/controllers/object-storage-proxy.ts (95%) rename server/{ => server}/controllers/plugins.ts (89%) rename server/{ => server}/controllers/services.ts (94%) rename server/{ => server}/controllers/shared/m3u8-playlist.ts (100%) rename server/{ => server}/controllers/sitemap.ts (87%) rename server/{ => server}/controllers/static.ts (92%) rename server/{ => server}/controllers/tracker.ts (95%) rename server/{ => server}/controllers/well-known.ts (93%) rename server/{lib/activitypub/context.ts => server/helpers/activity-pub-utils.ts} (78%) rename server/{ => server}/helpers/actors.ts (84%) rename server/{ => server}/helpers/audit-logger.ts (86%) rename server/{ => server}/helpers/captions-utils.ts (78%) rename server/{ => server}/helpers/core-utils.ts (92%) rename server/{ => server}/helpers/custom-jsonld-signature.ts (93%) rename server/{ => server}/helpers/custom-validators/abuses.ts (74%) rename server/{ => server}/helpers/custom-validators/accounts.ts (91%) rename server/{ => server}/helpers/custom-validators/activitypub/activity.ts (88%) rename server/{ => server}/helpers/custom-validators/activitypub/actor.ts (87%) rename server/{ => server}/helpers/custom-validators/activitypub/cache-file.ts (76%) rename server/{ => server}/helpers/custom-validators/activitypub/misc.ts (87%) rename server/{ => server}/helpers/custom-validators/activitypub/playlist.ts (63%) rename server/{ => server}/helpers/custom-validators/activitypub/signature.ts (86%) rename server/{ => server}/helpers/custom-validators/activitypub/video-comments.ts (85%) rename server/{ => server}/helpers/custom-validators/activitypub/videos.ts (84%) rename server/{ => server}/helpers/custom-validators/activitypub/watch-action.ts (85%) rename server/{ => server}/helpers/custom-validators/actor-images.ts (93%) rename server/{ => server}/helpers/custom-validators/bulk.ts (100%) rename server/{ => server}/helpers/custom-validators/feeds.ts (90%) rename server/{ => server}/helpers/custom-validators/follows.ts (87%) rename server/{ => server}/helpers/custom-validators/jobs.ts (75%) rename server/{ => server}/helpers/custom-validators/logs.ts (61%) rename server/{ => server}/helpers/custom-validators/metrics.ts (100%) rename server/{ => server}/helpers/custom-validators/misc.ts (85%) rename server/{ => server}/helpers/custom-validators/plugins.ts (85%) rename server/{ => server}/helpers/custom-validators/runners/jobs.ts (93%) rename server/{ => server}/helpers/custom-validators/runners/runners.ts (57%) rename server/{ => server}/helpers/custom-validators/search.ts (75%) rename server/{ => server}/helpers/custom-validators/servers.ts (68%) rename server/{ => server}/helpers/custom-validators/user-notifications.ts (70%) rename server/{ => server}/helpers/custom-validators/user-registration.ts (67%) rename server/{ => server}/helpers/custom-validators/users.ts (67%) rename server/{ => server}/helpers/custom-validators/video-blacklist.ts (73%) rename server/{ => server}/helpers/custom-validators/video-captions.ts (84%) rename server/{ => server}/helpers/custom-validators/video-channel-syncs.ts (80%) rename server/{ => server}/helpers/custom-validators/video-channels.ts (63%) rename server/{ => server}/helpers/custom-validators/video-comments.ts (76%) rename server/{ => server}/helpers/custom-validators/video-imports.ts (84%) rename server/{ => server}/helpers/custom-validators/video-lives.ts (81%) rename server/{ => server}/helpers/custom-validators/video-ownership.ts (76%) rename server/{ => server}/helpers/custom-validators/video-playlists.ts (60%) rename server/{ => server}/helpers/custom-validators/video-rates.ts (100%) rename server/{ => server}/helpers/custom-validators/video-redundancies.ts (87%) rename server/{ => server}/helpers/custom-validators/video-stats.ts (82%) rename server/{ => server}/helpers/custom-validators/video-studio.ts (80%) rename server/{ => server}/helpers/custom-validators/video-transcoding.ts (89%) rename server/{ => server}/helpers/custom-validators/video-view.ts (85%) rename server/{ => server}/helpers/custom-validators/videos.ts (78%) rename server/{ => server}/helpers/custom-validators/webfinger.ts (85%) rename server/{ => server}/helpers/database-utils.ts (97%) rename server/{ => server}/helpers/debounce.ts (100%) rename server/{ => server}/helpers/decache.ts (69%) rename server/{ => server}/helpers/dns.ts (87%) rename server/{ => server}/helpers/express-utils.ts (92%) rename server/{ => server}/helpers/ffmpeg/codecs.ts (90%) rename server/{ => server}/helpers/ffmpeg/ffmpeg-image.ts (91%) rename server/{ => server}/helpers/ffmpeg/ffmpeg-options.ts (78%) rename server/{ => server}/helpers/ffmpeg/framerate.ts (93%) create mode 100644 server/server/helpers/ffmpeg/index.ts rename server/{ => server}/helpers/geo-ip.ts (87%) rename server/{ => server}/helpers/image-utils.ts (90%) rename server/{ => server}/helpers/logger.ts (95%) rename server/{ => server}/helpers/markdown.ts (91%) rename server/{ => server}/helpers/memoize.ts (100%) create mode 100644 server/server/helpers/mentions.ts rename server/{ => server}/helpers/otp.ts (84%) rename server/{ => server}/helpers/peertube-crypto.ts (83%) rename server/{ => server}/helpers/promise-cache.ts (100%) rename server/{ => server}/helpers/proxy.ts (100%) rename server/{ => server}/helpers/query.ts (94%) rename server/{ => server}/helpers/regexp.ts (100%) rename server/{ => server}/helpers/requests.ts (82%) rename server/{ => server}/helpers/stream-replacer.ts (100%) rename server/{ => server}/helpers/token-generator.ts (84%) rename server/{ => server}/helpers/upload.ts (82%) rename server/{ => server}/helpers/utils.ts (86%) rename server/{ => server}/helpers/version.ts (88%) rename server/{ => server}/helpers/video.ts (78%) rename server/{ => server}/helpers/webtorrent.ts (87%) create mode 100644 server/server/helpers/youtube-dl/index.ts rename server/{ => server}/helpers/youtube-dl/youtube-dl-cli.ts (93%) rename server/{ => server}/helpers/youtube-dl/youtube-dl-info-builder.ts (94%) rename server/{ => server}/helpers/youtube-dl/youtube-dl-wrapper.ts (90%) rename server/{ => server}/initializers/checker-after-init.ts (93%) rename server/{ => server}/initializers/checker-before-init.ts (96%) rename server/{ => server}/initializers/config.ts (97%) rename server/{ => server}/initializers/constants.ts (95%) rename server/{ => server}/initializers/database.ts (75%) rename server/{ => server}/initializers/installer.ts (89%) rename server/{ => server}/initializers/migrations/0505-user-last-login-date.ts (100%) rename server/{ => server}/initializers/migrations/0510-video-file-metadata.ts (100%) rename server/{ => server}/initializers/migrations/0515-video-abuse-reason-timestamps.ts (100%) rename server/{ => server}/initializers/migrations/0520-abuses-split.ts (100%) rename server/{ => server}/initializers/migrations/0525-abuse-messages.ts (100%) rename server/{ => server}/initializers/migrations/0530-playlist-multiple-video.ts (96%) rename server/{ => server}/initializers/migrations/0535-video-live.ts (100%) rename server/{ => server}/initializers/migrations/0540-video-file-infohash.ts (100%) rename server/{ => server}/initializers/migrations/0545-video-live-save-replay.ts (100%) rename server/{ => server}/initializers/migrations/0550-actor-follow-cleanup.ts (100%) rename server/{ => server}/initializers/migrations/0555-actor-follow-url.ts (100%) rename server/{ => server}/initializers/migrations/0560-user-feed-token.ts (95%) rename server/{ => server}/initializers/migrations/0565-actor-follow-local-url.ts (100%) rename server/{ => server}/initializers/migrations/0570-permanent-live.ts (100%) rename server/{ => server}/initializers/migrations/0575-duplicate-thumbnail.ts (100%) rename server/{ => server}/initializers/migrations/0580-caption-filename.ts (100%) rename server/{ => server}/initializers/migrations/0585-video-file-names.ts (100%) rename server/{ => server}/initializers/migrations/0590-trackers.ts (100%) rename server/{ => server}/initializers/migrations/0595-remote-url.ts (100%) rename server/{ => server}/initializers/migrations/0600-duplicate-video-files.ts (100%) rename server/{ => server}/initializers/migrations/0605-actor-missing-keys.ts (93%) rename server/{ => server}/initializers/migrations/0610-views-index copy.ts (100%) rename server/{ => server}/initializers/migrations/0612-captions-unique.ts (100%) rename server/{ => server}/initializers/migrations/0615-latest-versions-notification-settings.ts (100%) rename server/{ => server}/initializers/migrations/0620-latest-versions-application.ts (100%) rename server/{ => server}/initializers/migrations/0625-latest-versions-notification.ts (100%) rename server/{ => server}/initializers/migrations/0630-banner.ts (100%) rename server/{ => server}/initializers/migrations/0635-actor-image-size.ts (100%) rename server/{ => server}/initializers/migrations/0640-unique-keys.ts (100%) rename server/{ => server}/initializers/migrations/0645-actor-remote-creation-date.ts (100%) rename server/{ => server}/initializers/migrations/0650-actor-custom-pages.ts (100%) rename server/{ => server}/initializers/migrations/0655-streaming-playlist-filenames.ts (100%) rename server/{ => server}/initializers/migrations/0660-object-storage.ts (96%) rename server/{ => server}/initializers/migrations/0665-no-account-warning-modal.ts (100%) rename server/{ => server}/initializers/migrations/0670-pending-job-default.ts (100%) rename server/{ => server}/initializers/migrations/0675-p2p-enabled.ts (100%) rename server/{ => server}/initializers/migrations/0680-files-storage-default.ts (100%) rename server/{ => server}/initializers/migrations/0685-multiple-actor-images.ts (100%) rename server/{ => server}/initializers/migrations/0690-live-latency-mode.ts (93%) rename server/{ => server}/initializers/migrations/0695-remove-remote-rates.ts (100%) rename server/{ => server}/initializers/migrations/0700-edition-finished-notification.ts (100%) rename server/{ => server}/initializers/migrations/0705-local-video-viewers.ts (100%) rename server/{ => server}/initializers/migrations/0710-live-sessions.ts (100%) rename server/{ => server}/initializers/migrations/0715-video-source.ts (100%) rename server/{ => server}/initializers/migrations/0720-session-ending-processed.ts (100%) rename server/{ => server}/initializers/migrations/0725-node-version.ts (100%) rename server/{ => server}/initializers/migrations/0730-video-channel-sync.ts (100%) rename server/{ => server}/initializers/migrations/0735-video-channel-sync-import-foreign-key.ts (100%) rename server/{ => server}/initializers/migrations/0740-fix-old-enums.ts (100%) rename server/{ => server}/initializers/migrations/0745-user-otp.ts (100%) rename server/{ => server}/initializers/migrations/0750-user-registration.ts (100%) rename server/{ => server}/initializers/migrations/0755-unique-viewer-url.ts (100%) rename server/{ => server}/initializers/migrations/0760-video-live-replay-setting.ts (100%) rename server/{ => server}/initializers/migrations/0765-remote-transcoding.ts (100%) rename server/{ => server}/initializers/migrations/0770-actor-preferred-username.ts (100%) rename server/{ => server}/initializers/migrations/0775-add-user-is-email-public.ts (100%) rename server/{ => server}/initializers/migrations/0780-notification-registration.ts (100%) rename server/{ => server}/initializers/migrations/0785-video-password-protection.ts (100%) rename server/{ => server}/initializers/migrations/0790-thumbnail-disk.ts (100%) rename server/{ => server}/initializers/migrations/0795-duplicate-runner-name.ts (100%) rename server/{ => server}/initializers/migrations/0800-video-replace-file.ts (100%) rename server/{ => server}/initializers/migrator.ts (86%) rename server/{ => server}/lib/activitypub/activity.ts (91%) rename server/{ => server}/lib/activitypub/actors/get.ts (88%) rename server/{ => server}/lib/activitypub/actors/image.ts (83%) create mode 100644 server/server/lib/activitypub/actors/index.ts rename server/{ => server}/lib/activitypub/actors/keys.ts (86%) rename server/{ => server}/lib/activitypub/actors/refresh.ts (85%) rename server/{ => server}/lib/activitypub/actors/shared/creator.ts (88%) create mode 100644 server/server/lib/activitypub/actors/shared/index.ts rename server/{ => server}/lib/activitypub/actors/shared/object-to-model-attributes.ts (82%) rename server/{ => server}/lib/activitypub/actors/shared/url-to-object.ts (88%) rename server/{ => server}/lib/activitypub/actors/updater.ts (88%) rename server/{ => server}/lib/activitypub/actors/webfinger.ts (86%) rename server/{ => server}/lib/activitypub/audience.ts (77%) rename server/{ => server}/lib/activitypub/cache-file.ts (95%) rename server/{ => server}/lib/activitypub/collection.ts (82%) create mode 100644 server/server/lib/activitypub/context.ts rename server/{ => server}/lib/activitypub/crawl.ts (89%) rename server/{ => server}/lib/activitypub/follow.ts (77%) rename server/{ => server}/lib/activitypub/inbox-manager.ts (83%) rename server/{ => server}/lib/activitypub/local-video-viewer.ts (83%) rename server/{ => server}/lib/activitypub/outbox.ts (76%) rename server/{ => server}/lib/activitypub/playlists/create-update.ts (87%) rename server/{ => server}/lib/activitypub/playlists/get.ts (73%) create mode 100644 server/server/lib/activitypub/playlists/index.ts rename server/{ => server}/lib/activitypub/playlists/refresh.ts (82%) create mode 100644 server/server/lib/activitypub/playlists/shared/index.ts rename server/{ => server}/lib/activitypub/playlists/shared/object-to-model-attributes.ts (85%) rename server/{ => server}/lib/activitypub/playlists/shared/url-to-object.ts (84%) create mode 100644 server/server/lib/activitypub/process/index.ts rename server/{ => server}/lib/activitypub/process/process-accept.ts (87%) rename server/{ => server}/lib/activitypub/process/process-announce.ts (85%) rename server/{ => server}/lib/activitypub/process/process-create.ts (88%) rename server/{ => server}/lib/activitypub/process/process-delete.ts (94%) rename server/{ => server}/lib/activitypub/process/process-dislike.ts (88%) rename server/{ => server}/lib/activitypub/process/process-flag.ts (85%) rename server/{ => server}/lib/activitypub/process/process-follow.ts (88%) rename server/{ => server}/lib/activitypub/process/process-like.ts (85%) rename server/{ => server}/lib/activitypub/process/process-reject.ts (87%) rename server/{ => server}/lib/activitypub/process/process-undo.ts (93%) rename server/{ => server}/lib/activitypub/process/process-update.ts (80%) rename server/{ => server}/lib/activitypub/process/process-view.ts (84%) rename server/{ => server}/lib/activitypub/process/process.ts (69%) rename server/{ => server}/lib/activitypub/send/http.ts (54%) create mode 100644 server/server/lib/activitypub/send/index.ts rename server/{ => server}/lib/activitypub/send/send-accept.ts (78%) rename server/{ => server}/lib/activitypub/send/send-announce.ts (79%) rename server/{ => server}/lib/activitypub/send/send-create.ts (97%) rename server/{ => server}/lib/activitypub/send/send-delete.ts (90%) rename server/{ => server}/lib/activitypub/send/send-dislike.ts (78%) rename server/{ => server}/lib/activitypub/send/send-flag.ts (79%) rename server/{ => server}/lib/activitypub/send/send-follow.ts (84%) rename server/{ => server}/lib/activitypub/send/send-like.ts (73%) rename server/{ => server}/lib/activitypub/send/send-reject.ts (73%) rename server/{ => server}/lib/activitypub/send/send-undo.ts (88%) rename server/{ => server}/lib/activitypub/send/send-update.ts (90%) rename server/{ => server}/lib/activitypub/send/send-view.ts (81%) rename server/{ => server}/lib/activitypub/send/shared/audience-utils.ts (86%) create mode 100644 server/server/lib/activitypub/send/shared/index.ts rename server/{ => server}/lib/activitypub/send/shared/send-utils.ts (94%) rename server/{ => server}/lib/activitypub/share.ts (87%) rename server/{ => server}/lib/activitypub/url.ts (97%) rename server/{ => server}/lib/activitypub/video-comments.ts (91%) rename server/{ => server}/lib/activitypub/video-rates.ts (81%) rename server/{ => server}/lib/activitypub/videos/federate.ts (77%) rename server/{ => server}/lib/activitypub/videos/get.ts (90%) create mode 100644 server/server/lib/activitypub/videos/index.ts rename server/{ => server}/lib/activitypub/videos/refresh.ts (84%) rename server/{ => server}/lib/activitypub/videos/shared/abstract-builder.ts (90%) rename server/{ => server}/lib/activitypub/videos/shared/creator.ts (88%) create mode 100644 server/server/lib/activitypub/videos/shared/index.ts rename server/{ => server}/lib/activitypub/videos/shared/object-to-model-attributes.ts (91%) rename server/{ => server}/lib/activitypub/videos/shared/trackers.ts (65%) rename server/{ => server}/lib/activitypub/videos/shared/url-to-object.ts (78%) rename server/{ => server}/lib/activitypub/videos/shared/video-sync-attributes.ts (81%) rename server/{ => server}/lib/activitypub/videos/updater.ts (91%) rename server/{ => server}/lib/actor-follow-health-cache.ts (95%) rename server/{ => server}/lib/actor-image.ts (86%) rename server/{ => server}/lib/auth/external-auth.ts (94%) rename server/{ => server}/lib/auth/oauth-model.ts (92%) rename server/{ => server}/lib/auth/oauth.ts (90%) rename server/{ => server}/lib/auth/tokens-cache.ts (91%) rename server/{ => server}/lib/blocklist.ts (95%) rename server/{ => server}/lib/client-html.ts (93%) rename server/{ => server}/lib/emailer.ts (90%) rename server/{ => server}/lib/emails/abuse-new-message/html.pug (100%) rename server/{ => server}/lib/emails/abuse-state-change/html.pug (100%) rename server/{ => server}/lib/emails/account-abuse-new/html.pug (100%) rename server/{ => server}/lib/emails/common/base.pug (100%) rename server/{ => server}/lib/emails/common/greetings.pug (100%) rename server/{ => server}/lib/emails/common/html.pug (100%) rename server/{ => server}/lib/emails/common/mixins.pug (100%) rename server/{ => server}/lib/emails/contact-form/html.pug (100%) rename server/{ => server}/lib/emails/follower-on-channel/html.pug (100%) rename server/{ => server}/lib/emails/password-create/html.pug (100%) rename server/{ => server}/lib/emails/password-reset/html.pug (100%) rename server/{ => server}/lib/emails/peertube-version-new/html.pug (100%) rename server/{ => server}/lib/emails/plugin-version-new/html.pug (100%) rename server/{ => server}/lib/emails/user-registered/html.pug (100%) rename server/{ => server}/lib/emails/user-registration-request-accepted/html.pug (100%) rename server/{ => server}/lib/emails/user-registration-request-rejected/html.pug (100%) rename server/{ => server}/lib/emails/user-registration-request/html.pug (100%) rename server/{ => server}/lib/emails/verify-email/html.pug (100%) rename server/{ => server}/lib/emails/video-abuse-new/html.pug (100%) rename server/{ => server}/lib/emails/video-auto-blacklist-new/html.pug (100%) rename server/{ => server}/lib/emails/video-comment-abuse-new/html.pug (100%) rename server/{ => server}/lib/emails/video-comment-mention/html.pug (100%) rename server/{ => server}/lib/emails/video-comment-new/html.pug (100%) rename server/{ => server}/lib/files-cache/avatar-permanent-file-cache.ts (77%) create mode 100644 server/server/lib/files-cache/index.ts rename server/{ => server}/lib/files-cache/shared/abstract-permanent-file-cache.ts (94%) rename server/{ => server}/lib/files-cache/shared/abstract-simple-file-cache.ts (91%) create mode 100644 server/server/lib/files-cache/shared/index.ts rename server/{ => server}/lib/files-cache/video-captions-simple-file-cache.ts (87%) rename server/{ => server}/lib/files-cache/video-miniature-permanent-file-cache.ts (58%) rename server/{ => server}/lib/files-cache/video-previews-simple-file-cache.ts (82%) rename server/{ => server}/lib/files-cache/video-storyboards-simple-file-cache.ts (91%) rename server/{ => server}/lib/files-cache/video-torrents-simple-file-cache.ts (83%) rename server/{ => server}/lib/hls.ts (89%) rename server/{ => server}/lib/internal-event-emitter.ts (93%) rename server/{ => server}/lib/job-queue/handlers/activitypub-cleaner.ts (87%) rename server/{ => server}/lib/job-queue/handlers/activitypub-follow.ts (83%) rename server/{ => server}/lib/job-queue/handlers/activitypub-http-broadcast.ts (80%) rename server/{ => server}/lib/job-queue/handlers/activitypub-http-fetcher.ts (74%) rename server/{ => server}/lib/job-queue/handlers/activitypub-http-unicast.ts (69%) rename server/{ => server}/lib/job-queue/handlers/activitypub-refresher.ts (82%) rename server/{ => server}/lib/job-queue/handlers/actor-keys.ts (70%) rename server/{ => server}/lib/job-queue/handlers/after-video-channel-import.ts (90%) rename server/{ => server}/lib/job-queue/handlers/email.ts (67%) rename server/{ => server}/lib/job-queue/handlers/federate-video.ts (78%) rename server/{ => server}/lib/job-queue/handlers/generate-storyboard.ts (91%) rename server/{ => server}/lib/job-queue/handlers/manage-video-torrent.ts (89%) rename server/{ => server}/lib/job-queue/handlers/move-to-object-storage.ts (92%) rename server/{ => server}/lib/job-queue/handlers/notify.ts (75%) rename server/{ => server}/lib/job-queue/handlers/transcoding-job-builder.ts (77%) rename server/{ => server}/lib/job-queue/handlers/video-channel-import.ts (80%) rename server/{ => server}/lib/job-queue/handlers/video-file-import.ts (75%) rename server/{ => server}/lib/job-queue/handlers/video-import.ts (87%) rename server/{ => server}/lib/job-queue/handlers/video-live-ending.ts (91%) rename server/{ => server}/lib/job-queue/handlers/video-redundancy.ts (75%) rename server/{ => server}/lib/job-queue/handlers/video-studio-edition.ts (88%) rename server/{ => server}/lib/job-queue/handlers/video-transcoding.ts (94%) rename server/{ => server}/lib/job-queue/handlers/video-views-stats.ts (85%) create mode 100644 server/server/lib/job-queue/index.ts rename server/{ => server}/lib/job-queue/job-queue.ts (93%) create mode 100644 server/server/lib/live/index.ts rename server/{ => server}/lib/live/live-manager.ts (91%) rename server/{ => server}/lib/live/live-quota-store.ts (100%) rename server/{ => server}/lib/live/live-segment-sha-store.ts (88%) rename server/{ => server}/lib/live/live-utils.ts (84%) create mode 100644 server/server/lib/live/shared/index.ts rename server/{ => server}/lib/live/shared/muxing-session.ts (94%) rename server/{ => server}/lib/live/shared/transcoding-wrapper/abstract-transcoding-wrapper.ts (90%) rename server/{ => server}/lib/live/shared/transcoding-wrapper/ffmpeg-transcoding-wrapper.ts (89%) create mode 100644 server/server/lib/live/shared/transcoding-wrapper/index.ts rename server/{ => server}/lib/live/shared/transcoding-wrapper/remote-transcoding-wrapper.ts (95%) rename server/{ => server}/lib/local-actor.ts (80%) rename server/{ => server}/lib/model-loaders/actor.ts (80%) create mode 100644 server/server/lib/model-loaders/index.ts rename server/{ => server}/lib/model-loaders/video.ts (94%) rename server/{ => server}/lib/moderation.ts (90%) create mode 100644 server/server/lib/notifier/index.ts rename server/{ => server}/lib/notifier/notifier.ts (93%) rename server/{ => server}/lib/notifier/shared/abuse/abstract-new-abuse-message.ts (82%) rename server/{ => server}/lib/notifier/shared/abuse/abuse-state-change-for-reporter.ts (81%) create mode 100644 server/server/lib/notifier/shared/abuse/index.ts rename server/{ => server}/lib/notifier/shared/abuse/new-abuse-for-moderators.ts (90%) rename server/{ => server}/lib/notifier/shared/abuse/new-abuse-message-for-moderators.ts (71%) rename server/{ => server}/lib/notifier/shared/abuse/new-abuse-message-for-reporter.ts (77%) create mode 100644 server/server/lib/notifier/shared/blacklist/index.ts rename server/{ => server}/lib/notifier/shared/blacklist/new-auto-blacklist-for-moderators.ts (80%) rename server/{ => server}/lib/notifier/shared/blacklist/new-blacklist-for-owner.ts (77%) rename server/{ => server}/lib/notifier/shared/blacklist/unblacklist-for-owner.ts (78%) rename server/{ => server}/lib/notifier/shared/comment/comment-mention.ts (89%) create mode 100644 server/server/lib/notifier/shared/comment/index.ts rename server/{ => server}/lib/notifier/shared/comment/new-comment-for-video-owner.ts (86%) rename server/{ => server}/lib/notifier/shared/common/abstract-notification.ts (72%) create mode 100644 server/server/lib/notifier/shared/common/index.ts rename server/{ => server}/lib/notifier/shared/follow/auto-follow-for-instance.ts (83%) rename server/{ => server}/lib/notifier/shared/follow/follow-for-instance.ts (84%) rename server/{ => server}/lib/notifier/shared/follow/follow-for-user.ts (89%) create mode 100644 server/server/lib/notifier/shared/follow/index.ts create mode 100644 server/server/lib/notifier/shared/index.ts rename server/{ => server}/lib/notifier/shared/instance/direct-registration-for-moderators.ts (80%) create mode 100644 server/server/lib/notifier/shared/instance/index.ts rename server/{ => server}/lib/notifier/shared/instance/new-peertube-version-for-admins.ts (84%) rename server/{ => server}/lib/notifier/shared/instance/new-plugin-version-for-admins.ts (82%) rename server/{ => server}/lib/notifier/shared/instance/registration-request-for-moderators.ts (82%) rename server/{ => server}/lib/notifier/shared/video-publication/abstract-owned-video-publication.ts (81%) rename server/{ => server}/lib/notifier/shared/video-publication/import-finished-for-owner.ts (90%) create mode 100644 server/server/lib/notifier/shared/video-publication/index.ts rename server/{ => server}/lib/notifier/shared/video-publication/new-video-for-subscribers.ts (86%) rename server/{ => server}/lib/notifier/shared/video-publication/owned-publication-after-auto-unblacklist.ts (83%) rename server/{ => server}/lib/notifier/shared/video-publication/owned-publication-after-schedule-update.ts (83%) rename server/{ => server}/lib/notifier/shared/video-publication/owned-publication-after-transcoding.ts (94%) rename server/{ => server}/lib/notifier/shared/video-publication/studio-edition-finished-for-owner.ts (81%) create mode 100644 server/server/lib/object-storage/index.ts rename server/{ => server}/lib/object-storage/keys.ts (88%) rename server/{ => server}/lib/object-storage/pre-signed-urls.ts (67%) rename server/{ => server}/lib/object-storage/proxy.ts (88%) create mode 100644 server/server/lib/object-storage/shared/client.ts create mode 100644 server/server/lib/object-storage/shared/index.ts rename server/{ => server}/lib/object-storage/shared/logger.ts (53%) rename server/{ => server}/lib/object-storage/shared/object-storage-helpers.ts (81%) rename server/{ => server}/lib/object-storage/urls.ts (92%) rename server/{ => server}/lib/object-storage/videos.ts (94%) rename server/{ => server}/lib/opentelemetry/metric-helpers/bittorrent-tracker-observers-builder.ts (100%) create mode 100644 server/server/lib/opentelemetry/metric-helpers/index.ts rename server/{ => server}/lib/opentelemetry/metric-helpers/job-queue-observers-builder.ts (91%) rename server/{ => server}/lib/opentelemetry/metric-helpers/lives-observers-builder.ts (91%) rename server/{ => server}/lib/opentelemetry/metric-helpers/nodejs-observers-builder.ts (98%) rename server/{ => server}/lib/opentelemetry/metric-helpers/playback-metrics.ts (95%) rename server/{ => server}/lib/opentelemetry/metric-helpers/stats-observers-builder.ts (98%) rename server/{ => server}/lib/opentelemetry/metric-helpers/viewers-observers-builder.ts (97%) rename server/{ => server}/lib/opentelemetry/metrics.ts (92%) create mode 100644 server/server/lib/opentelemetry/tracing.ts rename server/{ => server}/lib/paths.ts (88%) rename server/{ => server}/lib/peertube-socket.ts (91%) rename server/{ => server}/lib/plugins/hooks.ts (84%) rename server/{ => server}/lib/plugins/plugin-helpers-builder.ts (88%) rename server/{ => server}/lib/plugins/plugin-index.ts (85%) rename server/{ => server}/lib/plugins/plugin-manager.ts (94%) rename server/{ => server}/lib/plugins/register-helpers.ts (95%) rename server/{ => server}/lib/plugins/theme-utils.ts (82%) rename server/{ => server}/lib/plugins/video-constant-manager-factory.ts (95%) rename server/{ => server}/lib/plugins/yarn.ts (85%) rename server/{ => server}/lib/redis.ts (97%) rename server/{ => server}/lib/redundancy.ts (88%) create mode 100644 server/server/lib/runners/index.ts rename server/{ => server}/lib/runners/job-handlers/abstract-job-handler.ts (93%) rename server/{ => server}/lib/runners/job-handlers/abstract-vod-transcoding-job-handler.ts (78%) create mode 100644 server/server/lib/runners/job-handlers/index.ts rename server/{ => server}/lib/runners/job-handlers/live-rtmp-hls-transcoding-job-handler.ts (90%) rename server/{ => server}/lib/runners/job-handlers/runner-job-handlers.ts (74%) create mode 100644 server/server/lib/runners/job-handlers/shared/index.ts rename server/{ => server}/lib/runners/job-handlers/shared/vod-helpers.ts (74%) rename server/{ => server}/lib/runners/job-handlers/video-studio-transcoding-job-handler.ts (86%) rename server/{ => server}/lib/runners/job-handlers/vod-audio-merge-transcoding-job-handler.ts (84%) rename server/{ => server}/lib/runners/job-handlers/vod-hls-transcoding-job-handler.ts (85%) rename server/{ => server}/lib/runners/job-handlers/vod-web-video-transcoding-job-handler.ts (85%) rename server/{ => server}/lib/runners/runner-urls.ts (91%) rename server/{ => server}/lib/runners/runner.ts (86%) rename server/{ => server}/lib/schedulers/abstract-scheduler.ts (94%) rename server/{ => server}/lib/schedulers/actor-follow-scheduler.ts (88%) rename server/{ => server}/lib/schedulers/auto-follow-index-instances.ts (84%) rename server/{ => server}/lib/schedulers/geo-ip-update-scheduler.ts (79%) rename server/{ => server}/lib/schedulers/peertube-version-check-scheduler.ts (76%) rename server/{ => server}/lib/schedulers/plugins-check-scheduler.ts (84%) rename server/{ => server}/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts (90%) rename server/{ => server}/lib/schedulers/remove-old-history-scheduler.ts (80%) rename server/{ => server}/lib/schedulers/remove-old-views-scheduler.ts (75%) rename server/{ => server}/lib/schedulers/runner-job-watch-dog-scheduler.ts (82%) rename server/{ => server}/lib/schedulers/update-videos-scheduler.ts (78%) rename server/{ => server}/lib/schedulers/video-channel-sync-latest-scheduler.ts (85%) rename server/{ => server}/lib/schedulers/video-views-buffer-scheduler.ts (86%) rename server/{ => server}/lib/schedulers/videos-redundancy-scheduler.ts (94%) rename server/{ => server}/lib/schedulers/youtube-dl-update-scheduler.ts (77%) rename server/{ => server}/lib/search.ts (88%) rename server/{ => server}/lib/server-config-manager.ts (94%) rename server/{ => server}/lib/signup.ts (73%) rename server/{ => server}/lib/stat-manager.ts (93%) rename server/{ => server}/lib/sync-channel.ts (86%) rename server/{ => server}/lib/thumbnail.ts (93%) rename server/{ => server}/lib/timeserie.ts (97%) rename server/{ => server}/lib/transcoding/create-transcoding-job.ts (91%) rename server/{ => server}/lib/transcoding/default-transcoding-profiles.ts (95%) rename server/{ => server}/lib/transcoding/ended-transcoding.ts (79%) rename server/{ => server}/lib/transcoding/hls-transcoding.ts (86%) rename server/{ => server}/lib/transcoding/shared/ffmpeg-builder.ts (78%) create mode 100644 server/server/lib/transcoding/shared/index.ts rename server/{ => server}/lib/transcoding/shared/job-builders/abstract-job-builder.ts (96%) create mode 100644 server/server/lib/transcoding/shared/job-builders/index.ts rename server/{ => server}/lib/transcoding/shared/job-builders/transcoding-job-queue-builder.ts (95%) rename server/{ => server}/lib/transcoding/shared/job-builders/transcoding-runner-job-builder.ts (91%) rename server/{ => server}/lib/transcoding/transcoding-priority.ts (74%) rename server/{ => server}/lib/transcoding/transcoding-quick-transcode.ts (81%) rename server/{ => server}/lib/transcoding/transcoding-resolutions.ts (88%) rename server/{ => server}/lib/transcoding/web-transcoding.ts (90%) rename server/{ => server}/lib/uploadx.ts (81%) rename server/{ => server}/lib/user.ts (88%) rename server/{ => server}/lib/video-blacklist.ts (87%) rename server/{ => server}/lib/video-channel.ts (82%) rename server/{ => server}/lib/video-comment.ts (90%) rename server/{ => server}/lib/video-file.ts (87%) rename server/{ => server}/lib/video-path-manager.ts (88%) rename server/{ => server}/lib/video-playlist.ts (77%) rename server/{ => server}/lib/video-pre-import.ts (91%) rename server/{ => server}/lib/video-privacy.ts (90%) rename server/{ => server}/lib/video-state.ts (87%) rename server/{ => server}/lib/video-studio.ts (86%) rename server/{ => server}/lib/video-tokens-manager.ts (88%) rename server/{ => server}/lib/video-urls.ts (95%) rename server/{ => server}/lib/video.ts (84%) create mode 100644 server/server/lib/views/shared/index.ts rename server/{ => server}/lib/views/shared/video-viewer-counters.ts (93%) rename server/{ => server}/lib/views/shared/video-viewer-stats.ts (91%) rename server/{ => server}/lib/views/shared/video-views.ts (87%) rename server/{ => server}/lib/views/video-views-manager.ts (94%) rename server/{ => server}/lib/worker/parent-process.ts (82%) rename server/{ => server}/lib/worker/workers/http-broadcast.ts (76%) rename server/{ => server}/lib/worker/workers/image-downloader.ts (74%) create mode 100644 server/server/lib/worker/workers/image-processor.ts rename server/{ => server}/middlewares/activitypub.ts (93%) rename server/{ => server}/middlewares/async.ts (98%) rename server/{ => server}/middlewares/auth.ts (88%) rename server/{ => server}/middlewares/cache/cache.ts (86%) create mode 100644 server/server/middlewares/cache/index.ts rename server/{ => server}/middlewares/cache/shared/api-cache.ts (94%) create mode 100644 server/server/middlewares/cache/shared/index.ts rename server/{ => server}/middlewares/csp.ts (96%) rename server/{ => server}/middlewares/dnt.ts (100%) rename server/{ => server}/middlewares/doc.ts (100%) rename server/{ => server}/middlewares/error.ts (92%) create mode 100644 server/server/middlewares/index.ts rename server/{ => server}/middlewares/pagination.ts (80%) rename server/{ => server}/middlewares/rate-limiter.ts (83%) rename server/{ => server}/middlewares/robots.ts (100%) rename server/{ => server}/middlewares/servers.ts (83%) rename server/{ => server}/middlewares/sort.ts (100%) rename server/{ => server}/middlewares/user-right.ts (76%) rename server/{ => server}/middlewares/validators/abuse.ts (94%) rename server/{ => server}/middlewares/validators/account.ts (93%) rename server/{ => server}/middlewares/validators/activitypub/activity.ts (84%) create mode 100644 server/server/middlewares/validators/activitypub/index.ts rename server/{ => server}/middlewares/validators/activitypub/pagination.ts (83%) rename server/{ => server}/middlewares/validators/activitypub/signature.ts (89%) rename server/{ => server}/middlewares/validators/actor-image.ts (86%) rename server/{ => server}/middlewares/validators/blocklist.ts (93%) rename server/{ => server}/middlewares/validators/bulk.ts (85%) rename server/{ => server}/middlewares/validators/config.ts (96%) rename server/{ => server}/middlewares/validators/express.ts (100%) rename server/{ => server}/middlewares/validators/feeds.ts (96%) rename server/{ => server}/middlewares/validators/follows.ts (87%) create mode 100644 server/server/middlewares/validators/index.ts rename server/{ => server}/middlewares/validators/jobs.ts (81%) rename server/{ => server}/middlewares/validators/logs.ts (88%) rename server/{ => server}/middlewares/validators/metrics.ts (84%) rename server/{ => server}/middlewares/validators/object-storage-proxy.ts (80%) rename server/{ => server}/middlewares/validators/oembed.ts (90%) rename server/{ => server}/middlewares/validators/pagination.ts (86%) rename server/{ => server}/middlewares/validators/plugins.ts (89%) rename server/{ => server}/middlewares/validators/redundancy.ts (94%) create mode 100644 server/server/middlewares/validators/runners/index.ts rename server/{ => server}/middlewares/validators/runners/job-files.ts (94%) rename server/{ => server}/middlewares/validators/runners/jobs.ts (92%) rename server/{ => server}/middlewares/validators/runners/registration-token.ts (81%) rename server/{ => server}/middlewares/validators/runners/runners.ts (89%) rename server/{ => server}/middlewares/validators/search.ts (94%) rename server/{ => server}/middlewares/validators/server.ts (85%) rename server/{ => server}/middlewares/validators/shared/abuses.ts (72%) rename server/{ => server}/middlewares/validators/shared/accounts.ts (84%) create mode 100644 server/server/middlewares/validators/shared/index.ts rename server/{ => server}/middlewares/validators/shared/user-registrations.ts (88%) rename server/{ => server}/middlewares/validators/shared/users.ts (84%) rename server/{ => server}/middlewares/validators/shared/utils.ts (95%) rename server/{ => server}/middlewares/validators/shared/video-blacklists.ts (89%) rename server/{ => server}/middlewares/validators/shared/video-captions.ts (82%) rename server/{ => server}/middlewares/validators/shared/video-channel-syncs.ts (87%) rename server/{ => server}/middlewares/validators/shared/video-channels.ts (93%) rename server/{ => server}/middlewares/validators/shared/video-comments.ts (90%) rename server/{ => server}/middlewares/validators/shared/video-imports.ts (87%) rename server/{ => server}/middlewares/validators/shared/video-ownerships.ts (79%) rename server/{ => server}/middlewares/validators/shared/video-passwords.ts (90%) rename server/{ => server}/middlewares/validators/shared/video-playlists.ts (89%) rename server/{ => server}/middlewares/validators/shared/videos.ts (92%) rename server/{ => server}/middlewares/validators/sort.ts (96%) rename server/{ => server}/middlewares/validators/static.ts (92%) rename server/{ => server}/middlewares/validators/themes.ts (84%) rename server/{ => server}/middlewares/validators/two-factor.ts (93%) rename server/{ => server}/middlewares/validators/user-email-verification.ts (93%) rename server/{ => server}/middlewares/validators/user-history.ts (93%) rename server/{ => server}/middlewares/validators/user-notifications.ts (94%) rename server/{ => server}/middlewares/validators/user-registrations.ts (92%) rename server/{ => server}/middlewares/validators/user-subscriptions.ts (89%) rename server/{ => server}/middlewares/validators/users.ts (96%) create mode 100644 server/server/middlewares/validators/videos/index.ts create mode 100644 server/server/middlewares/validators/videos/shared/index.ts rename server/{ => server}/middlewares/validators/videos/shared/upload.ts (86%) rename server/{ => server}/middlewares/validators/videos/shared/video-validators.ts (84%) rename server/{ => server}/middlewares/validators/videos/video-blacklist.ts (92%) rename server/{ => server}/middlewares/validators/videos/video-captions.ts (92%) rename server/{ => server}/middlewares/validators/videos/video-channel-sync.ts (90%) rename server/{ => server}/middlewares/validators/videos/video-channels.ts (92%) rename server/{ => server}/middlewares/validators/videos/video-comments.ts (94%) rename server/{ => server}/middlewares/validators/videos/video-files.ts (96%) rename server/{ => server}/middlewares/validators/videos/video-imports.ts (88%) rename server/{ => server}/middlewares/validators/videos/video-live.ts (94%) rename server/{ => server}/middlewares/validators/videos/video-ownership-changes.ts (91%) rename server/{ => server}/middlewares/validators/videos/video-passwords.ts (95%) rename server/{ => server}/middlewares/validators/videos/video-playlists.ts (94%) rename server/{ => server}/middlewares/validators/videos/video-rates.ts (90%) rename server/{ => server}/middlewares/validators/videos/video-shares.ts (89%) rename server/{ => server}/middlewares/validators/videos/video-source.ts (87%) rename server/{ => server}/middlewares/validators/videos/video-stats.ts (94%) rename server/{ => server}/middlewares/validators/videos/video-studio.ts (88%) rename server/{ => server}/middlewares/validators/videos/video-token.ts (75%) rename server/{ => server}/middlewares/validators/videos/video-transcoding.ts (90%) rename server/{ => server}/middlewares/validators/videos/video-view.ts (88%) rename server/{ => server}/middlewares/validators/videos/videos.ts (95%) rename server/{ => server}/middlewares/validators/webfinger.ts (77%) rename server/{ => server}/models/abuse/abuse-message.ts (87%) rename server/{ => server}/models/abuse/abuse.ts (90%) rename server/{ => server}/models/abuse/sql/abuse-query-builder.ts (94%) rename server/{ => server}/models/abuse/video-abuse.ts (78%) rename server/{ => server}/models/abuse/video-comment-abuse.ts (76%) rename server/{ => server}/models/account/account-blocklist.ts (93%) rename server/{ => server}/models/account/account-video-rate.ts (90%) rename server/{ => server}/models/account/account.ts (88%) rename server/{ => server}/models/account/actor-custom-page.ts (86%) rename server/{ => server}/models/actor/actor-follow.ts (95%) rename server/{ => server}/models/actor/actor-image.ts (82%) rename server/{ => server}/models/actor/actor.ts (90%) rename server/{ => server}/models/actor/sql/instance-list-followers-query-builder.ts (84%) rename server/{ => server}/models/actor/sql/instance-list-following-query-builder.ts (85%) rename server/{ => server}/models/actor/sql/shared/actor-follow-table-attributes.ts (71%) rename server/{ => server}/models/actor/sql/shared/instance-list-follows-query-builder.ts (93%) rename server/{ => server}/models/application/application.ts (87%) rename server/{ => server}/models/oauth/oauth-client.ts (87%) rename server/{ => server}/models/oauth/oauth-token.ts (87%) rename server/{ => server}/models/redundancy/video-redundancy.ts (96%) rename server/{ => server}/models/runner/runner-job.ts (89%) rename server/{ => server}/models/runner/runner-registration-token.ts (89%) rename server/{ => server}/models/runner/runner.ts (88%) rename server/{ => server}/models/server/plugin.ts (87%) rename server/{ => server}/models/server/server-blocklist.ts (92%) rename server/{ => server}/models/server/server.ts (85%) rename server/{ => server}/models/server/tracker.ts (82%) rename server/{ => server}/models/server/video-tracker.ts (76%) rename server/{ => server}/models/shared/abstract-run-query.ts (100%) create mode 100644 server/server/models/shared/index.ts rename server/{ => server}/models/shared/model-builder.ts (97%) rename server/{ => server}/models/shared/model-cache.ts (97%) rename server/{ => server}/models/shared/query.ts (84%) rename server/{ => server}/models/shared/sequelize-helpers.ts (100%) rename server/{ => server}/models/shared/sort.ts (100%) rename server/{ => server}/models/shared/sql.ts (82%) rename server/{ => server}/models/shared/update.ts (100%) rename server/{ => server}/models/user/sql/user-notitication-list-query-builder.ts (99%) rename server/{ => server}/models/user/user-notification-setting.ts (79%) rename server/{ => server}/models/user/user-notification.ts (88%) rename server/{ => server}/models/user/user-registration.ts (90%) rename server/{ => server}/models/user/user-video-history.ts (81%) rename server/{ => server}/models/user/user.ts (93%) create mode 100644 server/server/models/video/formatter/index.ts create mode 100644 server/server/models/video/formatter/shared/index.ts rename server/{ => server}/models/video/formatter/shared/video-format-utils.ts (77%) rename server/{ => server}/models/video/formatter/video-activity-pub-format.ts (94%) rename server/{ => server}/models/video/formatter/video-api-format.ts (95%) rename server/{ => server}/models/video/schedule-video-update.ts (73%) rename server/{ => server}/models/video/sql/comment/video-comment-list-query-builder.ts (98%) rename server/{ => server}/models/video/sql/comment/video-comment-table-attributes.ts (76%) create mode 100644 server/server/models/video/sql/video/index.ts rename server/{ => server}/models/video/sql/video/shared/abstract-video-query-builder.ts (97%) rename server/{ => server}/models/video/sql/video/shared/video-file-query-builder.ts (99%) rename server/{ => server}/models/video/sql/video/shared/video-model-builder.ts (93%) rename server/{ => server}/models/video/sql/video/shared/video-table-attributes.ts (100%) rename server/{ => server}/models/video/sql/video/video-model-get-query-builder.ts (97%) rename server/{ => server}/models/video/sql/video/videos-id-list-query-builder.ts (97%) rename server/{ => server}/models/video/sql/video/videos-model-list-query-builder.ts (92%) rename server/{ => server}/models/video/storyboard.ts (89%) rename server/{ => server}/models/video/tag.ts (85%) rename server/{ => server}/models/video/thumbnail.ts (83%) rename server/{ => server}/models/video/video-blacklist.ts (84%) rename server/{ => server}/models/video/video-caption.ts (88%) rename server/{ => server}/models/video/video-change-ownership.ts (84%) rename server/{ => server}/models/video/video-channel-sync.ts (86%) rename server/{ => server}/models/video/video-channel.ts (95%) rename server/{ => server}/models/video/video-comment.ts (86%) rename server/{ => server}/models/video/video-file.ts (93%) rename server/{ => server}/models/video/video-import.ts (90%) rename server/{ => server}/models/video/video-job-info.ts (93%) rename server/{ => server}/models/video/video-live-replay-setting.ts (82%) rename server/{ => server}/models/video/video-live-session.ts (90%) rename server/{ => server}/models/video/video-live.ts (86%) rename server/{ => server}/models/video/video-password.ts (88%) rename server/{ => server}/models/video/video-playlist-element.ts (89%) rename server/{ => server}/models/video/video-playlist.ts (92%) rename server/{ => server}/models/video/video-share.ts (93%) rename server/{ => server}/models/video/video-source.ts (81%) rename server/{ => server}/models/video/video-streaming-playlist.ts (89%) rename server/{ => server}/models/video/video-tag.ts (77%) rename server/{ => server}/models/video/video.ts (91%) rename server/{ => server}/models/view/local-video-viewer-watch-section.ts (87%) rename server/{ => server}/models/view/local-video-viewer.ts (96%) rename server/{ => server}/models/view/video-view.ts (89%) rename server/{ => server}/static/dnt-policy/dnt-policy-1.0.txt (100%) rename server/{ => server}/types/activitypub-processor.model.ts (55%) rename server/{ => server}/types/express-handler.ts (100%) rename server/{ => server}/types/express.d.ts (93%) create mode 100644 server/server/types/index.ts rename server/{ => server}/types/lib.d.ts (100%) rename server/{ => server}/types/models/abuse/abuse-message.ts (75%) rename server/{ => server}/types/models/abuse/abuse.ts (94%) create mode 100644 server/server/types/models/abuse/index.ts rename server/{ => server}/types/models/account/account-blocklist.ts (85%) rename server/{ => server}/types/models/account/account.ts (89%) rename server/{ => server}/types/models/account/actor-custom-page.ts (86%) create mode 100644 server/server/types/models/account/index.ts rename server/{ => server}/types/models/actor/actor-follow.ts (95%) rename server/{ => server}/types/models/actor/actor-image.ts (81%) rename server/{ => server}/types/models/actor/actor.ts (94%) create mode 100644 server/server/types/models/actor/index.ts rename server/{ => server}/types/models/application/application.ts (94%) create mode 100644 server/server/types/models/application/index.ts create mode 100644 server/server/types/models/index.ts create mode 100644 server/server/types/models/oauth/index.ts rename server/{ => server}/types/models/oauth/oauth-client.ts (94%) rename server/{ => server}/types/models/oauth/oauth-token.ts (77%) create mode 100644 server/server/types/models/runners/index.ts rename server/{ => server}/types/models/runners/runner-job.ts (84%) rename server/{ => server}/types/models/runners/runner-registration-token.ts (87%) rename server/{ => server}/types/models/runners/runner.ts (70%) create mode 100644 server/server/types/models/server/index.ts rename server/{ => server}/types/models/server/plugin.ts (85%) rename server/{ => server}/types/models/server/server-blocklist.ts (85%) rename server/{ => server}/types/models/server/server.ts (78%) rename server/{ => server}/types/models/server/tracker.ts (73%) create mode 100644 server/server/types/models/user/index.ts rename server/{ => server}/types/models/user/user-notification-setting.ts (91%) rename server/{ => server}/types/models/user/user-notification.ts (89%) rename server/{ => server}/types/models/user/user-registration.ts (80%) rename server/{ => server}/types/models/user/user-video-history.ts (92%) rename server/{ => server}/types/models/user/user.ts (85%) create mode 100644 server/server/types/models/video/index.ts rename server/{ => server}/types/models/video/local-video-viewer-watch-section.ts (85%) rename server/{ => server}/types/models/video/local-video-viewer.ts (81%) rename server/{ => server}/types/models/video/schedule-video-update.ts (94%) rename server/{ => server}/types/models/video/storyboard.ts (80%) create mode 100644 server/server/types/models/video/tag.ts rename server/{ => server}/types/models/video/thumbnail.ts (69%) rename server/{ => server}/types/models/video/video-blacklist.ts (87%) rename server/{ => server}/types/models/video/video-caption.ts (88%) rename server/{ => server}/types/models/video/video-change-ownership.ts (84%) rename server/{ => server}/types/models/video/video-channel-sync.ts (82%) rename server/{ => server}/types/models/video/video-channels.ts (94%) rename server/{ => server}/types/models/video/video-comment.ts (93%) rename server/{ => server}/types/models/video/video-file.ts (88%) rename server/{ => server}/types/models/video/video-import.ts (85%) rename server/{ => server}/types/models/video/video-live-replay-setting.ts (83%) rename server/{ => server}/types/models/video/video-live-session.ts (74%) rename server/{ => server}/types/models/video/video-live.ts (70%) rename server/{ => server}/types/models/video/video-password.ts (91%) rename server/{ => server}/types/models/video/video-playlist-element.ts (89%) rename server/{ => server}/types/models/video/video-playlist.ts (92%) rename server/{ => server}/types/models/video/video-rate.ts (85%) rename server/{ => server}/types/models/video/video-redundancy.ts (83%) rename server/{ => server}/types/models/video/video-share.ts (75%) rename server/{ => server}/types/models/video/video-source.ts (93%) rename server/{ => server}/types/models/video/video-streaming-playlist.ts (87%) rename server/{ => server}/types/models/video/video.ts (92%) create mode 100644 server/server/types/plugins/index.ts rename server/{ => server}/types/plugins/plugin-library.model.ts (95%) rename server/{ => server}/types/plugins/register-server-auth.model.ts (92%) rename server/{ => server}/types/plugins/register-server-option.model.ts (94%) rename server/{ => server}/types/plugins/register-server-websocket-route.model.ts (100%) rename server/{ => server}/types/sequelize.ts (90%) delete mode 100644 server/tests/api/activitypub/index.ts delete mode 100644 server/tests/api/check-params/index.ts delete mode 100644 server/tests/api/index.ts delete mode 100644 server/tests/api/live/index.ts delete mode 100644 server/tests/api/moderation/index.ts delete mode 100644 server/tests/api/notifications/index.ts delete mode 100644 server/tests/api/object-storage/index.ts delete mode 100644 server/tests/api/redundancy/index.ts delete mode 100644 server/tests/api/runners/index.ts delete mode 100644 server/tests/api/search/index.ts delete mode 100644 server/tests/api/server/index.ts delete mode 100644 server/tests/api/transcoding/index.ts delete mode 100644 server/tests/api/users/index.ts delete mode 100644 server/tests/api/videos/index.ts delete mode 100644 server/tests/api/views/index.ts delete mode 100644 server/tests/helpers/comment-model.ts delete mode 100644 server/tests/helpers/index.ts delete mode 100644 server/tests/index.ts delete mode 100644 server/tests/lib/index.ts delete mode 100644 server/tests/peertube-runner/index.ts delete mode 100644 server/tests/shared/index.ts delete mode 100644 server/tests/shared/mock-servers/index.ts delete mode 100644 server/tools/README.md delete mode 100644 server/tools/package.json delete mode 100644 server/tools/peertube-auth.ts delete mode 100644 server/tools/peertube-get-access-token.ts delete mode 100644 server/tools/peertube-import-videos.ts delete mode 100644 server/tools/peertube-plugins.ts delete mode 100644 server/tools/peertube-redundancy.ts delete mode 100644 server/tools/peertube-upload.ts delete mode 100644 server/tools/shared/index.ts delete mode 100644 server/tools/tsconfig.json create mode 100644 server/tsconfig.lib.json delete mode 100644 server/types/index.ts delete mode 100644 server/types/models/abuse/index.ts delete mode 100644 server/types/models/account/index.ts delete mode 100644 server/types/models/actor/index.ts delete mode 100644 server/types/models/application/index.ts delete mode 100644 server/types/models/index.ts delete mode 100644 server/types/models/oauth/index.ts delete mode 100644 server/types/models/runners/index.ts delete mode 100644 server/types/models/server/index.ts delete mode 100644 server/types/models/user/index.ts delete mode 100644 server/types/models/video/index.ts delete mode 100644 server/types/models/video/tag.ts delete mode 100644 server/types/plugins/index.ts delete mode 100644 shared/core-utils/abuse/index.ts delete mode 100644 shared/core-utils/common/index.ts delete mode 100644 shared/core-utils/common/path.ts delete mode 100644 shared/core-utils/i18n/index.ts delete mode 100644 shared/core-utils/index.ts delete mode 100644 shared/core-utils/plugins/index.ts delete mode 100644 shared/core-utils/renderer/index.ts delete mode 100644 shared/core-utils/users/index.ts delete mode 100644 shared/core-utils/videos/index.ts delete mode 100644 shared/extra-utils/index.ts delete mode 100644 shared/ffmpeg/index.ts delete mode 100644 shared/ffmpeg/shared/index.ts delete mode 100644 shared/models/activitypub/index.ts delete mode 100644 shared/models/activitypub/objects/activitypub-object.ts delete mode 100644 shared/models/activitypub/objects/index.ts delete mode 100644 shared/models/actors/actor-image.type.ts delete mode 100644 shared/models/actors/index.ts delete mode 100644 shared/models/bulk/index.ts delete mode 100644 shared/models/common/index.ts delete mode 100644 shared/models/custom-markup/index.ts delete mode 100644 shared/models/feeds/feed-format.enum.ts delete mode 100644 shared/models/feeds/index.ts delete mode 100644 shared/models/http/index.ts delete mode 100644 shared/models/index.ts delete mode 100644 shared/models/joinpeertube/index.ts delete mode 100644 shared/models/metrics/index.ts delete mode 100644 shared/models/moderation/abuse/abuse-reason.model.ts delete mode 100644 shared/models/moderation/abuse/abuse-state.model.ts delete mode 100644 shared/models/moderation/abuse/abuse-update.model.ts delete mode 100644 shared/models/moderation/abuse/index.ts delete mode 100644 shared/models/moderation/index.ts delete mode 100644 shared/models/nodeinfo/index.ts delete mode 100644 shared/models/overviews/index.ts delete mode 100644 shared/models/plugins/client/index.ts delete mode 100644 shared/models/plugins/hook-type.enum.ts delete mode 100644 shared/models/plugins/index.ts delete mode 100644 shared/models/plugins/plugin-index/index.ts delete mode 100644 shared/models/plugins/plugin.type.ts delete mode 100644 shared/models/plugins/server/api/index.ts delete mode 100644 shared/models/plugins/server/index.ts delete mode 100644 shared/models/plugins/server/managers/index.ts delete mode 100644 shared/models/plugins/server/settings/index.ts delete mode 100644 shared/models/redundancy/index.ts delete mode 100644 shared/models/runners/index.ts delete mode 100644 shared/models/runners/runner-job-state.model.ts delete mode 100644 shared/models/search/index.ts delete mode 100644 shared/models/server/index.ts delete mode 100644 shared/models/tokens/index.ts delete mode 100644 shared/models/users/index.ts delete mode 100644 shared/models/users/registration/index.ts delete mode 100644 shared/models/users/registration/user-registration-state.model.ts delete mode 100644 shared/models/users/user-flag.model.ts delete mode 100644 shared/models/users/user-notification-setting.model.ts delete mode 100644 shared/models/users/user-right.enum.ts delete mode 100644 shared/models/users/user-role.ts delete mode 100644 shared/models/videos/blacklist/index.ts delete mode 100644 shared/models/videos/blacklist/video-blacklist.model.ts delete mode 100644 shared/models/videos/caption/index.ts delete mode 100644 shared/models/videos/change-ownership/index.ts delete mode 100644 shared/models/videos/change-ownership/video-change-ownership.model.ts delete mode 100644 shared/models/videos/channel-sync/index.ts delete mode 100644 shared/models/videos/channel-sync/video-channel-sync-state.enum.ts delete mode 100644 shared/models/videos/channel/index.ts delete mode 100644 shared/models/videos/comment/index.ts delete mode 100644 shared/models/videos/file/index.ts delete mode 100644 shared/models/videos/file/video-resolution.enum.ts delete mode 100644 shared/models/videos/import/index.ts delete mode 100644 shared/models/videos/import/video-import-state.enum.ts delete mode 100644 shared/models/videos/index.ts delete mode 100644 shared/models/videos/live/index.ts delete mode 100644 shared/models/videos/live/live-video-create.model.ts delete mode 100644 shared/models/videos/live/live-video-error.enum.ts delete mode 100644 shared/models/videos/live/live-video-event-payload.model.ts delete mode 100644 shared/models/videos/live/live-video-latency-mode.enum.ts delete mode 100644 shared/models/videos/live/live-video-update.model.ts delete mode 100644 shared/models/videos/live/live-video.model.ts delete mode 100644 shared/models/videos/playlist/index.ts delete mode 100644 shared/models/videos/playlist/video-playlist-element.model.ts delete mode 100644 shared/models/videos/playlist/video-playlist-privacy.model.ts delete mode 100644 shared/models/videos/playlist/video-playlist-type.model.ts delete mode 100644 shared/models/videos/playlist/video-playlist.model.ts delete mode 100644 shared/models/videos/rate/account-video-rate.model.ts delete mode 100644 shared/models/videos/rate/index.ts delete mode 100644 shared/models/videos/stats/index.ts delete mode 100644 shared/models/videos/studio/index.ts delete mode 100644 shared/models/videos/thumbnail.type.ts delete mode 100644 shared/models/videos/transcoding/index.ts delete mode 100644 shared/models/videos/video-include.enum.ts delete mode 100644 shared/models/videos/video-privacy.enum.ts delete mode 100644 shared/models/videos/video-schedule-update.model.ts delete mode 100644 shared/models/videos/video-state.enum.ts delete mode 100644 shared/models/videos/video-storage.enum.ts delete mode 100644 shared/models/videos/video-streaming-playlist.type.ts delete mode 100644 shared/server-commands/bulk/index.ts delete mode 100644 shared/server-commands/cli/index.ts delete mode 100644 shared/server-commands/custom-pages/index.ts delete mode 100644 shared/server-commands/feeds/index.ts delete mode 100644 shared/server-commands/index.ts delete mode 100644 shared/server-commands/logs/index.ts delete mode 100644 shared/server-commands/moderation/index.ts delete mode 100644 shared/server-commands/overviews/index.ts delete mode 100644 shared/server-commands/requests/index.ts delete mode 100644 shared/server-commands/runners/index.ts delete mode 100644 shared/server-commands/search/index.ts delete mode 100644 shared/server-commands/server/index.ts delete mode 100644 shared/server-commands/shared/index.ts delete mode 100644 shared/server-commands/socket/index.ts delete mode 100644 shared/server-commands/users/index.ts delete mode 100644 shared/server-commands/videos/index.ts delete mode 100644 shared/tsconfig.json delete mode 100644 shared/typescript-utils/index.ts create mode 100644 tsconfig.eslint.json delete mode 100644 tsconfig.json diff --git a/.eslintrc.json b/.eslintrc.json index 4e80ff224..3bfdee6eb 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,5 +1,6 @@ { "extends": "standard-with-typescript", + "root": true, "rules": { "eol-last": [ "error", @@ -126,18 +127,20 @@ ] }, "ignorePatterns": [ - "node_modules/", - "server/tests/fixtures" + "node_modules", + "packages/tests/fixtures", + "apps/**/dist", + "packages/**/dist", + "server/dist", + "packages/types-generator/tests", + "*.js", + "/client", + "/dist" ], "parserOptions": { - "EXPERIMENTAL_useSourceOfProjectReferenceRedirect": true, "project": [ - "./tsconfig.json", - "./shared/tsconfig.json", - "./scripts/tsconfig.json", - "./server/tsconfig.json", - "./server/tools/tsconfig.json", - "./packages/peertube-runner/tsconfig.json" - ] + "./tsconfig.eslint.json" + ], + "EXPERIMENTAL_useSourceOfProjectReferenceRedirect": true } } diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 80b7cba3c..16863eceb 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -53,13 +53,25 @@ interested in, user interface, design, decentralized architecture... You can help to write the documentation of the REST API, code, architecture, demonstrations. -For the REST API you can see the documentation in [/support/doc/api](https://github.com/Chocobozzz/PeerTube/tree/develop/support/doc/api) directory. -Then, you can just open the `openapi.yaml` file in a special editor like [http://editor.swagger.io/](http://editor.swagger.io/) to easily see and edit the documentation. You can also use [redoc-cli](https://github.com/Redocly/redoc/blob/master/cli/README.md) and run `redoc-cli serve --watch support/doc/api/openapi.yaml` to see the final result. +### User documentation + +The official user documentation is available on https://docs.joinpeertube.org/ + +You can update it by writing markdown files in the following repository: https://framagit.org/framasoft/peertube/documentation/ + +### REST API documentation + +The [REST API documentation](https://docs.joinpeertube.org/api-rest-reference.html) is generated from `support/doc/api/openapi.yaml` file. +To quickly get a preview of your changes, you can generate the documentation *on the fly* using the following command: + +``` +npx @redocly/cli preview-docs ./support/doc/api/openapi.yaml +``` Some hints: - * Routes are defined in [/server/controllers/](https://github.com/Chocobozzz/PeerTube/tree/develop/server/controllers) directory - * Parameters validators are defined in [/server/middlewares/validators](https://github.com/Chocobozzz/PeerTube/tree/develop/server/middlewares/validators) directory - * Models sent/received by the controllers are defined in [/shared/models](https://github.com/Chocobozzz/PeerTube/tree/develop/shared/models) directory + * Routes are defined in [/server/server/controllers/](https://github.com/Chocobozzz/PeerTube/tree/develop/server/server/controllers) directory + * Parameters validators are defined in [/server/server/middlewares/validators](https://github.com/Chocobozzz/PeerTube/tree/develop/server/server/middlewares/validators) directory + * Models sent/received by the controllers are defined in [/packages/models](https://github.com/Chocobozzz/PeerTube/tree/develop/packages/models) directory ## Improve the website @@ -242,15 +254,6 @@ To test emails with PeerTube: * Run [mailslurper](http://mailslurper.com/) * Run PeerTube using mailslurper SMTP port: `NODE_CONFIG='{ "smtp": { "hostname": "localhost", "port": 2500, "tls": false } }' NODE_ENV=dev node dist/server` -### OpenAPI documentation - -The [REST API documentation](https://docs.joinpeertube.org/api-rest-reference.html) is generated from `support/doc/api/openapi.yaml` file. -To quickly get a preview of your changes, you can generate the documentation *on the fly* using the following command: - -``` -npx @redocly/cli preview-docs ./support/doc/api/openapi.yaml -``` - ### Environment variables PeerTube can be configured using environment variables. diff --git a/.github/actions/reusable-prepare-peertube-build/action.yml b/.github/actions/reusable-prepare-peertube-build/action.yml index 03034f6cc..13e22ceb4 100644 --- a/.github/actions/reusable-prepare-peertube-build/action.yml +++ b/.github/actions/reusable-prepare-peertube-build/action.yml @@ -32,4 +32,12 @@ runs: - name: Install peertube runner dependencies shell: bash - run: cd packages/peertube-runner && yarn install --frozen-lockfile + run: cd apps/peertube-runner && yarn install --frozen-lockfile + + - name: Install peertube CLI dependencies + shell: bash + run: cd apps/peertube-cli && yarn install --frozen-lockfile + + - name: Display PeerTube dependencies + shell: bash + run: ls -l node_modules/@peertube diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index ab1780c74..5f56db3ad 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -71,7 +71,7 @@ jobs: - name: Run benchmark run: | - node dist/scripts/benchmark.js -o benchmark.json + npm run benchmark-server -- -o benchmark.json - name: Display result run: | diff --git a/.github/workflows/codeql/codeql-config.yml b/.github/workflows/codeql/codeql-config.yml index 8b771ae99..c96a4693e 100644 --- a/.github/workflows/codeql/codeql-config.yml +++ b/.github/workflows/codeql/codeql-config.yml @@ -1,4 +1,4 @@ name: "PeerTube CodeQL config" paths-ignore: - - server/tests + - packages/tests diff --git a/.github/workflows/stats.yml b/.github/workflows/stats.yml index e772fdb81..573b42975 100644 --- a/.github/workflows/stats.yml +++ b/.github/workflows/stats.yml @@ -36,12 +36,12 @@ jobs: run: | wget "https://github.com/boyter/scc/releases/download/v3.0.0/scc-3.0.0-x86_64-unknown-linux.zip" unzip "scc-3.0.0-x86_64-unknown-linux.zip" - ./scc --format=json --exclude-dir .git,node_modules,client/node_modules,client/dist,dist,yarn.lock,client/yarn.lock,client/src/locale,test1,test2,test3,client/src/assets/images,config,storage,server/tests/fixtures,support/openapi,.idea,.vscode,docker-volume,ffmpeg-3,ffmpeg-4 > ./scc.json + ./scc --format=json --exclude-dir .git,node_modules,client/node_modules,client/dist,dist,yarn.lock,client/yarn.lock,client/src/locale,test1,test2,test3,client/src/assets/images,config,storage,packages/tests/fixtures,support/openapi,.idea,.vscode,docker-volume,ffmpeg-3,ffmpeg-4 > ./scc.json - name: PeerTube client stats if: github.event_name != 'pull_request' run: | - node dist/scripts/client-build-stats.js > client-build-stats.json + npm run client:build-stats > client-build-stats.json - name: PeerTube client lighthouse report if: github.event_name != 'pull_request' diff --git a/.gitignore b/.gitignore index e0004004d..55707fb80 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ # NPM instalation -/node_modules/ -/server/tools/node_modules +node_modules *npm-debug.log yarn-error.log +.yarn # Testing /test1/ @@ -11,8 +11,8 @@ yarn-error.log /test4/ /test5/ /test6/ -/server/tests/fixtures/video_high_bitrate_1080p.mp4 -/server/tests/fixtures/video_59fps.mp4 +/packages/tests/fixtures/video_high_bitrate_1080p.mp4 +/packages/tests/fixtures/video_59fps.mp4 # Production /storage @@ -49,12 +49,14 @@ yarn-error.log /*.tar.xz /*.asc *.DS_Store -/server/tools/import-mediacore.ts /docker-volume/ /init.mp4 # TypeScript *.tsbuildinfo -# Packages -/packages/types/dist/ +# EsLint +.eslintcache + +# Compiled output +dist diff --git a/.mocharc.cjs b/.mocharc.cjs new file mode 100644 index 000000000..88566cfcb --- /dev/null +++ b/.mocharc.cjs @@ -0,0 +1,10 @@ +process.env.ESBK_TSCONFIG_PATH = './packages/tests/tsconfig.json' + +module.exports = { + "node-option": [ + "loader=tsx", + "no-warnings", + "conditions=peertube:tsx" + ], + "timeout": 30000 +} diff --git a/apps/peertube-cli/.npmignore b/apps/peertube-cli/.npmignore new file mode 100644 index 000000000..af17b9f32 --- /dev/null +++ b/apps/peertube-cli/.npmignore @@ -0,0 +1,4 @@ +src +meta.json +tsconfig.json +scripts diff --git a/apps/peertube-cli/README.md b/apps/peertube-cli/README.md new file mode 100644 index 000000000..b5b379090 --- /dev/null +++ b/apps/peertube-cli/README.md @@ -0,0 +1,43 @@ +# PeerTube CLI + +## Usage + +See https://docs.joinpeertube.org/maintain/tools#remote-tools + +## Dev + +## Install dependencies + +```bash +cd peertube-root +yarn install --pure-lockfile +cd apps/peertube-cli && yarn install --pure-lockfile +``` + +## Develop + +```bash +cd peertube-root +npm run dev:peertube-cli +``` + +## Build + +```bash +cd peertube-root +npm run build:peertube-cli +``` + +## Run + +```bash +cd peertube-root +node apps/peertube-cli/dist/peertube-cli.js --help +``` + +## Publish on NPM + +```bash +cd peertube-root +(cd apps/peertube-cli && npm version patch) && npm run build:peertube-cli && (cd apps/peertube-cli && npm publish --access=public) +``` diff --git a/apps/peertube-cli/package.json b/apps/peertube-cli/package.json new file mode 100644 index 000000000..a78319be2 --- /dev/null +++ b/apps/peertube-cli/package.json @@ -0,0 +1,19 @@ +{ + "name": "@peertube/peertube-cli", + "version": "1.0.1", + "type": "module", + "main": "dist/peertube.js", + "bin": "dist/peertube.js", + "engines": { + "node": ">=16.x" + }, + "scripts": {}, + "license": "AGPL-3.0", + "private": false, + "devDependencies": { + "application-config": "^2.0.0", + "cli-table3": "^0.6.0", + "netrc-parser": "^3.1.6" + }, + "dependencies": {} +} diff --git a/apps/peertube-cli/scripts/build.js b/apps/peertube-cli/scripts/build.js new file mode 100644 index 000000000..a9139acfa --- /dev/null +++ b/apps/peertube-cli/scripts/build.js @@ -0,0 +1,27 @@ +import * as esbuild from 'esbuild' +import { readFileSync } from 'fs' + +const packageJSON = JSON.parse(readFileSync(new URL('../package.json', import.meta.url))) + +export const esbuildOptions = { + entryPoints: [ './src/peertube.ts' ], + bundle: true, + platform: 'node', + format: 'esm', + target: 'node16', + external: [ + './lib-cov/fluent-ffmpeg', + 'pg-hstore' + ], + outfile: './dist/peertube.js', + banner: { + js: `const require = (await import("node:module")).createRequire(import.meta.url);` + + `const __filename = (await import("node:url")).fileURLToPath(import.meta.url);` + + `const __dirname = (await import("node:path")).dirname(__filename);` + }, + define: { + 'process.env.PACKAGE_VERSION': `'${packageJSON.version}'` + } +} + +await esbuild.build(esbuildOptions) diff --git a/apps/peertube-cli/scripts/watch.js b/apps/peertube-cli/scripts/watch.js new file mode 100644 index 000000000..94e57199c --- /dev/null +++ b/apps/peertube-cli/scripts/watch.js @@ -0,0 +1,7 @@ +import * as esbuild from 'esbuild' +import { esbuildOptions } from './build.js' + +const context = await esbuild.context(esbuildOptions) + +// Enable watch mode +await context.watch() diff --git a/apps/peertube-cli/src/peertube-auth.ts b/apps/peertube-cli/src/peertube-auth.ts new file mode 100644 index 000000000..1d30207c7 --- /dev/null +++ b/apps/peertube-cli/src/peertube-auth.ts @@ -0,0 +1,171 @@ +import CliTable3 from 'cli-table3' +import prompt from 'prompt' +import { Command } from '@commander-js/extra-typings' +import { assignToken, buildServer, getNetrc, getSettings, writeSettings } from './shared/index.js' + +export function defineAuthProgram () { + const program = new Command() + .name('auth') + .description('Register your accounts on remote instances to use them with other commands') + + program + .command('add') + .description('remember your accounts on remote instances for easier use') + .option('-u, --url ', 'Server url') + .option('-U, --username ', 'Username') + .option('-p, --password ', 'Password') + .option('--default', 'add the entry as the new default') + .action(options => { + /* eslint-disable no-import-assign */ + prompt.override = options + prompt.start() + prompt.get({ + properties: { + url: { + description: 'instance url', + conform: value => isURLaPeerTubeInstance(value), + message: 'It should be an URL (https://peertube.example.com)', + required: true + }, + username: { + conform: value => typeof value === 'string' && value.length !== 0, + message: 'Name must be only letters, spaces, or dashes', + required: true + }, + password: { + hidden: true, + replace: '*', + required: true + } + } + }, async (_, result) => { + + // Check credentials + try { + // Strip out everything after the domain:port. + // See https://github.com/Chocobozzz/PeerTube/issues/3520 + result.url = stripExtraneousFromPeerTubeUrl(result.url) + + const server = buildServer(result.url) + await assignToken(server, result.username, result.password) + } catch (err) { + console.error(err.message) + process.exit(-1) + } + + await setInstance(result.url, result.username, result.password, options.default) + + process.exit(0) + }) + }) + + program + .command('del ') + .description('Unregisters a remote instance') + .action(async url => { + await delInstance(url) + + process.exit(0) + }) + + program + .command('list') + .description('List registered remote instances') + .action(async () => { + const [ settings, netrc ] = await Promise.all([ getSettings(), getNetrc() ]) + + const table = new CliTable3({ + head: [ 'instance', 'login' ], + colWidths: [ 30, 30 ] + }) as any + + settings.remotes.forEach(element => { + if (!netrc.machines[element]) return + + table.push([ + element, + netrc.machines[element].login + ]) + }) + + console.log(table.toString()) + + process.exit(0) + }) + + program + .command('set-default ') + .description('Set an existing entry as default') + .action(async url => { + const settings = await getSettings() + const instanceExists = settings.remotes.includes(url) + + if (instanceExists) { + settings.default = settings.remotes.indexOf(url) + await writeSettings(settings) + + process.exit(0) + } else { + console.log(' is not a registered instance.') + process.exit(-1) + } + }) + + program.addHelpText('after', '\n\n Examples:\n\n' + + ' $ peertube auth add -u https://peertube.cpy.re -U "PEERTUBE_USER" --password "PEERTUBE_PASSWORD"\n' + + ' $ peertube auth add -u https://peertube.cpy.re -U root\n' + + ' $ peertube auth list\n' + + ' $ peertube auth del https://peertube.cpy.re\n' + ) + + return program +} + +// --------------------------------------------------------------------------- +// Private +// --------------------------------------------------------------------------- + +async function delInstance (url: string) { + const [ settings, netrc ] = await Promise.all([ getSettings(), getNetrc() ]) + + const index = settings.remotes.indexOf(url) + settings.remotes.splice(index) + + if (settings.default === index) settings.default = -1 + + await writeSettings(settings) + + delete netrc.machines[url] + + await netrc.save() +} + +async function setInstance (url: string, username: string, password: string, isDefault: boolean) { + const [ settings, netrc ] = await Promise.all([ getSettings(), getNetrc() ]) + + if (settings.remotes.includes(url) === false) { + settings.remotes.push(url) + } + + if (isDefault || settings.remotes.length === 1) { + settings.default = settings.remotes.length - 1 + } + + await writeSettings(settings) + + netrc.machines[url] = { login: username, password } + await netrc.save() +} + +function isURLaPeerTubeInstance (url: string) { + return url.startsWith('http://') || url.startsWith('https://') +} + +function stripExtraneousFromPeerTubeUrl (url: string) { + // Get everything before the 3rd /. + const urlLength = url.includes('/', 8) + ? url.indexOf('/', 8) + : url.length + + return url.substring(0, urlLength) +} diff --git a/apps/peertube-cli/src/peertube-get-access-token.ts b/apps/peertube-cli/src/peertube-get-access-token.ts new file mode 100644 index 000000000..3e0013182 --- /dev/null +++ b/apps/peertube-cli/src/peertube-get-access-token.ts @@ -0,0 +1,39 @@ +import { Command } from '@commander-js/extra-typings' +import { assignToken, buildServer } from './shared/index.js' + +export function defineGetAccessProgram () { + const program = new Command() + .name('get-access-token') + .description('Get a peertube access token') + .alias('token') + + program + .option('-u, --url ', 'Server url') + .option('-n, --username ', 'Username') + .option('-p, --password ', 'Password') + .action(async options => { + try { + if ( + !options.url || + !options.username || + !options.password + ) { + if (!options.url) console.error('--url field is required.') + if (!options.username) console.error('--username field is required.') + if (!options.password) console.error('--password field is required.') + + process.exit(-1) + } + + const server = buildServer(options.url) + await assignToken(server, options.username, options.password) + + console.log(server.accessToken) + } catch (err) { + console.error('Cannot get access token: ' + err.message) + process.exit(-1) + } + }) + + return program +} diff --git a/apps/peertube-cli/src/peertube-plugins.ts b/apps/peertube-cli/src/peertube-plugins.ts new file mode 100644 index 000000000..c9da56266 --- /dev/null +++ b/apps/peertube-cli/src/peertube-plugins.ts @@ -0,0 +1,167 @@ +import CliTable3 from 'cli-table3' +import { isAbsolute } from 'path' +import { Command } from '@commander-js/extra-typings' +import { PluginType, PluginType_Type } from '@peertube/peertube-models' +import { assignToken, buildServer, CommonProgramOptions, getServerCredentials } from './shared/index.js' + +export function definePluginsProgram () { + const program = new Command() + + program + .name('plugins') + .description('Manage instance plugins/themes') + .alias('p') + + program + .command('list') + .description('List installed plugins') + .option('-u, --url ', 'Server url') + .option('-U, --username ', 'Username') + .option('-p, --password ', 'Password') + .option('-t, --only-themes', 'List themes only') + .option('-P, --only-plugins', 'List plugins only') + .action(async options => { + try { + await pluginsListCLI(options) + } catch (err) { + console.error('Cannot list plugins: ' + err.message) + process.exit(-1) + } + }) + + program + .command('install') + .description('Install a plugin or a theme') + .option('-u, --url ', 'Server url') + .option('-U, --username ', 'Username') + .option('-p, --password ', 'Password') + .option('-P --path ', 'Install from a path') + .option('-n, --npm-name ', 'Install from npm') + .option('--plugin-version ', 'Specify the plugin version to install (only available when installing from npm)') + .action(async options => { + try { + await installPluginCLI(options) + } catch (err) { + console.error('Cannot install plugin: ' + err.message) + process.exit(-1) + } + }) + + program + .command('update') + .description('Update a plugin or a theme') + .option('-u, --url ', 'Server url') + .option('-U, --username ', 'Username') + .option('-p, --password ', 'Password') + .option('-P --path ', 'Update from a path') + .option('-n, --npm-name ', 'Update from npm') + .action(async options => { + try { + await updatePluginCLI(options) + } catch (err) { + console.error('Cannot update plugin: ' + err.message) + process.exit(-1) + } + }) + + program + .command('uninstall') + .description('Uninstall a plugin or a theme') + .option('-u, --url ', 'Server url') + .option('-U, --username ', 'Username') + .option('-p, --password ', 'Password') + .option('-n, --npm-name ', 'NPM plugin/theme name') + .action(async options => { + try { + await uninstallPluginCLI(options) + } catch (err) { + console.error('Cannot uninstall plugin: ' + err.message) + process.exit(-1) + } + }) + + return program +} + +// ---------------------------------------------------------------------------- + +async function pluginsListCLI (options: CommonProgramOptions & { onlyThemes?: true, onlyPlugins?: true }) { + const { url, username, password } = await getServerCredentials(options) + const server = buildServer(url) + await assignToken(server, username, password) + + let pluginType: PluginType_Type + if (options.onlyThemes) pluginType = PluginType.THEME + if (options.onlyPlugins) pluginType = PluginType.PLUGIN + + const { data } = await server.plugins.list({ start: 0, count: 100, sort: 'name', pluginType }) + + const table = new CliTable3({ + head: [ 'name', 'version', 'homepage' ], + colWidths: [ 50, 20, 50 ] + }) as any + + for (const plugin of data) { + const npmName = plugin.type === PluginType.PLUGIN + ? 'peertube-plugin-' + plugin.name + : 'peertube-theme-' + plugin.name + + table.push([ + npmName, + plugin.version, + plugin.homepage + ]) + } + + console.log(table.toString()) +} + +async function installPluginCLI (options: CommonProgramOptions & { path?: string, npmName?: string, pluginVersion?: string }) { + if (!options.path && !options.npmName) { + throw new Error('You need to specify the npm name or the path of the plugin you want to install.') + } + + if (options.path && !isAbsolute(options.path)) { + throw new Error('Path should be absolute.') + } + + const { url, username, password } = await getServerCredentials(options) + const server = buildServer(url) + await assignToken(server, username, password) + + await server.plugins.install({ npmName: options.npmName, path: options.path, pluginVersion: options.pluginVersion }) + + console.log('Plugin installed.') +} + +async function updatePluginCLI (options: CommonProgramOptions & { path?: string, npmName?: string }) { + if (!options.path && !options.npmName) { + throw new Error('You need to specify the npm name or the path of the plugin you want to update.') + } + + if (options.path && !isAbsolute(options.path)) { + throw new Error('Path should be absolute.') + } + + const { url, username, password } = await getServerCredentials(options) + const server = buildServer(url) + await assignToken(server, username, password) + + await server.plugins.update({ npmName: options.npmName, path: options.path }) + + console.log('Plugin updated.') +} + +async function uninstallPluginCLI (options: CommonProgramOptions & { npmName?: string }) { + if (!options.npmName) { + throw new Error('You need to specify the npm name of the plugin/theme you want to uninstall.') + } + + const { url, username, password } = await getServerCredentials(options) + const server = buildServer(url) + await assignToken(server, username, password) + + await server.plugins.uninstall({ npmName: options.npmName }) + + console.log('Plugin uninstalled.') +} diff --git a/apps/peertube-cli/src/peertube-redundancy.ts b/apps/peertube-cli/src/peertube-redundancy.ts new file mode 100644 index 000000000..56fc6366b --- /dev/null +++ b/apps/peertube-cli/src/peertube-redundancy.ts @@ -0,0 +1,186 @@ +import bytes from 'bytes' +import CliTable3 from 'cli-table3' +import { URL } from 'url' +import { Command } from '@commander-js/extra-typings' +import { forceNumber, uniqify } from '@peertube/peertube-core-utils' +import { HttpStatusCode, VideoRedundanciesTarget } from '@peertube/peertube-models' +import { assignToken, buildServer, CommonProgramOptions, getServerCredentials } from './shared/index.js' + +export function defineRedundancyProgram () { + const program = new Command() + .name('redundancy') + .description('Manage instance redundancies') + .alias('r') + + program + .command('list-remote-redundancies') + .description('List remote redundancies on your videos') + .option('-u, --url ', 'Server url') + .option('-U, --username ', 'Username') + .option('-p, --password ', 'Password') + .action(async options => { + try { + await listRedundanciesCLI({ target: 'my-videos', ...options }) + } catch (err) { + console.error('Cannot list remote redundancies: ' + err.message) + process.exit(-1) + } + }) + + program + .command('list-my-redundancies') + .description('List your redundancies of remote videos') + .option('-u, --url ', 'Server url') + .option('-U, --username ', 'Username') + .option('-p, --password ', 'Password') + .action(async options => { + try { + await listRedundanciesCLI({ target: 'remote-videos', ...options }) + } catch (err) { + console.error('Cannot list redundancies: ' + err.message) + process.exit(-1) + } + }) + + program + .command('add') + .description('Duplicate a video in your redundancy system') + .option('-u, --url ', 'Server url') + .option('-U, --username ', 'Username') + .option('-p, --password ', 'Password') + .requiredOption('-v, --video ', 'Video id to duplicate', parseInt) + .action(async options => { + try { + await addRedundancyCLI(options) + } catch (err) { + console.error('Cannot duplicate video: ' + err.message) + process.exit(-1) + } + }) + + program + .command('remove') + .description('Remove a video from your redundancies') + .option('-u, --url ', 'Server url') + .option('-U, --username ', 'Username') + .option('-p, --password ', 'Password') + .requiredOption('-v, --video ', 'Video id to remove from redundancies', parseInt) + .action(async options => { + try { + await removeRedundancyCLI(options) + } catch (err) { + console.error('Cannot remove redundancy: ' + err) + process.exit(-1) + } + }) + + return program +} + +// ---------------------------------------------------------------------------- + +async function listRedundanciesCLI (options: CommonProgramOptions & { target: VideoRedundanciesTarget }) { + const { target } = options + + const { url, username, password } = await getServerCredentials(options) + const server = buildServer(url) + await assignToken(server, username, password) + + const { data } = await server.redundancy.listVideos({ start: 0, count: 100, sort: 'name', target }) + + const table = new CliTable3({ + head: [ 'video id', 'video name', 'video url', 'files', 'playlists', 'by instances', 'total size' ] + }) as any + + for (const redundancy of data) { + const webVideoFiles = redundancy.redundancies.files + const streamingPlaylists = redundancy.redundancies.streamingPlaylists + + let totalSize = '' + if (target === 'remote-videos') { + const tmp = webVideoFiles.concat(streamingPlaylists) + .reduce((a, b) => a + b.size, 0) + + // FIXME: don't use external dependency to stringify bytes: we already have the functions in the client + totalSize = bytes(tmp) + } + + const instances = uniqify( + webVideoFiles.concat(streamingPlaylists) + .map(r => r.fileUrl) + .map(u => new URL(u).host) + ) + + table.push([ + redundancy.id.toString(), + redundancy.name, + redundancy.url, + webVideoFiles.length, + streamingPlaylists.length, + instances.join('\n'), + totalSize + ]) + } + + console.log(table.toString()) +} + +async function addRedundancyCLI (options: { video: number } & CommonProgramOptions) { + const { url, username, password } = await getServerCredentials(options) + const server = buildServer(url) + await assignToken(server, username, password) + + if (!options.video || isNaN(options.video)) { + throw new Error('You need to specify the video id to duplicate and it should be a number.') + } + + try { + await server.redundancy.addVideo({ videoId: options.video }) + + console.log('Video will be duplicated by your instance!') + } catch (err) { + if (err.message.includes(HttpStatusCode.CONFLICT_409)) { + throw new Error('This video is already duplicated by your instance.') + } + + if (err.message.includes(HttpStatusCode.NOT_FOUND_404)) { + throw new Error('This video id does not exist.') + } + + throw err + } +} + +async function removeRedundancyCLI (options: CommonProgramOptions & { video: number }) { + const { url, username, password } = await getServerCredentials(options) + const server = buildServer(url) + await assignToken(server, username, password) + + if (!options.video || isNaN(options.video)) { + throw new Error('You need to specify the video id to remove from your redundancies') + } + + const videoId = forceNumber(options.video) + + const myVideoRedundancies = await server.redundancy.listVideos({ target: 'my-videos' }) + let videoRedundancy = myVideoRedundancies.data.find(r => videoId === r.id) + + if (!videoRedundancy) { + const remoteVideoRedundancies = await server.redundancy.listVideos({ target: 'remote-videos' }) + videoRedundancy = remoteVideoRedundancies.data.find(r => videoId === r.id) + } + + if (!videoRedundancy) { + throw new Error('Video redundancy not found.') + } + + const ids = videoRedundancy.redundancies.files + .concat(videoRedundancy.redundancies.streamingPlaylists) + .map(r => r.id) + + for (const id of ids) { + await server.redundancy.removeVideo({ redundancyId: id }) + } + + console.log('Video redundancy removed!') +} diff --git a/apps/peertube-cli/src/peertube-upload.ts b/apps/peertube-cli/src/peertube-upload.ts new file mode 100644 index 000000000..443f8ce1f --- /dev/null +++ b/apps/peertube-cli/src/peertube-upload.ts @@ -0,0 +1,167 @@ +import { access, constants } from 'fs/promises' +import { isAbsolute } from 'path' +import { inspect } from 'util' +import { Command } from '@commander-js/extra-typings' +import { VideoPrivacy } from '@peertube/peertube-models' +import { PeerTubeServer } from '@peertube/peertube-server-commands' +import { assignToken, buildServer, getServerCredentials, listOptions } from './shared/index.js' + +type UploadOptions = { + url?: string + username?: string + password?: string + thumbnail?: string + preview?: string + file?: string + videoName?: string + category?: string + licence?: string + language?: string + tags?: string + nsfw?: true + videoDescription?: string + privacy?: number + channelName?: string + noCommentsEnabled?: true + support?: string + noWaitTranscoding?: true + noDownloadEnabled?: true +} + +export function defineUploadProgram () { + const program = new Command('upload') + .description('Upload a video on a PeerTube instance') + .alias('up') + + program + .option('-u, --url ', 'Server url') + .option('-U, --username ', 'Username') + .option('-p, --password ', 'Password') + .option('-b, --thumbnail ', 'Thumbnail path') + .option('-v, --preview ', 'Preview path') + .option('-f, --file ', 'Video absolute file path') + .option('-n, --video-name ', 'Video name') + .option('-c, --category ', 'Category number') + .option('-l, --licence ', 'Licence number') + .option('-L, --language ', 'Language ISO 639 code (fr or en...)') + .option('-t, --tags ', 'Video tags', listOptions) + .option('-N, --nsfw', 'Video is Not Safe For Work') + .option('-d, --video-description ', 'Video description') + .option('-P, --privacy ', 'Privacy', parseInt) + .option('-C, --channel-name ', 'Channel name') + .option('--no-comments-enabled', 'Disable video comments') + .option('-s, --support ', 'Video support text') + .option('--no-wait-transcoding', 'Do not wait transcoding before publishing the video') + .option('--no-download-enabled', 'Disable video download') + .option('-v, --verbose ', 'Verbosity, from 0/\'error\' to 4/\'debug\'', 'info') + .action(async options => { + try { + const { url, username, password } = await getServerCredentials(options) + + if (!options.videoName || !options.file) { + if (!options.videoName) console.error('--video-name is required.') + if (!options.file) console.error('--file is required.') + + process.exit(-1) + } + + if (isAbsolute(options.file) === false) { + console.error('File path should be absolute.') + process.exit(-1) + } + + await run({ ...options, url, username, password }) + } catch (err) { + console.error('Cannot upload video: ' + err.message) + process.exit(-1) + } + }) + + return program +} + +// --------------------------------------------------------------------------- +// Private +// --------------------------------------------------------------------------- + +async function run (options: UploadOptions) { + const { url, username, password } = options + + const server = buildServer(url) + await assignToken(server, username, password) + + await access(options.file, constants.F_OK) + + console.log('Uploading %s video...', options.videoName) + + const baseAttributes = await buildVideoAttributesFromCommander(server, options) + + const attributes = { + ...baseAttributes, + + fixture: options.file, + thumbnailfile: options.thumbnail, + previewfile: options.preview + } + + try { + await server.videos.upload({ attributes }) + console.log(`Video ${options.videoName} uploaded.`) + process.exit(0) + } catch (err) { + const message = err.message || '' + if (message.includes('413')) { + console.error('Aborted: user quota is exceeded or video file is too big for this PeerTube instance.') + } else { + console.error(inspect(err)) + } + + process.exit(-1) + } +} + +async function buildVideoAttributesFromCommander (server: PeerTubeServer, options: UploadOptions, defaultAttributes: any = {}) { + const defaultBooleanAttributes = { + nsfw: false, + commentsEnabled: true, + downloadEnabled: true, + waitTranscoding: true + } + + const booleanAttributes: { [id in keyof typeof defaultBooleanAttributes]: boolean } | {} = {} + + for (const key of Object.keys(defaultBooleanAttributes)) { + if (options[key] !== undefined) { + booleanAttributes[key] = options[key] + } else if (defaultAttributes[key] !== undefined) { + booleanAttributes[key] = defaultAttributes[key] + } else { + booleanAttributes[key] = defaultBooleanAttributes[key] + } + } + + const videoAttributes = { + name: options.videoName || defaultAttributes.name, + category: options.category || defaultAttributes.category || undefined, + licence: options.licence || defaultAttributes.licence || undefined, + language: options.language || defaultAttributes.language || undefined, + privacy: options.privacy || defaultAttributes.privacy || VideoPrivacy.PUBLIC, + support: options.support || defaultAttributes.support || undefined, + description: options.videoDescription || defaultAttributes.description || undefined, + tags: options.tags || defaultAttributes.tags || undefined + } + + Object.assign(videoAttributes, booleanAttributes) + + if (options.channelName) { + const videoChannel = await server.channels.get({ channelName: options.channelName }) + + Object.assign(videoAttributes, { channelId: videoChannel.id }) + + if (!videoAttributes.support && videoChannel.support) { + Object.assign(videoAttributes, { support: videoChannel.support }) + } + } + + return videoAttributes +} diff --git a/server/tools/peertube.ts b/apps/peertube-cli/src/peertube.ts similarity index 60% rename from server/tools/peertube.ts rename to apps/peertube-cli/src/peertube.ts index b79917b4f..e3565bb1a 100644 --- a/server/tools/peertube.ts +++ b/apps/peertube-cli/src/peertube.ts @@ -1,32 +1,24 @@ #!/usr/bin/env node -import { CommandOptions, program } from 'commander' -import { getSettings, version } from './shared' +import { Command } from '@commander-js/extra-typings' +import { defineAuthProgram } from './peertube-auth.js' +import { defineGetAccessProgram } from './peertube-get-access-token.js' +import { definePluginsProgram } from './peertube-plugins.js' +import { defineRedundancyProgram } from './peertube-redundancy.js' +import { defineUploadProgram } from './peertube-upload.js' +import { getSettings, version } from './shared/index.js' + +const program = new Command() program .version(version, '-v, --version') .usage('[command] [options]') -/* Subcommands automatically loaded in the directory and beginning by peertube-* */ -program - .command('auth [action]', 'register your accounts on remote instances to use them with other commands') - .command('upload', 'upload a video').alias('up') - .command('import-videos', 'import a video from a streaming platform').alias('import') - .command('get-access-token', 'get a peertube access token', { noHelp: true }).alias('token') - .command('plugins [action]', 'manage instance plugins/themes').alias('p') - .command('redundancy [action]', 'manage instance redundancies').alias('r') - -/* Not Yet Implemented */ -program - .command( - 'diagnostic [action]', - 'like couple therapy, but for your instance', - { noHelp: true } as CommandOptions - ).alias('d') - .command('admin', - 'manage an instance where you have elevated rights', - { noHelp: true } as CommandOptions - ).alias('a') +program.addCommand(defineAuthProgram()) +program.addCommand(defineUploadProgram()) +program.addCommand(defineRedundancyProgram()) +program.addCommand(definePluginsProgram()) +program.addCommand(defineGetAccessProgram()) // help on no command if (!process.argv.slice(2).length) { diff --git a/server/tools/shared/cli.ts b/apps/peertube-cli/src/shared/cli.ts similarity index 50% rename from server/tools/shared/cli.ts rename to apps/peertube-cli/src/shared/cli.ts index e010ab320..080eb8237 100644 --- a/server/tools/shared/cli.ts +++ b/apps/peertube-cli/src/shared/cli.ts @@ -1,19 +1,23 @@ -import { Command } from 'commander' +import applicationConfig from 'application-config' import { Netrc } from 'netrc-parser' import { join } from 'path' import { createLogger, format, transports } from 'winston' -import { getAppNumber, isTestInstance } from '@server/helpers/core-utils' -import { loadLanguages } from '@server/initializers/constants' -import { root } from '@shared/core-utils' -import { UserRole, VideoPrivacy } from '@shared/models' -import { PeerTubeServer } from '@shared/server-commands' +import { UserRole } from '@peertube/peertube-models' +import { getAppNumber, isTestInstance, root } from '@peertube/peertube-node-utils' +import { PeerTubeServer } from '@peertube/peertube-server-commands' + +export type CommonProgramOptions = { + url?: string + username?: string + password?: string +} let configName = 'PeerTube/CLI' if (isTestInstance()) configName += `-${getAppNumber()}` -const config = require('application-config')(configName) +const config = applicationConfig(configName) -const version = require(join(root(), 'package.json')).version +const version: string = process.env.PACKAGE_VERSION async function getAdminTokenOrDie (server: PeerTubeServer, username: string, password: string) { const token = await server.login.getAccessToken(username, password) @@ -32,13 +36,13 @@ interface Settings { default: number } -async function getSettings (): Promise { - const defaultSettings = { +async function getSettings () { + const defaultSettings: Settings = { remotes: [], default: -1 } - const data = await config.read() + const data = await config.read() as Promise return Object.keys(data).length === 0 ? defaultSettings @@ -46,10 +50,8 @@ async function getSettings (): Promise { } async function getNetrc () { - const Netrc = require('netrc-parser').Netrc - const netrc = isTestInstance() - ? new Netrc(join(root(), 'test' + getAppNumber(), 'netrc')) + ? new Netrc(join(root(import.meta.url), 'test' + getAppNumber(), 'netrc')) : new Netrc() await netrc.load() @@ -66,11 +68,10 @@ function deleteSettings () { } function getRemoteObjectOrDie ( - program: Command, + options: CommonProgramOptions, settings: Settings, netrc: Netrc ): { url: string, username: string, password: string } { - const options = program.opts() function exitIfNoOptions (optionNames: string[], errorPrefix: string = '') { let exit = false @@ -119,85 +120,18 @@ function getRemoteObjectOrDie ( return { url, username, password } } -function buildCommonVideoOptions (command: Command) { - function list (val) { - return val.split(',') - } - - return command - .option('-n, --video-name ', 'Video name') - .option('-c, --category ', 'Category number') - .option('-l, --licence ', 'Licence number') - .option('-L, --language ', 'Language ISO 639 code (fr or en...)') - .option('-t, --tags ', 'Video tags', list) - .option('-N, --nsfw', 'Video is Not Safe For Work') - .option('-d, --video-description ', 'Video description') - .option('-P, --privacy ', 'Privacy') - .option('-C, --channel-name ', 'Channel name') - .option('--no-comments-enabled', 'Disable video comments') - .option('-s, --support ', 'Video support text') - .option('--no-wait-transcoding', 'Do not wait transcoding before publishing the video') - .option('--no-download-enabled', 'Disable video download') - .option('-v, --verbose ', 'Verbosity, from 0/\'error\' to 4/\'debug\'', 'info') +function listOptions (val: any) { + return val.split(',') } -async function buildVideoAttributesFromCommander (server: PeerTubeServer, command: Command, defaultAttributes: any = {}) { - const options = command.opts() - - const defaultBooleanAttributes = { - nsfw: false, - commentsEnabled: true, - downloadEnabled: true, - waitTranscoding: true - } - - const booleanAttributes: { [id in keyof typeof defaultBooleanAttributes]: boolean } | {} = {} - - for (const key of Object.keys(defaultBooleanAttributes)) { - if (options[key] !== undefined) { - booleanAttributes[key] = options[key] - } else if (defaultAttributes[key] !== undefined) { - booleanAttributes[key] = defaultAttributes[key] - } else { - booleanAttributes[key] = defaultBooleanAttributes[key] - } - } - - const videoAttributes = { - name: options.videoName || defaultAttributes.name, - category: options.category || defaultAttributes.category || undefined, - licence: options.licence || defaultAttributes.licence || undefined, - language: options.language || defaultAttributes.language || undefined, - privacy: options.privacy || defaultAttributes.privacy || VideoPrivacy.PUBLIC, - support: options.support || defaultAttributes.support || undefined, - description: options.videoDescription || defaultAttributes.description || undefined, - tags: options.tags || defaultAttributes.tags || undefined - } - - Object.assign(videoAttributes, booleanAttributes) - - if (options.channelName) { - const videoChannel = await server.channels.get({ channelName: options.channelName }) - - Object.assign(videoAttributes, { channelId: videoChannel.id }) - - if (!videoAttributes.support && videoChannel.support) { - Object.assign(videoAttributes, { support: videoChannel.support }) - } - } - - return videoAttributes -} - -function getServerCredentials (program: Command) { +function getServerCredentials (options: CommonProgramOptions) { return Promise.all([ getSettings(), getNetrc() ]) .then(([ settings, netrc ]) => { - return getRemoteObjectOrDie(program, settings, netrc) + return getRemoteObjectOrDie(options, settings, netrc) }) } function buildServer (url: string) { - loadLanguages() return new PeerTubeServer({ url }) } @@ -253,8 +187,7 @@ export { getServerCredentials, - buildCommonVideoOptions, - buildVideoAttributesFromCommander, + listOptions, getAdminTokenOrDie, buildServer, diff --git a/apps/peertube-cli/src/shared/index.ts b/apps/peertube-cli/src/shared/index.ts new file mode 100644 index 000000000..a1fc9470b --- /dev/null +++ b/apps/peertube-cli/src/shared/index.ts @@ -0,0 +1 @@ +export * from './cli.js' diff --git a/apps/peertube-cli/tsconfig.json b/apps/peertube-cli/tsconfig.json new file mode 100644 index 000000000..636bdb95a --- /dev/null +++ b/apps/peertube-cli/tsconfig.json @@ -0,0 +1,15 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "baseUrl": "./", + "outDir": "./dist", + "rootDir": "src", + "tsBuildInfoFile": "./dist/.tsbuildinfo" + }, + "references": [ + { "path": "../../packages/core-utils" }, + { "path": "../../packages/models" }, + { "path": "../../packages/node-utils" }, + { "path": "../../packages/server-commands" } + ] +} diff --git a/server/tools/yarn.lock b/apps/peertube-cli/yarn.lock similarity index 78% rename from server/tools/yarn.lock rename to apps/peertube-cli/yarn.lock index 025ef208d..76b36ee73 100644 --- a/server/tools/yarn.lock +++ b/apps/peertube-cli/yarn.lock @@ -3,26 +3,32 @@ "@babel/code-frame@^7.0.0": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.16.7.tgz#44416b6bd7624b998f5b1af5d470856c40138789" - integrity sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg== + version "7.22.10" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.22.10.tgz#1c20e612b768fefa75f6e90d6ecb86329247f0a3" + integrity sha512-/KKIMG4UEL35WmI9OlvMhurwtytjvXoFcGNrOvyG9zIzA8YmPjVtIZUf7b05+TPO7G7/GEmLHDaoCgACHl9hhA== dependencies: - "@babel/highlight" "^7.16.7" + "@babel/highlight" "^7.22.10" + chalk "^2.4.2" -"@babel/helper-validator-identifier@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz#e8c602438c4a8195751243da9031d1607d247cad" - integrity sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw== +"@babel/helper-validator-identifier@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz#9544ef6a33999343c8740fa51350f30eeaaaf193" + integrity sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ== -"@babel/highlight@^7.16.7": - version "7.16.10" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.16.10.tgz#744f2eb81579d6eea753c227b0f570ad785aba88" - integrity sha512-5FnTQLSLswEj6IkgVw5KusNUUFY9ZGqe/TRFnP/BKYHYgfh7tc+C7mwiy95/yNP7Dh9x580Vv8r7u7ZfTBFxdw== +"@babel/highlight@^7.22.10": + version "7.22.10" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.22.10.tgz#02a3f6d8c1cb4521b2fd0ab0da8f4739936137d7" + integrity sha512-78aUtVcT7MUscr0K5mIEnkwxPE0MaxkR5RxRwuHaQ+JuU5AmTPhY+do2mdzVTnIJJpyBglql2pehuBIWHug+WQ== dependencies: - "@babel/helper-validator-identifier" "^7.16.7" - chalk "^2.0.0" + "@babel/helper-validator-identifier" "^7.22.5" + chalk "^2.4.2" js-tokens "^4.0.0" +"@colors/colors@1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9" + integrity sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ== + ansi-regex@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" @@ -36,9 +42,9 @@ ansi-styles@^3.2.1: color-convert "^1.9.0" application-config-path@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/application-config-path/-/application-config-path-0.1.0.tgz#193c5f0a86541a4c66fba1e2dc38583362ea5e8f" - integrity sha1-GTxfCoZUGkxm+6Hi3DhYM2LqXo8= + version "0.1.1" + resolved "https://registry.yarnpkg.com/application-config-path/-/application-config-path-0.1.1.tgz#8b5ac64ff6afdd9bd70ce69f6f64b6998f5f756e" + integrity sha512-zy9cHePtMP0YhwG+CfHm0bgwdnga2X3gZexpdCwEj//dpb+TKajtiC8REEUJUSq6Ab4f9cgNy2l8ObXzCXFkEw== application-config@^2.0.0: version "2.0.0" @@ -49,7 +55,7 @@ application-config@^2.0.0: load-json-file "^6.2.0" write-json-file "^4.2.0" -chalk@^2.0.0: +chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -59,13 +65,13 @@ chalk@^2.0.0: supports-color "^5.3.0" cli-table3@^0.6.0: - version "0.6.1" - resolved "https://registry.yarnpkg.com/cli-table3/-/cli-table3-0.6.1.tgz#36ce9b7af4847f288d3cdd081fbd09bf7bd237b8" - integrity sha512-w0q/enDHhPLq44ovMGdQeeDLvwxwavsJX7oQGYt/LrBlYsyaxyDnp6z3QzFut/6kLLKnlcUVJLrpB7KBfgG/RA== + version "0.6.3" + resolved "https://registry.yarnpkg.com/cli-table3/-/cli-table3-0.6.3.tgz#61ab765aac156b52f222954ffc607a6f01dbeeb2" + integrity sha512-w5Jac5SykAeZJKntOxJCrm63Eg5/4dhMWIcuTbo9rpE+brgaSZo0RuNJZeOyMgsUdhDeojvgyQLmjI+K50ZGyg== dependencies: string-width "^4.2.0" optionalDependencies: - colors "1.4.0" + "@colors/colors" "1.5.0" color-convert@^1.9.0: version "1.9.3" @@ -77,12 +83,7 @@ color-convert@^1.9.0: color-name@1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= - -colors@1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78" - integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA== + integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw== cross-spawn@^6.0.0: version "6.0.5" @@ -122,7 +123,7 @@ error-ex@^1.3.1: escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= + integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg== execa@^0.10.0: version "0.10.0" @@ -140,27 +141,27 @@ execa@^0.10.0: get-stream@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" - integrity sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ= + integrity sha512-GlhdIUuVakc8SJ6kK0zAFbiGzRFzNnY4jUuEbV9UROo4Y+0Ny4fjvcZFVTeDA4odpFyOQzaw6hXukJSq/f28sQ== graceful-fs@^4.1.15: - version "4.2.9" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.9.tgz#041b05df45755e587a24942279b9d113146e1c96" - integrity sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ== + version "4.2.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" + integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== has-flag@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= + integrity sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw== imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" - integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= + integrity sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA== is-arrayish@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" - integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= + integrity sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg== is-fullwidth-code-point@^3.0.0: version "3.0.0" @@ -175,17 +176,17 @@ is-plain-obj@^2.0.0: is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" - integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ= + integrity sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ== is-typedarray@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" - integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo= + integrity sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA== isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= + integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== js-tokens@^4.0.0: version "4.0.0" @@ -240,14 +241,14 @@ nice-try@^1.0.4: npm-run-path@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" - integrity sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8= + integrity sha512-lJxZYlT4DW/bRUtFh1MQIWqmLwQfAxnqWG4HhEdjMlkrJYnJn0Jrr2u3mgxqaWsdiBc76TYkTG/mhrnYTuzfHw== dependencies: path-key "^2.0.0" p-finally@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" - integrity sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4= + integrity sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow== parse-json@^5.0.0: version "5.2.0" @@ -262,29 +263,29 @@ parse-json@^5.0.0: path-key@^2.0.0, path-key@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" - integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A= + integrity sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw== semver@^5.5.0: - version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== + version "5.7.2" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" + integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== semver@^6.0.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" - integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== + version "6.3.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" + integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== shebang-command@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" - integrity sha1-RKrGW2lbAzmJaMOfNj/uXer98eo= + integrity sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg== dependencies: shebang-regex "^1.0.0" shebang-regex@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" - integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= + integrity sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ== signal-exit@^3.0.0, signal-exit@^3.0.2: version "3.0.7" @@ -322,7 +323,7 @@ strip-bom@^4.0.0: strip-eof@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" - integrity sha1-u0P/VZim6wXYm1n80SnJgzE2Br8= + integrity sha512-7FCwGGmx8mD5xQd3RPUvnSpUXHM3BWuzjtpD4TXsfcZ9EL4azvVVUscFYwD9nx8Kh+uCBC00XBtAykoMHwTh8Q== supports-color@^5.3.0: version "5.5.0" diff --git a/packages/peertube-runner/.gitignore b/apps/peertube-runner/.gitignore similarity index 100% rename from packages/peertube-runner/.gitignore rename to apps/peertube-runner/.gitignore diff --git a/apps/peertube-runner/.npmignore b/apps/peertube-runner/.npmignore new file mode 100644 index 000000000..af17b9f32 --- /dev/null +++ b/apps/peertube-runner/.npmignore @@ -0,0 +1,4 @@ +src +meta.json +tsconfig.json +scripts diff --git a/apps/peertube-runner/README.md b/apps/peertube-runner/README.md new file mode 100644 index 000000000..37760f867 --- /dev/null +++ b/apps/peertube-runner/README.md @@ -0,0 +1,43 @@ +# PeerTube runner + +Runner program to execute jobs (transcoding...) of remote PeerTube instances. + +Commands below has to be run at the root of PeerTube git repository. + +## Dev + +### Install dependencies + +```bash +cd peertube-root +yarn install --pure-lockfile +cd apps/peertube-runner && yarn install --pure-lockfile +``` + +### Develop + +```bash +cd peertube-root +npm run dev:peertube-runner +``` + +### Build + +```bash +cd peertube-root +npm run build:peertube-runner +``` + +### Run + +```bash +cd peertube-root +node apps/peertube-runner/dist/peertube-runner.js --help +``` + +### Publish on NPM + +```bash +cd peertube-root +(cd apps/peertube-runner && npm version patch) && npm run build:peertube-runner && (cd apps/peertube-runner && npm publish --access=public) +``` diff --git a/packages/peertube-runner/package.json b/apps/peertube-runner/package.json similarity index 86% rename from packages/peertube-runner/package.json rename to apps/peertube-runner/package.json index 1c525691a..1dca15451 100644 --- a/packages/peertube-runner/package.json +++ b/apps/peertube-runner/package.json @@ -1,15 +1,18 @@ { "name": "@peertube/peertube-runner", "version": "0.0.5", + "type": "module", "main": "dist/peertube-runner.js", "bin": "dist/peertube-runner.js", + "engines": { + "node": ">=16.x" + }, "license": "AGPL-3.0", "dependencies": {}, "devDependencies": { "@commander-js/extra-typings": "^10.0.3", "@iarna/toml": "^2.2.5", "env-paths": "^3.0.0", - "esbuild": "^0.17.15", "net-ipc": "^2.0.1", "pino": "^8.11.0", "pino-pretty": "^10.0.0" diff --git a/apps/peertube-runner/scripts/build.js b/apps/peertube-runner/scripts/build.js new file mode 100644 index 000000000..f54ca35f3 --- /dev/null +++ b/apps/peertube-runner/scripts/build.js @@ -0,0 +1,26 @@ +import * as esbuild from 'esbuild' + +const packageJSON = JSON.parse(readFileSync(new URL('../package.json', import.meta.url))) + +export const esbuildOptions = { + entryPoints: [ './src/peertube-runner.ts' ], + bundle: true, + platform: 'node', + format: 'esm', + target: 'node16', + external: [ + './lib-cov/fluent-ffmpeg', + 'pg-hstore' + ], + outfile: './dist/peertube-runner.js', + banner: { + js: `const require = (await import("node:module")).createRequire(import.meta.url);` + + `const __filename = (await import("node:url")).fileURLToPath(import.meta.url);` + + `const __dirname = (await import("node:path")).dirname(__filename);` + }, + define: { + 'process.env.PACKAGE_VERSION': `'${packageJSON.version}'` + } +} + +await esbuild.build(esbuildOptions) diff --git a/packages/peertube-runner/peertube-runner.ts b/apps/peertube-runner/src/peertube-runner.ts similarity index 93% rename from packages/peertube-runner/peertube-runner.ts rename to apps/peertube-runner/src/peertube-runner.ts index 32586c4d9..67ca0e0ac 100644 --- a/packages/peertube-runner/peertube-runner.ts +++ b/apps/peertube-runner/src/peertube-runner.ts @@ -1,14 +1,12 @@ #!/usr/bin/env node import { Command, InvalidArgumentError } from '@commander-js/extra-typings' -import { listRegistered, registerRunner, unregisterRunner } from './register' -import { RunnerServer } from './server' -import { ConfigManager, logger } from './shared' - -const packageJSON = require('./package.json') +import { listRegistered, registerRunner, unregisterRunner } from './register/index.js' +import { RunnerServer } from './server/index.js' +import { ConfigManager, logger } from './shared/index.js' const program = new Command() - .version(packageJSON.version) + .version(process.env.PACKAGE_VERSION) .option( '--id ', 'Runner server id, so you can run multiple PeerTube server runners with different configurations on the same machine', diff --git a/apps/peertube-runner/src/register/index.ts b/apps/peertube-runner/src/register/index.ts new file mode 100644 index 000000000..a7d6cf457 --- /dev/null +++ b/apps/peertube-runner/src/register/index.ts @@ -0,0 +1 @@ +export * from './register.js' diff --git a/packages/peertube-runner/register/register.ts b/apps/peertube-runner/src/register/register.ts similarity index 92% rename from packages/peertube-runner/register/register.ts rename to apps/peertube-runner/src/register/register.ts index ca1bf0f5a..e8af21661 100644 --- a/packages/peertube-runner/register/register.ts +++ b/apps/peertube-runner/src/register/register.ts @@ -1,4 +1,4 @@ -import { IPCClient } from '../shared/ipc' +import { IPCClient } from '../shared/ipc/index.js' export async function registerRunner (options: { url: string diff --git a/apps/peertube-runner/src/server/index.ts b/apps/peertube-runner/src/server/index.ts new file mode 100644 index 000000000..e56cda526 --- /dev/null +++ b/apps/peertube-runner/src/server/index.ts @@ -0,0 +1 @@ +export * from './server.js' diff --git a/apps/peertube-runner/src/server/process/index.ts b/apps/peertube-runner/src/server/process/index.ts new file mode 100644 index 000000000..64a7b00fc --- /dev/null +++ b/apps/peertube-runner/src/server/process/index.ts @@ -0,0 +1,2 @@ +export * from './shared/index.js' +export * from './process.js' diff --git a/packages/peertube-runner/server/process/process.ts b/apps/peertube-runner/src/server/process/process.ts similarity index 90% rename from packages/peertube-runner/server/process/process.ts rename to apps/peertube-runner/src/server/process/process.ts index 1caafda8c..e8a1d7c28 100644 --- a/packages/peertube-runner/server/process/process.ts +++ b/apps/peertube-runner/src/server/process/process.ts @@ -1,14 +1,14 @@ -import { logger } from 'packages/peertube-runner/shared/logger' import { RunnerJobLiveRTMPHLSTranscodingPayload, RunnerJobStudioTranscodingPayload, RunnerJobVODAudioMergeTranscodingPayload, RunnerJobVODHLSTranscodingPayload, RunnerJobVODWebVideoTranscodingPayload -} from '@shared/models' -import { processAudioMergeTranscoding, processHLSTranscoding, ProcessOptions, processWebVideoTranscoding } from './shared' -import { ProcessLiveRTMPHLSTranscoding } from './shared/process-live' -import { processStudioTranscoding } from './shared/process-studio' +} from '@peertube/peertube-models' +import { logger } from '../../shared/index.js' +import { processAudioMergeTranscoding, processHLSTranscoding, ProcessOptions, processWebVideoTranscoding } from './shared/index.js' +import { ProcessLiveRTMPHLSTranscoding } from './shared/process-live.js' +import { processStudioTranscoding } from './shared/process-studio.js' export async function processJob (options: ProcessOptions) { const { server, job } = options diff --git a/packages/peertube-runner/server/process/shared/common.ts b/apps/peertube-runner/src/server/process/shared/common.ts similarity index 84% rename from packages/peertube-runner/server/process/shared/common.ts rename to apps/peertube-runner/src/server/process/shared/common.ts index a9b37bbc4..09241d93b 100644 --- a/packages/peertube-runner/server/process/shared/common.ts +++ b/apps/peertube-runner/src/server/process/shared/common.ts @@ -1,11 +1,11 @@ -import { remove } from 'fs-extra' -import { ConfigManager, downloadFile, logger } from 'packages/peertube-runner/shared' +import { remove } from 'fs-extra/esm' import { join } from 'path' -import { buildUUID } from '@shared/extra-utils' -import { FFmpegEdition, FFmpegLive, FFmpegVOD, getDefaultAvailableEncoders, getDefaultEncodersToTry } from '@shared/ffmpeg' -import { RunnerJob, RunnerJobPayload } from '@shared/models' -import { PeerTubeServer } from '@shared/server-commands' -import { getTranscodingLogger } from './transcoding-logger' +import { FFmpegEdition, FFmpegLive, FFmpegVOD, getDefaultAvailableEncoders, getDefaultEncodersToTry } from '@peertube/peertube-ffmpeg' +import { RunnerJob, RunnerJobPayload } from '@peertube/peertube-models' +import { buildUUID } from '@peertube/peertube-node-utils' +import { PeerTubeServer } from '@peertube/peertube-server-commands' +import { ConfigManager, downloadFile, logger } from '../../../shared/index.js' +import { getTranscodingLogger } from './transcoding-logger.js' export type JobWithToken = RunnerJob & { jobToken: string } diff --git a/apps/peertube-runner/src/server/process/shared/index.ts b/apps/peertube-runner/src/server/process/shared/index.ts new file mode 100644 index 000000000..638bf127f --- /dev/null +++ b/apps/peertube-runner/src/server/process/shared/index.ts @@ -0,0 +1,3 @@ +export * from './common.js' +export * from './process-vod.js' +export * from './transcoding-logger.js' diff --git a/packages/peertube-runner/server/process/shared/process-live.ts b/apps/peertube-runner/src/server/process/shared/process-live.ts similarity index 95% rename from packages/peertube-runner/server/process/shared/process-live.ts rename to apps/peertube-runner/src/server/process/shared/process-live.ts index e1fc0e34e..0dc4e5b13 100644 --- a/packages/peertube-runner/server/process/shared/process-live.ts +++ b/apps/peertube-runner/src/server/process/shared/process-live.ts @@ -1,20 +1,20 @@ import { FSWatcher, watch } from 'chokidar' import { FfmpegCommand } from 'fluent-ffmpeg' -import { ensureDir, remove } from 'fs-extra' -import { logger } from 'packages/peertube-runner/shared' +import { ensureDir, remove } from 'fs-extra/esm' import { basename, join } from 'path' -import { wait } from '@shared/core-utils' -import { buildUUID } from '@shared/extra-utils' -import { ffprobePromise, getVideoStreamBitrate, getVideoStreamDimensionsInfo, hasAudioStream } from '@shared/ffmpeg' +import { wait } from '@peertube/peertube-core-utils' +import { ffprobePromise, getVideoStreamBitrate, getVideoStreamDimensionsInfo, hasAudioStream } from '@peertube/peertube-ffmpeg' import { LiveRTMPHLSTranscodingSuccess, LiveRTMPHLSTranscodingUpdatePayload, PeerTubeProblemDocument, RunnerJobLiveRTMPHLSTranscodingPayload, ServerErrorCode -} from '@shared/models' -import { ConfigManager } from '../../../shared/config-manager' -import { buildFFmpegLive, ProcessOptions } from './common' +} from '@peertube/peertube-models' +import { buildUUID } from '@peertube/peertube-node-utils' +import { ConfigManager } from '../../../shared/config-manager.js' +import { logger } from '../../../shared/index.js' +import { buildFFmpegLive, ProcessOptions } from './common.js' export class ProcessLiveRTMPHLSTranscoding { diff --git a/packages/peertube-runner/server/process/shared/process-studio.ts b/apps/peertube-runner/src/server/process/shared/process-studio.ts similarity index 92% rename from packages/peertube-runner/server/process/shared/process-studio.ts rename to apps/peertube-runner/src/server/process/shared/process-studio.ts index 7bb209e80..11b7b7d9a 100644 --- a/packages/peertube-runner/server/process/shared/process-studio.ts +++ b/apps/peertube-runner/src/server/process/shared/process-studio.ts @@ -1,8 +1,6 @@ -import { remove } from 'fs-extra' -import { logger } from 'packages/peertube-runner/shared' +import { remove } from 'fs-extra/esm' import { join } from 'path' -import { pick } from '@shared/core-utils' -import { buildUUID } from '@shared/extra-utils' +import { pick } from '@peertube/peertube-core-utils' import { RunnerJobStudioTranscodingPayload, VideoStudioTask, @@ -12,9 +10,11 @@ import { VideoStudioTaskPayload, VideoStudioTaskWatermarkPayload, VideoStudioTranscodingSuccess -} from '@shared/models' -import { ConfigManager } from '../../../shared/config-manager' -import { buildFFmpegEdition, downloadInputFile, JobWithToken, ProcessOptions, scheduleTranscodingProgress } from './common' +} from '@peertube/peertube-models' +import { buildUUID } from '@peertube/peertube-node-utils' +import { ConfigManager } from '../../../shared/config-manager.js' +import { logger } from '../../../shared/index.js' +import { buildFFmpegEdition, downloadInputFile, JobWithToken, ProcessOptions, scheduleTranscodingProgress } from './common.js' export async function processStudioTranscoding (options: ProcessOptions) { const { server, job, runnerToken } = options diff --git a/packages/peertube-runner/server/process/shared/process-vod.ts b/apps/peertube-runner/src/server/process/shared/process-vod.ts similarity index 95% rename from packages/peertube-runner/server/process/shared/process-vod.ts rename to apps/peertube-runner/src/server/process/shared/process-vod.ts index f7c076b27..fe1715ca9 100644 --- a/packages/peertube-runner/server/process/shared/process-vod.ts +++ b/apps/peertube-runner/src/server/process/shared/process-vod.ts @@ -1,7 +1,5 @@ -import { remove } from 'fs-extra' -import { logger } from 'packages/peertube-runner/shared' +import { remove } from 'fs-extra/esm' import { join } from 'path' -import { buildUUID } from '@shared/extra-utils' import { RunnerJobVODAudioMergeTranscodingPayload, RunnerJobVODHLSTranscodingPayload, @@ -9,9 +7,11 @@ import { VODAudioMergeTranscodingSuccess, VODHLSTranscodingSuccess, VODWebVideoTranscodingSuccess -} from '@shared/models' -import { ConfigManager } from '../../../shared/config-manager' -import { buildFFmpegVOD, downloadInputFile, ProcessOptions, scheduleTranscodingProgress } from './common' +} from '@peertube/peertube-models' +import { buildUUID } from '@peertube/peertube-node-utils' +import { ConfigManager } from '../../../shared/config-manager.js' +import { logger } from '../../../shared/index.js' +import { buildFFmpegVOD, downloadInputFile, ProcessOptions, scheduleTranscodingProgress } from './common.js' export async function processWebVideoTranscoding (options: ProcessOptions) { const { server, job, runnerToken } = options diff --git a/packages/peertube-runner/server/process/shared/transcoding-logger.ts b/apps/peertube-runner/src/server/process/shared/transcoding-logger.ts similarity index 76% rename from packages/peertube-runner/server/process/shared/transcoding-logger.ts rename to apps/peertube-runner/src/server/process/shared/transcoding-logger.ts index d0f928914..041dd62eb 100644 --- a/packages/peertube-runner/server/process/shared/transcoding-logger.ts +++ b/apps/peertube-runner/src/server/process/shared/transcoding-logger.ts @@ -1,4 +1,4 @@ -import { logger } from 'packages/peertube-runner/shared/logger' +import { logger } from '../../../shared/index.js' export function getTranscodingLogger () { return { diff --git a/packages/peertube-runner/server/server.ts b/apps/peertube-runner/src/server/server.ts similarity index 93% rename from packages/peertube-runner/server/server.ts rename to apps/peertube-runner/src/server/server.ts index 5fa86fa1a..825e3f297 100644 --- a/packages/peertube-runner/server/server.ts +++ b/apps/peertube-runner/src/server/server.ts @@ -1,14 +1,15 @@ -import { ensureDir, readdir, remove } from 'fs-extra' +import { ensureDir, remove } from 'fs-extra/esm' +import { readdir } from 'fs/promises' import { join } from 'path' import { io, Socket } from 'socket.io-client' -import { pick, shuffle, wait } from '@shared/core-utils' -import { PeerTubeProblemDocument, ServerErrorCode } from '@shared/models' -import { PeerTubeServer as PeerTubeServerCommand } from '@shared/server-commands' -import { ConfigManager } from '../shared' -import { IPCServer } from '../shared/ipc' -import { logger } from '../shared/logger' -import { JobWithToken, processJob } from './process' -import { isJobSupported } from './shared' +import { pick, shuffle, wait } from '@peertube/peertube-core-utils' +import { PeerTubeProblemDocument, ServerErrorCode } from '@peertube/peertube-models' +import { PeerTubeServer as PeerTubeServerCommand } from '@peertube/peertube-server-commands' +import { ConfigManager } from '../shared/index.js' +import { IPCServer } from '../shared/ipc/index.js' +import { logger } from '../shared/logger.js' +import { JobWithToken, processJob } from './process/index.js' +import { isJobSupported } from './shared/index.js' type PeerTubeServer = PeerTubeServerCommand & { runnerToken: string diff --git a/apps/peertube-runner/src/server/shared/index.ts b/apps/peertube-runner/src/server/shared/index.ts new file mode 100644 index 000000000..34d51196b --- /dev/null +++ b/apps/peertube-runner/src/server/shared/index.ts @@ -0,0 +1 @@ +export * from './supported-job.js' diff --git a/packages/peertube-runner/server/shared/supported-job.ts b/apps/peertube-runner/src/server/shared/supported-job.ts similarity index 97% rename from packages/peertube-runner/server/shared/supported-job.ts rename to apps/peertube-runner/src/server/shared/supported-job.ts index 1137d8206..d905b5de2 100644 --- a/packages/peertube-runner/server/shared/supported-job.ts +++ b/apps/peertube-runner/src/server/shared/supported-job.ts @@ -7,7 +7,7 @@ import { RunnerJobVODHLSTranscodingPayload, RunnerJobVODWebVideoTranscodingPayload, VideoStudioTaskPayload -} from '@shared/models' +} from '@peertube/peertube-models' const supportedMatrix = { 'vod-web-video-transcoding': (_payload: RunnerJobVODWebVideoTranscodingPayload) => { diff --git a/packages/peertube-runner/shared/config-manager.ts b/apps/peertube-runner/src/shared/config-manager.ts similarity index 94% rename from packages/peertube-runner/shared/config-manager.ts rename to apps/peertube-runner/src/shared/config-manager.ts index 548eeab85..84a326a16 100644 --- a/packages/peertube-runner/shared/config-manager.ts +++ b/apps/peertube-runner/src/shared/config-manager.ts @@ -1,9 +1,10 @@ -import envPaths from 'env-paths' -import { ensureDir, pathExists, readFile, remove, writeFile } from 'fs-extra' -import { merge } from 'lodash' -import { logger } from 'packages/peertube-runner/shared/logger' -import { dirname, join } from 'path' import { parse, stringify } from '@iarna/toml' +import envPaths from 'env-paths' +import { ensureDir, pathExists, remove } from 'fs-extra/esm' +import { readFile, writeFile } from 'fs/promises' +import merge from 'lodash-es/merge.js' +import { dirname, join } from 'path' +import { logger } from '../shared/index.js' const paths = envPaths('peertube-runner') diff --git a/packages/peertube-runner/shared/http.ts b/apps/peertube-runner/src/shared/http.ts similarity index 92% rename from packages/peertube-runner/shared/http.ts rename to apps/peertube-runner/src/shared/http.ts index df64dc168..42886279c 100644 --- a/packages/peertube-runner/shared/http.ts +++ b/apps/peertube-runner/src/shared/http.ts @@ -1,7 +1,8 @@ -import { createWriteStream, remove } from 'fs-extra' +import { createWriteStream } from 'fs' +import { remove } from 'fs-extra/esm' import { request as requestHTTP } from 'http' import { request as requestHTTPS, RequestOptions } from 'https' -import { logger } from './logger' +import { logger } from './logger.js' export function downloadFile (options: { url: string diff --git a/apps/peertube-runner/src/shared/index.ts b/apps/peertube-runner/src/shared/index.ts new file mode 100644 index 000000000..951eef55b --- /dev/null +++ b/apps/peertube-runner/src/shared/index.ts @@ -0,0 +1,3 @@ +export * from './config-manager.js' +export * from './http.js' +export * from './logger.js' diff --git a/apps/peertube-runner/src/shared/ipc/index.ts b/apps/peertube-runner/src/shared/ipc/index.ts new file mode 100644 index 000000000..337d4de16 --- /dev/null +++ b/apps/peertube-runner/src/shared/ipc/index.ts @@ -0,0 +1,2 @@ +export * from './ipc-client.js' +export * from './ipc-server.js' diff --git a/packages/peertube-runner/shared/ipc/ipc-client.ts b/apps/peertube-runner/src/shared/ipc/ipc-client.ts similarity index 95% rename from packages/peertube-runner/shared/ipc/ipc-client.ts rename to apps/peertube-runner/src/shared/ipc/ipc-client.ts index f8e72f97f..aa5740dd1 100644 --- a/packages/peertube-runner/shared/ipc/ipc-client.ts +++ b/apps/peertube-runner/src/shared/ipc/ipc-client.ts @@ -1,8 +1,8 @@ import CliTable3 from 'cli-table3' -import { ensureDir } from 'fs-extra' +import { ensureDir } from 'fs-extra/esm' import { Client as NetIPC } from 'net-ipc' -import { ConfigManager } from '../config-manager' -import { IPCReponse, IPCReponseData, IPCRequest } from './shared' +import { ConfigManager } from '../config-manager.js' +import { IPCReponse, IPCReponseData, IPCRequest } from './shared/index.js' export class IPCClient { private netIPC: NetIPC diff --git a/packages/peertube-runner/shared/ipc/ipc-server.ts b/apps/peertube-runner/src/shared/ipc/ipc-server.ts similarity index 87% rename from packages/peertube-runner/shared/ipc/ipc-server.ts rename to apps/peertube-runner/src/shared/ipc/ipc-server.ts index 4b67d01ae..c68438504 100644 --- a/packages/peertube-runner/shared/ipc/ipc-server.ts +++ b/apps/peertube-runner/src/shared/ipc/ipc-server.ts @@ -1,10 +1,10 @@ -import { ensureDir } from 'fs-extra' +import { ensureDir } from 'fs-extra/esm' import { Server as NetIPC } from 'net-ipc' -import { pick } from '@shared/core-utils' -import { RunnerServer } from '../../server' -import { ConfigManager } from '../config-manager' -import { logger } from '../logger' -import { IPCReponse, IPCReponseData, IPCRequest } from './shared' +import { pick } from '@peertube/peertube-core-utils' +import { RunnerServer } from '../../server/index.js' +import { ConfigManager } from '../config-manager.js' +import { logger } from '../logger.js' +import { IPCReponse, IPCReponseData, IPCRequest } from './shared/index.js' export class IPCServer { private netIPC: NetIPC diff --git a/apps/peertube-runner/src/shared/ipc/shared/index.ts b/apps/peertube-runner/src/shared/ipc/shared/index.ts new file mode 100644 index 000000000..986acafb0 --- /dev/null +++ b/apps/peertube-runner/src/shared/ipc/shared/index.ts @@ -0,0 +1,2 @@ +export * from './ipc-request.model.js' +export * from './ipc-response.model.js' diff --git a/packages/peertube-runner/shared/ipc/shared/ipc-request.model.ts b/apps/peertube-runner/src/shared/ipc/shared/ipc-request.model.ts similarity index 100% rename from packages/peertube-runner/shared/ipc/shared/ipc-request.model.ts rename to apps/peertube-runner/src/shared/ipc/shared/ipc-request.model.ts diff --git a/packages/peertube-runner/shared/ipc/shared/ipc-response.model.ts b/apps/peertube-runner/src/shared/ipc/shared/ipc-response.model.ts similarity index 100% rename from packages/peertube-runner/shared/ipc/shared/ipc-response.model.ts rename to apps/peertube-runner/src/shared/ipc/shared/ipc-response.model.ts diff --git a/packages/peertube-runner/shared/logger.ts b/apps/peertube-runner/src/shared/logger.ts similarity index 77% rename from packages/peertube-runner/shared/logger.ts rename to apps/peertube-runner/src/shared/logger.ts index bf0f41828..ef5283892 100644 --- a/packages/peertube-runner/shared/logger.ts +++ b/apps/peertube-runner/src/shared/logger.ts @@ -1,7 +1,7 @@ import { pino } from 'pino' import pretty from 'pino-pretty' -const logger = pino(pretty({ +const logger = pino(pretty.default({ colorize: true })) diff --git a/apps/peertube-runner/tsconfig.json b/apps/peertube-runner/tsconfig.json new file mode 100644 index 000000000..03660b0eb --- /dev/null +++ b/apps/peertube-runner/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "baseUrl": "./", + "outDir": "./dist", + "rootDir": "src", + "tsBuildInfoFile": "./dist/.tsbuildinfo" + }, + "references": [ + { "path": "../../packages/core-utils" }, + { "path": "../../packages/ffmpeg" }, + { "path": "../../packages/models" }, + { "path": "../../packages/node-utils" }, + { "path": "../../packages/server-commands" } + ] +} diff --git a/packages/peertube-runner/yarn.lock b/apps/peertube-runner/yarn.lock similarity index 100% rename from packages/peertube-runner/yarn.lock rename to apps/peertube-runner/yarn.lock diff --git a/client/.eslintrc.json b/client/.eslintrc.json index c5685b9dc..e4c8d901b 100644 --- a/client/.eslintrc.json +++ b/client/.eslintrc.json @@ -14,6 +14,7 @@ "project": [ "tsconfig.eslint.json" ], + "EXPERIMENTAL_useSourceOfProjectReferenceRedirect": true, "createDefaultProgram": false }, "extends": [ diff --git a/client/e2e/wdio.main.conf.ts b/client/e2e/wdio.main.conf.ts index 5ae7fa18b..8e6ef51cf 100644 --- a/client/e2e/wdio.main.conf.ts +++ b/client/e2e/wdio.main.conf.ts @@ -107,14 +107,6 @@ export const config = { tsNodeOpts: { project: require('path').join(__dirname, './tsconfig.json') - }, - - tsConfigPathsOpts: { - baseUrl: './', - paths: { - '@server/*': [ '../../server/*' ], - '@shared/*': [ '../../shared/*' ] - } } }, diff --git a/client/package.json b/client/package.json index 149322192..9c311622b 100644 --- a/client/package.json +++ b/client/package.json @@ -14,7 +14,7 @@ }, "scripts": { "lint": "npm run lint-ts && npm run lint-scss", - "lint-ts": "eslint --ext .ts src/standalone/**/*.ts && npm run ng lint", + "lint-ts": "eslint --cache --ext .ts src/standalone/**/*.ts && npm run ng lint", "lint-scss": "stylelint 'src/**/*.scss'", "webpack": "webpack", "eslint": "eslint", @@ -24,6 +24,9 @@ "ngx-extractor": "ngx-extractor", "stylelint": "stylelint" }, + "workspaces": [ + "../packages/*" + ], "typings": "*.d.ts", "devDependencies": { "@angular-devkit/build-angular": "^16.0.2", @@ -57,6 +60,8 @@ "@peertube/maildev": "^1.2.0", "@peertube/p2p-media-loader-core": "^1.0.14", "@peertube/p2p-media-loader-hlsjs": "^1.0.14", + "@peertube/peertube-core-utils": "*", + "@peertube/peertube-models": "*", "@peertube/videojs-contextmenu": "^5.5.0", "@peertube/xliffmerge": "^2.0.3", "@popperjs/core": "^2.11.5", @@ -86,7 +91,7 @@ "buffer": "^6.0.3", "chart.js": "^4.3.0", "chartjs-plugin-zoom": "~2.0.1", - "chromedriver": "^113.0.0", + "chromedriver": "^115.0.1", "core-js": "^3.22.8", "css-loader": "^6.2.0", "debug": "^4.3.1", @@ -122,6 +127,7 @@ "stylelint": "^15.1.0", "stylelint-config-sass-guidelines": "^10.0.0", "ts-loader": "^9.3.0", + "ts-node": "^10.9.1", "tslib": "^2.4.0", "typescript": "~4.9.5", "video.js": "^7.19.2", diff --git a/client/src/app/+about/about-follows/about-follows.component.ts b/client/src/app/+about/about-follows/about-follows.component.ts index e1df8b813..a542cdbf1 100644 --- a/client/src/app/+about/about-follows/about-follows.component.ts +++ b/client/src/app/+about/about-follows/about-follows.component.ts @@ -2,7 +2,7 @@ import { SortMeta } from 'primeng/api' import { Component, OnInit } from '@angular/core' import { ComponentPagination, hasMoreItems, Notifier, RestService, ServerService } from '@app/core' import { InstanceFollowService } from '@app/shared/shared-instance' -import { Actor } from '@shared/models/actors' +import { Actor } from '@peertube/peertube-models' @Component({ selector: 'my-about-follows', diff --git a/client/src/app/+about/about-instance/about-instance.component.ts b/client/src/app/+about/about-instance/about-instance.component.ts index fc5214215..85e973d7b 100644 --- a/client/src/app/+about/about-instance/about-instance.component.ts +++ b/client/src/app/+about/about-instance/about-instance.component.ts @@ -3,8 +3,8 @@ import { AfterViewChecked, Component, ElementRef, OnInit, ViewChild } from '@ang import { ActivatedRoute } from '@angular/router' import { Notifier, ServerService } from '@app/core' import { AboutHTML } from '@app/shared/shared-instance' +import { HTMLServerConfig, ServerStats } from '@peertube/peertube-models' import { copyToClipboard } from '@root-helpers/utils' -import { HTMLServerConfig, ServerStats } from '@shared/models/server' import { ResolverData } from './about-instance.resolver' import { ContactAdminModalComponent } from './contact-admin-modal.component' diff --git a/client/src/app/+about/about-instance/about-instance.resolver.ts b/client/src/app/+about/about-instance/about-instance.resolver.ts index f52a95b88..b5e8ccaa2 100644 --- a/client/src/app/+about/about-instance/about-instance.resolver.ts +++ b/client/src/app/+about/about-instance/about-instance.resolver.ts @@ -4,7 +4,7 @@ import { Injectable } from '@angular/core' import { ServerService } from '@app/core' import { CustomMarkupService } from '@app/shared/shared-custom-markup' import { AboutHTML, InstanceService } from '@app/shared/shared-instance' -import { About, ServerStats } from '@shared/models/server' +import { About, ServerStats } from '@peertube/peertube-models' export type ResolverData = { serverStats: ServerStats diff --git a/client/src/app/+about/about-instance/contact-admin-modal.component.ts b/client/src/app/+about/about-instance/contact-admin-modal.component.ts index 0e2bf51e8..38e577fcd 100644 --- a/client/src/app/+about/about-instance/contact-admin-modal.component.ts +++ b/client/src/app/+about/about-instance/contact-admin-modal.component.ts @@ -11,7 +11,7 @@ import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' import { InstanceService } from '@app/shared/shared-instance' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' -import { HTMLServerConfig, HttpStatusCode } from '@shared/models' +import { HTMLServerConfig, HttpStatusCode } from '@peertube/peertube-models' type Prefill = { subject?: string diff --git a/client/src/app/+about/about-instance/instance-statistics.component.ts b/client/src/app/+about/about-instance/instance-statistics.component.ts index ac6984438..9eb56d0a4 100644 --- a/client/src/app/+about/about-instance/instance-statistics.component.ts +++ b/client/src/app/+about/about-instance/instance-statistics.component.ts @@ -1,5 +1,5 @@ import { Component, Input } from '@angular/core' -import { ServerStats } from '@shared/models/server' +import { ServerStats } from '@peertube/peertube-models' @Component({ selector: 'my-instance-statistics', diff --git a/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts b/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts index 2ee168492..b8afa66ff 100644 --- a/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts +++ b/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts @@ -5,7 +5,7 @@ import { ComponentPagination, hasMoreItems, MarkdownService, User, UserService } import { SimpleMemoize } from '@app/helpers' import { Account, AccountService, Video, VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main' import { MiniatureDisplayOptions } from '@app/shared/shared-video-miniature' -import { NSFWPolicyType, VideoSortField } from '@shared/models' +import { NSFWPolicyType, VideoSortField } from '@peertube/peertube-models' @Component({ selector: 'my-account-video-channels', diff --git a/client/src/app/+accounts/account-videos/account-videos.component.ts b/client/src/app/+accounts/account-videos/account-videos.component.ts index 13d1f857d..d8e8377e1 100644 --- a/client/src/app/+accounts/account-videos/account-videos.component.ts +++ b/client/src/app/+accounts/account-videos/account-videos.component.ts @@ -4,7 +4,7 @@ import { Component, OnDestroy, OnInit } from '@angular/core' import { ComponentPaginationLight, DisableForReuseHook, ScreenService } from '@app/core' import { Account, AccountService, VideoService } from '@app/shared/shared-main' import { VideoFilters } from '@app/shared/shared-video-miniature' -import { VideoSortField } from '@shared/models' +import { VideoSortField } from '@peertube/peertube-models' @Component({ selector: 'my-account-videos', diff --git a/client/src/app/+accounts/accounts.component.ts b/client/src/app/+accounts/accounts.component.ts index 6d912e325..156f35804 100644 --- a/client/src/app/+accounts/accounts.component.ts +++ b/client/src/app/+accounts/accounts.component.ts @@ -13,7 +13,7 @@ import { VideoService } from '@app/shared/shared-main' import { AccountReportComponent, BlocklistService } from '@app/shared/shared-moderation' -import { HttpStatusCode, User, UserRight } from '@shared/models' +import { HttpStatusCode, User, UserRight } from '@peertube/peertube-models' @Component({ templateUrl: './accounts.component.html', diff --git a/client/src/app/+admin/admin.component.ts b/client/src/app/+admin/admin.component.ts index 49092ea2a..c0d7db99e 100644 --- a/client/src/app/+admin/admin.component.ts +++ b/client/src/app/+admin/admin.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core' import { AuthService, ScreenService, ServerService } from '@app/core' import { ListOverflowItem } from '@app/shared/shared-main' import { TopMenuDropdownParam } from '@app/shared/shared-main/misc/top-menu-dropdown.component' -import { UserRight } from '@shared/models' +import { UserRight } from '@peertube/peertube-models' @Component({ templateUrl: './admin.component.html', diff --git a/client/src/app/+admin/config/config.routes.ts b/client/src/app/+admin/config/config.routes.ts index 6d255ac46..96a4f3771 100644 --- a/client/src/app/+admin/config/config.routes.ts +++ b/client/src/app/+admin/config/config.routes.ts @@ -1,7 +1,7 @@ import { Routes } from '@angular/router' import { EditCustomConfigComponent } from '@app/+admin/config/edit-custom-config' import { UserRightGuard } from '@app/core' -import { UserRight } from '@shared/models' +import { UserRight } from '@peertube/peertube-models' export const ConfigRoutes: Routes = [ { diff --git a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts index 2122e67b2..953c7d540 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts @@ -3,7 +3,7 @@ import { SelectOptionsItem } from 'src/types/select-options-item.model' import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core' import { FormGroup } from '@angular/forms' import { MenuService, ThemeService } from '@app/core' -import { HTMLServerConfig } from '@shared/models' +import { HTMLServerConfig } from '@peertube/peertube-models' import { ConfigService } from '../shared/config.service' @Component({ diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts index c3b85b196..54c076b74 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts @@ -27,7 +27,7 @@ import { import { USER_VIDEO_QUOTA_DAILY_VALIDATOR, USER_VIDEO_QUOTA_VALIDATOR } from '@app/shared/form-validators/user-validators' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' import { CustomPageService } from '@app/shared/shared-main/custom-page' -import { CustomConfig, CustomPage, HTMLServerConfig } from '@shared/models' +import { CustomConfig, CustomPage, HTMLServerConfig } from '@peertube/peertube-models' import { EditConfigurationService } from './edit-configuration.service' type ComponentCustomConfig = CustomConfig & { diff --git a/client/src/app/+admin/config/edit-custom-config/edit-live-configuration.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-live-configuration.component.ts index 1d1fecf90..59629aa20 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-live-configuration.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-live-configuration.component.ts @@ -2,7 +2,7 @@ import { SelectOptionsItem } from 'src/types/select-options-item.model' import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core' import { FormGroup } from '@angular/forms' -import { HTMLServerConfig } from '@shared/models' +import { HTMLServerConfig } from '@peertube/peertube-models' import { ConfigService } from '../shared/config.service' import { EditConfigurationService, ResolutionOption } from './edit-configuration.service' diff --git a/client/src/app/+admin/config/edit-custom-config/edit-vod-transcoding.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-vod-transcoding.component.ts index 6496e8753..a2cd04396 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-vod-transcoding.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-vod-transcoding.component.ts @@ -2,7 +2,7 @@ import { SelectOptionsItem } from 'src/types/select-options-item.model' import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core' import { FormGroup } from '@angular/forms' -import { HTMLServerConfig } from '@shared/models' +import { HTMLServerConfig } from '@peertube/peertube-models' import { ConfigService } from '../shared/config.service' import { EditConfigurationService, ResolutionOption } from './edit-configuration.service' diff --git a/client/src/app/+admin/config/shared/config.service.ts b/client/src/app/+admin/config/shared/config.service.ts index 80f495b41..3c3894945 100644 --- a/client/src/app/+admin/config/shared/config.service.ts +++ b/client/src/app/+admin/config/shared/config.service.ts @@ -2,7 +2,7 @@ import { catchError } from 'rxjs/operators' import { HttpClient } from '@angular/common/http' import { Injectable } from '@angular/core' import { RestExtractor } from '@app/core' -import { CustomConfig } from '@shared/models' +import { CustomConfig } from '@peertube/peertube-models' import { SelectOptionsItem } from '../../../../types/select-options-item.model' import { environment } from '../../../../environments/environment' diff --git a/client/src/app/+admin/follows/followers-list/followers-list.component.ts b/client/src/app/+admin/follows/followers-list/followers-list.component.ts index 618892242..656a7bf87 100644 --- a/client/src/app/+admin/follows/followers-list/followers-list.component.ts +++ b/client/src/app/+admin/follows/followers-list/followers-list.component.ts @@ -5,7 +5,7 @@ import { formatICU } from '@app/helpers' import { AdvancedInputFilter } from '@app/shared/shared-forms' import { InstanceFollowService } from '@app/shared/shared-instance' import { DropdownAction } from '@app/shared/shared-main' -import { ActorFollow } from '@shared/models' +import { ActorFollow } from '@peertube/peertube-models' @Component({ selector: 'my-followers-list', diff --git a/client/src/app/+admin/follows/following-list/following-list.component.ts b/client/src/app/+admin/follows/following-list/following-list.component.ts index 6c8723c16..da6647f6b 100644 --- a/client/src/app/+admin/follows/following-list/following-list.component.ts +++ b/client/src/app/+admin/follows/following-list/following-list.component.ts @@ -3,7 +3,7 @@ import { Component, OnInit, ViewChild } from '@angular/core' import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core' import { AdvancedInputFilter } from '@app/shared/shared-forms' import { InstanceFollowService } from '@app/shared/shared-instance' -import { ActorFollow } from '@shared/models' +import { ActorFollow } from '@peertube/peertube-models' import { FollowModalComponent } from './follow-modal.component' import { DropdownAction } from '@app/shared/shared-main' import { formatICU } from '@app/helpers' diff --git a/client/src/app/+admin/follows/follows.routes.ts b/client/src/app/+admin/follows/follows.routes.ts index 718493dc7..e187f83ea 100644 --- a/client/src/app/+admin/follows/follows.routes.ts +++ b/client/src/app/+admin/follows/follows.routes.ts @@ -1,7 +1,7 @@ import { Routes } from '@angular/router' import { VideoRedundanciesListComponent } from '@app/+admin/follows/video-redundancies-list' import { UserRightGuard } from '@app/core' -import { UserRight } from '@shared/models' +import { UserRight } from '@peertube/peertube-models' import { FollowersListComponent } from './followers-list' import { FollowingListComponent } from './following-list/following-list.component' diff --git a/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts b/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts index efcefd509..09fc038ce 100644 --- a/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts +++ b/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts @@ -3,9 +3,8 @@ import { SortMeta } from 'primeng/api' import { Component, OnInit } from '@angular/core' import { ConfirmService, Notifier, RestPagination, RestTable, ServerService } from '@app/core' import { BytesPipe, RedundancyService } from '@app/shared/shared-main' +import { VideoRedundanciesTarget, VideoRedundancy, VideosRedundancyStats } from '@peertube/peertube-models' import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' -import { VideoRedundanciesTarget, VideoRedundancy } from '@shared/models' -import { VideosRedundancyStats } from '@shared/models/server' @Component({ selector: 'my-video-redundancies-list', diff --git a/client/src/app/+admin/follows/video-redundancies-list/video-redundancy-information.component.ts b/client/src/app/+admin/follows/video-redundancies-list/video-redundancy-information.component.ts index 6f3090c08..779d19059 100644 --- a/client/src/app/+admin/follows/video-redundancies-list/video-redundancy-information.component.ts +++ b/client/src/app/+admin/follows/video-redundancies-list/video-redundancy-information.component.ts @@ -1,5 +1,5 @@ import { Component, Input } from '@angular/core' -import { FileRedundancyInformation, StreamingPlaylistRedundancyInformation } from '@shared/models' +import { FileRedundancyInformation, StreamingPlaylistRedundancyInformation } from '@peertube/peertube-models' @Component({ selector: 'my-video-redundancy-information', diff --git a/client/src/app/+admin/moderation/moderation.routes.ts b/client/src/app/+admin/moderation/moderation.routes.ts index 378d2bed7..f0494de7b 100644 --- a/client/src/app/+admin/moderation/moderation.routes.ts +++ b/client/src/app/+admin/moderation/moderation.routes.ts @@ -3,7 +3,7 @@ import { AbuseListComponent } from '@app/+admin/moderation/abuse-list' import { InstanceAccountBlocklistComponent, InstanceServerBlocklistComponent } from '@app/+admin/moderation/instance-blocklist' import { VideoBlockListComponent } from '@app/+admin/moderation/video-block-list' import { UserRightGuard } from '@app/core' -import { UserRight } from '@shared/models' +import { UserRight } from '@peertube/peertube-models' import { RegistrationListComponent } from './registration-list' export const ModerationRoutes: Routes = [ diff --git a/client/src/app/+admin/moderation/registration-list/admin-registration.service.ts b/client/src/app/+admin/moderation/registration-list/admin-registration.service.ts index a9f13cf2f..f8ab04c71 100644 --- a/client/src/app/+admin/moderation/registration-list/admin-registration.service.ts +++ b/client/src/app/+admin/moderation/registration-list/admin-registration.service.ts @@ -4,8 +4,8 @@ import { catchError, concatMap, toArray } from 'rxjs/operators' import { HttpClient, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' import { RestExtractor, RestPagination, RestService } from '@app/core' -import { arrayify } from '@shared/core-utils' -import { ResultList, UserRegistration, UserRegistrationUpdateState } from '@shared/models' +import { arrayify } from '@peertube/peertube-core-utils' +import { ResultList, UserRegistration, UserRegistrationUpdateState } from '@peertube/peertube-models' import { environment } from '../../../../environments/environment' @Injectable() diff --git a/client/src/app/+admin/moderation/registration-list/process-registration-modal.component.ts b/client/src/app/+admin/moderation/registration-list/process-registration-modal.component.ts index 8f013cbd5..f8e346f50 100644 --- a/client/src/app/+admin/moderation/registration-list/process-registration-modal.component.ts +++ b/client/src/app/+admin/moderation/registration-list/process-registration-modal.component.ts @@ -3,7 +3,7 @@ import { Notifier, ServerService } from '@app/core' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' -import { UserRegistration } from '@shared/models' +import { UserRegistration } from '@peertube/peertube-models' import { AdminRegistrationService } from './admin-registration.service' import { REGISTRATION_MODERATION_RESPONSE_VALIDATOR } from './process-registration-validators' diff --git a/client/src/app/+admin/moderation/registration-list/registration-list.component.ts b/client/src/app/+admin/moderation/registration-list/registration-list.component.ts index 35d9d13d7..1dc5e9077 100644 --- a/client/src/app/+admin/moderation/registration-list/registration-list.component.ts +++ b/client/src/app/+admin/moderation/registration-list/registration-list.component.ts @@ -5,7 +5,7 @@ import { ConfirmService, MarkdownService, Notifier, RestPagination, RestTable, S import { formatICU } from '@app/helpers' import { AdvancedInputFilter } from '@app/shared/shared-forms' import { DropdownAction } from '@app/shared/shared-main' -import { UserRegistration, UserRegistrationState } from '@shared/models' +import { UserRegistration, UserRegistrationState } from '@peertube/peertube-models' import { AdminRegistrationService } from './admin-registration.service' import { ProcessRegistrationModalComponent } from './process-registration-modal.component' diff --git a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts index f365a2500..3c6bda16c 100644 --- a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts +++ b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts @@ -7,9 +7,9 @@ import { ConfirmService, MarkdownService, Notifier, RestPagination, RestTable, S import { AdvancedInputFilter } from '@app/shared/shared-forms' import { DropdownAction, VideoService } from '@app/shared/shared-main' import { VideoBlockService } from '@app/shared/shared-moderation' +import { buildVideoEmbedLink, decorateVideoLink } from '@peertube/peertube-core-utils' +import { VideoBlacklist, VideoBlacklistType, VideoBlacklistType_Type } from '@peertube/peertube-models' import { buildVideoOrPlaylistEmbed } from '@root-helpers/video' -import { buildVideoEmbedLink, decorateVideoLink } from '@shared/core-utils' -import { VideoBlacklist, VideoBlacklistType } from '@shared/models' @Component({ selector: 'my-video-block-list', @@ -21,7 +21,7 @@ export class VideoBlockListComponent extends RestTable implements OnInit { totalRecords = 0 sort: SortMeta = { field: 'createdAt', order: -1 } pagination: RestPagination = { count: this.rowsPerPage, start: 0 } - blocklistTypeFilter: VideoBlacklistType = undefined + blocklistTypeFilter: VideoBlacklistType_Type videoBlocklistActions: DropdownAction[][] = [] diff --git a/client/src/app/+admin/overview/comments/video-comment-list.component.ts b/client/src/app/+admin/overview/comments/video-comment-list.component.ts index b77072665..254e76a60 100644 --- a/client/src/app/+admin/overview/comments/video-comment-list.component.ts +++ b/client/src/app/+admin/overview/comments/video-comment-list.component.ts @@ -6,7 +6,7 @@ import { AdvancedInputFilter } from '@app/shared/shared-forms' import { DropdownAction } from '@app/shared/shared-main' import { BulkService } from '@app/shared/shared-moderation' import { VideoCommentAdmin, VideoCommentService } from '@app/shared/shared-video-comment' -import { FeedFormat, UserRight } from '@shared/models' +import { FeedFormat, UserRight } from '@peertube/peertube-models' import { formatICU } from '@app/helpers' @Component({ diff --git a/client/src/app/+admin/overview/comments/video-comment.routes.ts b/client/src/app/+admin/overview/comments/video-comment.routes.ts index f0bd440ad..f67027430 100644 --- a/client/src/app/+admin/overview/comments/video-comment.routes.ts +++ b/client/src/app/+admin/overview/comments/video-comment.routes.ts @@ -1,6 +1,6 @@ import { Routes } from '@angular/router' import { UserRightGuard } from '@app/core' -import { UserRight } from '@shared/models' +import { UserRight } from '@peertube/peertube-models' import { VideoCommentListComponent } from './video-comment-list.component' export const commentRoutes: Routes = [ diff --git a/client/src/app/+admin/overview/users/user-edit/user-create.component.ts b/client/src/app/+admin/overview/users/user-edit/user-create.component.ts index 0627aa887..77acb9988 100644 --- a/client/src/app/+admin/overview/users/user-edit/user-create.component.ts +++ b/client/src/app/+admin/overview/users/user-edit/user-create.component.ts @@ -14,7 +14,7 @@ import { } from '@app/shared/form-validators/user-validators' import { FormReactiveService } from '@app/shared/shared-forms' import { UserAdminService } from '@app/shared/shared-users' -import { UserCreate, UserRole } from '@shared/models' +import { UserCreate, UserRole } from '@peertube/peertube-models' import { UserEdit } from './user-edit' @Component({ diff --git a/client/src/app/+admin/overview/users/user-edit/user-edit.ts b/client/src/app/+admin/overview/users/user-edit/user-edit.ts index 9547da2d1..d61b7b068 100644 --- a/client/src/app/+admin/overview/users/user-edit/user-edit.ts +++ b/client/src/app/+admin/overview/users/user-edit/user-edit.ts @@ -2,9 +2,8 @@ import { Directive, OnInit } from '@angular/core' import { ConfigService } from '@app/+admin/config/shared/config.service' import { AuthService, ScreenService, ServerService, User } from '@app/core' import { FormReactive } from '@app/shared/shared-forms' -import { peertubeTranslate } from '@shared/core-utils' -import { USER_ROLE_LABELS } from '@shared/core-utils/users' -import { HTMLServerConfig, UserAdminFlag, UserRole } from '@shared/models' +import { peertubeTranslate, USER_ROLE_LABELS } from '@peertube/peertube-core-utils' +import { HTMLServerConfig, UserAdminFlag, UserRole } from '@peertube/peertube-models' import { SelectOptionsItem } from '../../../../../types/select-options-item.model' @Directive() diff --git a/client/src/app/+admin/overview/users/user-edit/user-password.component.ts b/client/src/app/+admin/overview/users/user-edit/user-password.component.ts index ec93619f5..af39c82af 100644 --- a/client/src/app/+admin/overview/users/user-edit/user-password.component.ts +++ b/client/src/app/+admin/overview/users/user-edit/user-password.component.ts @@ -3,7 +3,7 @@ import { Notifier } from '@app/core' import { USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' import { UserAdminService } from '@app/shared/shared-users' -import { UserUpdate } from '@shared/models' +import { UserUpdate } from '@peertube/peertube-models' @Component({ selector: 'my-user-password', diff --git a/client/src/app/+admin/overview/users/user-edit/user-update.component.ts b/client/src/app/+admin/overview/users/user-edit/user-update.component.ts index 25d02f000..b55a519f3 100644 --- a/client/src/app/+admin/overview/users/user-edit/user-update.component.ts +++ b/client/src/app/+admin/overview/users/user-edit/user-update.component.ts @@ -11,7 +11,7 @@ import { } from '@app/shared/form-validators/user-validators' import { FormReactiveService } from '@app/shared/shared-forms' import { TwoFactorService, UserAdminService } from '@app/shared/shared-users' -import { User as UserType, UserAdminFlag, UserRole, UserUpdate } from '@shared/models' +import { User as UserType, UserAdminFlag, UserRole, UserUpdate } from '@peertube/peertube-models' import { UserEdit } from './user-edit' @Component({ diff --git a/client/src/app/+admin/overview/users/user-list/user-list.component.ts b/client/src/app/+admin/overview/users/user-list/user-list.component.ts index 5d5abf6f4..a5a1552da 100644 --- a/client/src/app/+admin/overview/users/user-list/user-list.component.ts +++ b/client/src/app/+admin/overview/users/user-list/user-list.component.ts @@ -7,8 +7,8 @@ import { AdvancedInputFilter } from '@app/shared/shared-forms' import { Actor, DropdownAction } from '@app/shared/shared-main' import { AccountMutedStatus, BlocklistService, UserBanModalComponent, UserModerationDisplayType } from '@app/shared/shared-moderation' import { UserAdminService } from '@app/shared/shared-users' +import { User, UserRole, UserRoleType } from '@peertube/peertube-models' import { logger } from '@root-helpers/logger' -import { User, UserRole } from '@shared/models' type UserForList = User & { rawVideoQuota: number @@ -166,7 +166,7 @@ export class UserListComponent extends RestTable implements OnInit { return 'UserListComponent' } - getRoleClass (role: UserRole) { + getRoleClass (role: UserRoleType) { switch (role) { case UserRole.ADMINISTRATOR: return 'badge-purple' diff --git a/client/src/app/+admin/overview/users/users.routes.ts b/client/src/app/+admin/overview/users/users.routes.ts index c9724e5fb..d66b8c762 100644 --- a/client/src/app/+admin/overview/users/users.routes.ts +++ b/client/src/app/+admin/overview/users/users.routes.ts @@ -1,6 +1,6 @@ import { Routes } from '@angular/router' import { UserRightGuard } from '@app/core' -import { UserRight } from '@shared/models' +import { UserRight } from '@peertube/peertube-models' import { UserCreateComponent, UserUpdateComponent } from './user-edit' import { UserListComponent } from './user-list' diff --git a/client/src/app/+admin/overview/videos/video-admin.service.ts b/client/src/app/+admin/overview/videos/video-admin.service.ts index 722495706..9b33ed8e5 100644 --- a/client/src/app/+admin/overview/videos/video-admin.service.ts +++ b/client/src/app/+admin/overview/videos/video-admin.service.ts @@ -5,8 +5,8 @@ import { Injectable } from '@angular/core' import { RestExtractor, RestPagination, RestService } from '@app/core' import { AdvancedInputFilter } from '@app/shared/shared-forms' import { CommonVideoParams, Video, VideoService } from '@app/shared/shared-main' -import { ResultList, VideoInclude, VideoPrivacy } from '@shared/models' -import { getAllPrivacies } from '@shared/core-utils' +import { ResultList, VideoInclude, VideoPrivacy } from '@peertube/peertube-models' +import { getAllPrivacies } from '@peertube/peertube-core-utils' @Injectable() export class VideoAdminService { diff --git a/client/src/app/+admin/overview/videos/video-list.component.ts b/client/src/app/+admin/overview/videos/video-list.component.ts index 2792a2d8a..2e12a2b31 100644 --- a/client/src/app/+admin/overview/videos/video-list.component.ts +++ b/client/src/app/+admin/overview/videos/video-list.component.ts @@ -8,8 +8,8 @@ import { AdvancedInputFilter } from '@app/shared/shared-forms' import { DropdownAction, Video, VideoService } from '@app/shared/shared-main' import { VideoBlockComponent, VideoBlockService } from '@app/shared/shared-moderation' import { VideoActionsDisplayType } from '@app/shared/shared-video-miniature' -import { getAllFiles } from '@shared/core-utils' -import { UserRight, VideoFile, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models' +import { getAllFiles } from '@peertube/peertube-core-utils' +import { UserRight, VideoFile, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@peertube/peertube-models' import { VideoAdminService } from './video-admin.service' @Component({ diff --git a/client/src/app/+admin/overview/videos/video.routes.ts b/client/src/app/+admin/overview/videos/video.routes.ts index 01cb5b497..dfffd2696 100644 --- a/client/src/app/+admin/overview/videos/video.routes.ts +++ b/client/src/app/+admin/overview/videos/video.routes.ts @@ -1,6 +1,6 @@ import { Routes } from '@angular/router' import { UserRightGuard } from '@app/core' -import { UserRight } from '@shared/models' +import { UserRight } from '@peertube/peertube-models' import { VideoListComponent } from './video-list.component' export const videosRoutes: Routes = [ diff --git a/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts b/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts index 3fa1c56dc..1b78a00cd 100644 --- a/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts +++ b/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts @@ -4,8 +4,8 @@ import { ActivatedRoute, Router } from '@angular/router' import { PluginApiService } from '@app/+admin/plugins/shared/plugin-api.service' import { ComponentPagination, ConfirmService, hasMoreItems, Notifier } from '@app/core' import { PluginService } from '@app/core/plugins/plugin.service' -import { compareSemVer } from '@shared/core-utils' -import { PeerTubePlugin, PluginType } from '@shared/models' +import { compareSemVer } from '@peertube/peertube-core-utils' +import { PeerTubePlugin, PluginType, PluginType_Type } from '@peertube/peertube-models' @Component({ selector: 'my-plugin-list-installed', @@ -13,7 +13,7 @@ import { PeerTubePlugin, PluginType } from '@shared/models' styleUrls: [ './plugin-list-installed.component.scss' ] }) export class PluginListInstalledComponent implements OnInit { - pluginType: PluginType + pluginType: PluginType_Type pagination: ComponentPagination = { currentPage: 1, @@ -48,7 +48,7 @@ export class PluginListInstalledComponent implements OnInit { this.route.queryParams.subscribe(query => { if (!query['pluginType']) return - this.pluginType = parseInt(query['pluginType'], 10) + this.pluginType = parseInt(query['pluginType'], 10) as PluginType_Type this.reloadPlugins() }) diff --git a/client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts b/client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts index c03e37aa5..5539d1c13 100644 --- a/client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts +++ b/client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts @@ -4,8 +4,8 @@ import { Component, OnInit } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' import { PluginApiService } from '@app/+admin/plugins/shared/plugin-api.service' import { ComponentPagination, ConfirmService, hasMoreItems, Notifier, PluginService } from '@app/core' +import { PeerTubePluginIndex, PluginType, PluginType_Type } from '@peertube/peertube-models' import { logger } from '@root-helpers/logger' -import { PeerTubePluginIndex, PluginType } from '@shared/models' @Component({ selector: 'my-plugin-search', @@ -13,7 +13,7 @@ import { PeerTubePluginIndex, PluginType } from '@shared/models' styleUrls: [ './plugin-search.component.scss' ] }) export class PluginSearchComponent implements OnInit { - pluginType: PluginType + pluginType: PluginType_Type pagination: ComponentPagination = { currentPage: 1, @@ -53,7 +53,7 @@ export class PluginSearchComponent implements OnInit { this.route.queryParams.subscribe(query => { if (!query['pluginType']) return - this.pluginType = parseInt(query['pluginType'], 10) + this.pluginType = parseInt(query['pluginType'], 10) as PluginType_Type this.search = query['search'] || '' this.reloadPlugins() diff --git a/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts b/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts index b1a41567e..9eee1a901 100644 --- a/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts +++ b/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts @@ -5,7 +5,7 @@ import { ActivatedRoute } from '@angular/router' import { HooksService, Notifier, PluginService } from '@app/core' import { BuildFormArgument } from '@app/shared/form-validators' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' -import { PeerTubePlugin, RegisterServerSettingOptions } from '@shared/models' +import { PeerTubePlugin, RegisterServerSettingOptions } from '@peertube/peertube-models' import { PluginApiService } from '../shared/plugin-api.service' @Component({ diff --git a/client/src/app/+admin/plugins/plugins.routes.ts b/client/src/app/+admin/plugins/plugins.routes.ts index f735a490b..40660f1f4 100644 --- a/client/src/app/+admin/plugins/plugins.routes.ts +++ b/client/src/app/+admin/plugins/plugins.routes.ts @@ -3,7 +3,7 @@ import { PluginListInstalledComponent } from '@app/+admin/plugins/plugin-list-in import { PluginSearchComponent } from '@app/+admin/plugins/plugin-search/plugin-search.component' import { PluginShowInstalledComponent } from '@app/+admin/plugins/plugin-show-installed/plugin-show-installed.component' import { UserRightGuard } from '@app/core' -import { UserRight } from '@shared/models' +import { UserRight } from '@peertube/peertube-models' export const PluginsRoutes: Routes = [ { diff --git a/client/src/app/+admin/plugins/shared/plugin-api.service.ts b/client/src/app/+admin/plugins/shared/plugin-api.service.ts index fbfdaea18..e1bd2f125 100644 --- a/client/src/app/+admin/plugins/shared/plugin-api.service.ts +++ b/client/src/app/+admin/plugins/shared/plugin-api.service.ts @@ -9,9 +9,10 @@ import { PeerTubePlugin, PeerTubePluginIndex, PluginType, + PluginType_Type, RegisteredServerSettings, ResultList -} from '@shared/models' +} from '@peertube/peertube-models' import { environment } from '../../../../environments/environment' @Injectable() @@ -25,7 +26,7 @@ export class PluginApiService { private pluginService: PluginService ) { } - getPluginTypeLabel (type: PluginType) { + getPluginTypeLabel (type: PluginType_Type) { if (type === PluginType.PLUGIN) { return $localize`plugin` } @@ -34,7 +35,7 @@ export class PluginApiService { } getPlugins ( - pluginType: PluginType, + pluginType: PluginType_Type, componentPagination: ComponentPagination, sort: string ) { @@ -49,7 +50,7 @@ export class PluginApiService { } searchAvailablePlugins ( - pluginType: PluginType, + pluginType: PluginType_Type, componentPagination: ComponentPagination, sort: string, search?: string @@ -73,7 +74,7 @@ export class PluginApiService { .pipe(catchError(res => this.restExtractor.handleError(res))) } - getPluginRegisteredSettings (pluginName: string, pluginType: PluginType) { + getPluginRegisteredSettings (pluginName: string, pluginType: PluginType_Type) { const npmName = this.pluginService.nameToNpmName(pluginName, pluginType) const path = PluginApiService.BASE_PLUGIN_URL + '/' + npmName + '/registered-settings' @@ -83,7 +84,7 @@ export class PluginApiService { ) } - updatePluginSettings (pluginName: string, pluginType: PluginType, settings: any) { + updatePluginSettings (pluginName: string, pluginType: PluginType_Type, settings: any) { const npmName = this.pluginService.nameToNpmName(pluginName, pluginType) const path = PluginApiService.BASE_PLUGIN_URL + '/' + npmName + '/settings' @@ -91,7 +92,7 @@ export class PluginApiService { .pipe(catchError(res => this.restExtractor.handleError(res))) } - uninstall (pluginName: string, pluginType: PluginType) { + uninstall (pluginName: string, pluginType: PluginType_Type) { const body: ManagePlugin = { npmName: this.pluginService.nameToNpmName(pluginName, pluginType) } @@ -100,7 +101,7 @@ export class PluginApiService { .pipe(catchError(res => this.restExtractor.handleError(res))) } - update (pluginName: string, pluginType: PluginType) { + update (pluginName: string, pluginType: PluginType_Type) { const body: ManagePlugin = { npmName: this.pluginService.nameToNpmName(pluginName, pluginType) } @@ -118,7 +119,7 @@ export class PluginApiService { .pipe(catchError(res => this.restExtractor.handleError(res))) } - getPluginOrThemeHref (type: PluginType, name: string) { + getPluginOrThemeHref (type: PluginType_Type, name: string) { const typeString = type === PluginType.PLUGIN ? 'plugin' : 'theme' diff --git a/client/src/app/+admin/plugins/shared/plugin-card.component.ts b/client/src/app/+admin/plugins/shared/plugin-card.component.ts index 462a6c213..ae91f6887 100644 --- a/client/src/app/+admin/plugins/shared/plugin-card.component.ts +++ b/client/src/app/+admin/plugins/shared/plugin-card.component.ts @@ -1,5 +1,5 @@ import { Component, Input } from '@angular/core' -import { PeerTubePlugin, PeerTubePluginIndex, PluginType } from '@shared/models' +import { PeerTubePlugin, PeerTubePluginIndex, PluginType_Type } from '@peertube/peertube-models' import { PluginApiService } from './plugin-api.service' @Component({ @@ -11,7 +11,7 @@ import { PluginApiService } from './plugin-api.service' export class PluginCardComponent { @Input() plugin: PeerTubePluginIndex | PeerTubePlugin @Input() version: string - @Input() pluginType: PluginType + @Input() pluginType: PluginType_Type constructor ( private pluginApiService: PluginApiService diff --git a/client/src/app/+admin/plugins/shared/plugin-navigation.component.ts b/client/src/app/+admin/plugins/shared/plugin-navigation.component.ts index 1c963f521..c829bc975 100644 --- a/client/src/app/+admin/plugins/shared/plugin-navigation.component.ts +++ b/client/src/app/+admin/plugins/shared/plugin-navigation.component.ts @@ -1,5 +1,5 @@ import { Component, Input } from '@angular/core' -import { PluginType } from '@shared/models/plugins' +import { PluginType_Type } from '@peertube/peertube-models' @Component({ selector: 'my-plugin-navigation', @@ -7,5 +7,5 @@ import { PluginType } from '@shared/models/plugins' styleUrls: [ './plugin-navigation.component.scss' ] }) export class PluginNavigationComponent { - @Input() pluginType: PluginType + @Input() pluginType: PluginType_Type } diff --git a/client/src/app/+admin/shared/user-email-info.component.ts b/client/src/app/+admin/shared/user-email-info.component.ts index e33948b60..0af905c84 100644 --- a/client/src/app/+admin/shared/user-email-info.component.ts +++ b/client/src/app/+admin/shared/user-email-info.component.ts @@ -1,5 +1,5 @@ import { Component, Input } from '@angular/core' -import { User, UserRegistration } from '@shared/models/users' +import { User, UserRegistration } from '@peertube/peertube-models' @Component({ selector: 'my-user-email-info', diff --git a/client/src/app/+admin/shared/user-real-quota-info.component.ts b/client/src/app/+admin/shared/user-real-quota-info.component.ts index 0a342c799..dd78fa9f0 100644 --- a/client/src/app/+admin/shared/user-real-quota-info.component.ts +++ b/client/src/app/+admin/shared/user-real-quota-info.component.ts @@ -1,6 +1,6 @@ import { Component, Input, OnInit } from '@angular/core' import { ServerService } from '@app/core' -import { HTMLServerConfig, VideoResolution } from '@shared/models/index' +import { HTMLServerConfig, VideoResolution } from '@peertube/peertube-models' @Component({ selector: 'my-user-real-quota-info', diff --git a/client/src/app/+admin/system/debug/debug.component.ts b/client/src/app/+admin/system/debug/debug.component.ts index 1f4e71e8a..5c86803ef 100644 --- a/client/src/app/+admin/system/debug/debug.component.ts +++ b/client/src/app/+admin/system/debug/debug.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit } from '@angular/core' import { Notifier } from '@app/core' -import { Debug } from '@shared/models' +import { Debug } from '@peertube/peertube-models' import { DebugService } from './debug.service' @Component({ diff --git a/client/src/app/+admin/system/debug/debug.service.ts b/client/src/app/+admin/system/debug/debug.service.ts index ab1d0a7fa..24d3b2ab8 100644 --- a/client/src/app/+admin/system/debug/debug.service.ts +++ b/client/src/app/+admin/system/debug/debug.service.ts @@ -3,7 +3,7 @@ import { catchError } from 'rxjs/operators' import { HttpClient } from '@angular/common/http' import { Injectable } from '@angular/core' import { RestExtractor } from '@app/core' -import { Debug } from '@shared/models' +import { Debug } from '@peertube/peertube-models' import { environment } from '../../../../environments/environment' @Injectable() diff --git a/client/src/app/+admin/system/jobs/job.service.ts b/client/src/app/+admin/system/jobs/job.service.ts index 031e2bad8..eae1dea7d 100644 --- a/client/src/app/+admin/system/jobs/job.service.ts +++ b/client/src/app/+admin/system/jobs/job.service.ts @@ -4,7 +4,7 @@ import { catchError, map } from 'rxjs/operators' import { HttpClient, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' import { RestExtractor, RestPagination, RestService } from '@app/core' -import { Job, ResultList } from '@shared/models' +import { Job, ResultList } from '@peertube/peertube-models' import { environment } from '../../../../environments/environment' import { JobStateClient } from '../../../../types/job-state-client.type' import { JobTypeClient } from '../../../../types/job-type-client.type' diff --git a/client/src/app/+admin/system/jobs/jobs.component.ts b/client/src/app/+admin/system/jobs/jobs.component.ts index 6e10c81ff..4e6b4bf7b 100644 --- a/client/src/app/+admin/system/jobs/jobs.component.ts +++ b/client/src/app/+admin/system/jobs/jobs.component.ts @@ -1,9 +1,9 @@ import { SortMeta } from 'primeng/api' import { Component, OnInit } from '@angular/core' import { Notifier, RestPagination, RestTable } from '@app/core' +import { escapeHTML } from '@peertube/peertube-core-utils' +import { Job, JobState, JobType } from '@peertube/peertube-models' import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' -import { escapeHTML } from '@shared/core-utils/renderer' -import { Job, JobState, JobType } from '@shared/models' import { JobStateClient } from '../../../../types/job-state-client.type' import { JobTypeClient } from '../../../../types/job-type-client.type' import { JobService } from './job.service' diff --git a/client/src/app/+admin/system/logs/log-row.model.ts b/client/src/app/+admin/system/logs/log-row.model.ts index e83c7b064..15799e8b0 100644 --- a/client/src/app/+admin/system/logs/log-row.model.ts +++ b/client/src/app/+admin/system/logs/log-row.model.ts @@ -1,6 +1,6 @@ import omit from 'lodash-es/omit' import { logger } from '@root-helpers/logger' -import { ServerLogLevel } from '@shared/models' +import { ServerLogLevel } from '@peertube/peertube-models' export class LogRow { date: Date diff --git a/client/src/app/+admin/system/logs/logs.component.ts b/client/src/app/+admin/system/logs/logs.component.ts index 939e710d7..22375fcd9 100644 --- a/client/src/app/+admin/system/logs/logs.component.ts +++ b/client/src/app/+admin/system/logs/logs.component.ts @@ -1,6 +1,6 @@ import { Component, ElementRef, OnInit, ViewChild } from '@angular/core' import { LocalStorageService, Notifier } from '@app/core' -import { ServerLogLevel } from '@shared/models' +import { ServerLogLevel } from '@peertube/peertube-models' import { LogRow } from './log-row.model' import { LogsService } from './logs.service' diff --git a/client/src/app/+admin/system/logs/logs.service.ts b/client/src/app/+admin/system/logs/logs.service.ts index 933a074a8..9e774d7fd 100644 --- a/client/src/app/+admin/system/logs/logs.service.ts +++ b/client/src/app/+admin/system/logs/logs.service.ts @@ -3,7 +3,7 @@ import { catchError, map } from 'rxjs/operators' import { HttpClient, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' import { RestExtractor, RestService } from '@app/core' -import { ServerLogLevel } from '@shared/models' +import { ServerLogLevel } from '@peertube/peertube-models' import { environment } from '../../../../environments/environment' import { LogRow } from './log-row.model' diff --git a/client/src/app/+admin/system/runners/runner-job-list/runner-job-list.component.ts b/client/src/app/+admin/system/runners/runner-job-list/runner-job-list.component.ts index 2670eac86..e75446d8c 100644 --- a/client/src/app/+admin/system/runners/runner-job-list/runner-job-list.component.ts +++ b/client/src/app/+admin/system/runners/runner-job-list/runner-job-list.component.ts @@ -3,7 +3,7 @@ import { Component, OnInit } from '@angular/core' import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core' import { formatICU } from '@app/helpers' import { DropdownAction } from '@app/shared/shared-main' -import { RunnerJob, RunnerJobState } from '@shared/models' +import { RunnerJob, RunnerJobState } from '@peertube/peertube-models' import { RunnerJobFormatted, RunnerService } from '../runner.service' import { AdvancedInputFilter } from '@app/shared/shared-forms' diff --git a/client/src/app/+admin/system/runners/runner-list/runner-list.component.ts b/client/src/app/+admin/system/runners/runner-list/runner-list.component.ts index 7566f967e..0964471f9 100644 --- a/client/src/app/+admin/system/runners/runner-list/runner-list.component.ts +++ b/client/src/app/+admin/system/runners/runner-list/runner-list.component.ts @@ -2,7 +2,7 @@ import { SortMeta } from 'primeng/api' import { Component, OnInit } from '@angular/core' import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core' import { DropdownAction } from '@app/shared/shared-main' -import { Runner } from '@shared/models' +import { Runner } from '@peertube/peertube-models' import { RunnerService } from '../runner.service' @Component({ diff --git a/client/src/app/+admin/system/runners/runner-registration-token-list/runner-registration-token-list.component.ts b/client/src/app/+admin/system/runners/runner-registration-token-list/runner-registration-token-list.component.ts index 77908a2e1..c8a597b18 100644 --- a/client/src/app/+admin/system/runners/runner-registration-token-list/runner-registration-token-list.component.ts +++ b/client/src/app/+admin/system/runners/runner-registration-token-list/runner-registration-token-list.component.ts @@ -2,7 +2,7 @@ import { SortMeta } from 'primeng/api' import { Component, OnInit } from '@angular/core' import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core' import { DropdownAction } from '@app/shared/shared-main' -import { RunnerRegistrationToken } from '@shared/models' +import { RunnerRegistrationToken } from '@peertube/peertube-models' import { RunnerService } from '../runner.service' @Component({ diff --git a/client/src/app/+admin/system/runners/runner.service.ts b/client/src/app/+admin/system/runners/runner.service.ts index 3ab36c4ff..94bdaad78 100644 --- a/client/src/app/+admin/system/runners/runner.service.ts +++ b/client/src/app/+admin/system/runners/runner.service.ts @@ -4,9 +4,8 @@ import { catchError, concatMap, forkJoin, from, map, toArray } from 'rxjs' import { HttpClient, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' import { RestExtractor, RestPagination, RestService, ServerService } from '@app/core' -import { arrayify, peertubeTranslate } from '@shared/core-utils' -import { ResultList } from '@shared/models/common' -import { Runner, RunnerJob, RunnerJobAdmin, RunnerJobState, RunnerRegistrationToken } from '@shared/models/runners' +import { arrayify, peertubeTranslate } from '@peertube/peertube-core-utils' +import { ResultList, Runner, RunnerJob, RunnerJobAdmin, RunnerJobState, RunnerRegistrationToken } from '@peertube/peertube-models' import { environment } from '../../../../environments/environment' export type RunnerJobFormatted = RunnerJob & { diff --git a/client/src/app/+admin/system/runners/runners.routes.ts b/client/src/app/+admin/system/runners/runners.routes.ts index fabe687d6..004c3bedd 100644 --- a/client/src/app/+admin/system/runners/runners.routes.ts +++ b/client/src/app/+admin/system/runners/runners.routes.ts @@ -1,6 +1,6 @@ import { Routes } from '@angular/router' import { UserRightGuard } from '@app/core' -import { UserRight } from '@shared/models' +import { UserRight } from '@peertube/peertube-models' import { RunnerJobListComponent } from './runner-job-list' import { RunnerListComponent } from './runner-list' import { RunnerRegistrationTokenListComponent } from './runner-registration-token-list' diff --git a/client/src/app/+admin/system/system.routes.ts b/client/src/app/+admin/system/system.routes.ts index 87e4b25b3..169d52952 100644 --- a/client/src/app/+admin/system/system.routes.ts +++ b/client/src/app/+admin/system/system.routes.ts @@ -1,6 +1,6 @@ import { Routes } from '@angular/router' import { UserRightGuard } from '@app/core' -import { UserRight } from '@shared/models' +import { UserRight } from '@peertube/peertube-models' import { DebugComponent } from './debug' import { JobsComponent } from './jobs/jobs.component' import { LogsComponent } from './logs' diff --git a/client/src/app/+error-page/error-page.component.ts b/client/src/app/+error-page/error-page.component.ts index 4fee01350..9cc4646df 100644 --- a/client/src/app/+error-page/error-page.component.ts +++ b/client/src/app/+error-page/error-page.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit } from '@angular/core' import { Title } from '@angular/platform-browser' import { Router } from '@angular/router' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode, HttpStatusCodeType } from '@peertube/peertube-models' @Component({ selector: 'my-error-page', @@ -9,7 +9,7 @@ import { HttpStatusCode } from '@shared/models' styleUrls: [ './error-page.component.scss' ] }) export class ErrorPageComponent implements OnInit { - status = HttpStatusCode.NOT_FOUND_404 + status: HttpStatusCodeType = HttpStatusCode.NOT_FOUND_404 type: 'video' | 'other' = 'other' public constructor ( diff --git a/client/src/app/+login/login.component.ts b/client/src/app/+login/login.component.ts index e486df61d..a6906efa2 100644 --- a/client/src/app/+login/login.component.ts +++ b/client/src/app/+login/login.component.ts @@ -8,8 +8,8 @@ import { USER_OTP_TOKEN_VALIDATOR } from '@app/shared/form-validators/user-valid import { FormReactive, FormReactiveService, InputTextComponent } from '@app/shared/shared-forms' import { InstanceAboutAccordionComponent } from '@app/shared/shared-instance' import { NgbAccordionDirective, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' -import { getExternalAuthHref } from '@shared/core-utils' -import { RegisteredExternalAuthConfig, ServerConfig, ServerErrorCode } from '@shared/models' +import { getExternalAuthHref } from '@peertube/peertube-core-utils' +import { RegisteredExternalAuthConfig, ServerConfig, ServerErrorCode } from '@peertube/peertube-models' @Component({ selector: 'my-login', diff --git a/client/src/app/+manage/video-channel-edit/video-channel-create.component.ts b/client/src/app/+manage/video-channel-edit/video-channel-create.component.ts index 8ca94b0b3..3f876078f 100644 --- a/client/src/app/+manage/video-channel-edit/video-channel-create.component.ts +++ b/client/src/app/+manage/video-channel-edit/video-channel-create.component.ts @@ -11,7 +11,7 @@ import { } from '@app/shared/form-validators/video-channel-validators' import { FormReactiveService } from '@app/shared/shared-forms' import { VideoChannel, VideoChannelService } from '@app/shared/shared-main' -import { HttpStatusCode, VideoChannelCreate } from '@shared/models' +import { HttpStatusCode, VideoChannelCreate } from '@peertube/peertube-models' import { VideoChannelEdit } from './video-channel-edit' @Component({ diff --git a/client/src/app/+manage/video-channel-edit/video-channel-update.component.ts b/client/src/app/+manage/video-channel-edit/video-channel-update.component.ts index f9045db35..3992e298e 100644 --- a/client/src/app/+manage/video-channel-edit/video-channel-update.component.ts +++ b/client/src/app/+manage/video-channel-edit/video-channel-update.component.ts @@ -11,9 +11,9 @@ import { } from '@app/shared/form-validators/video-channel-validators' import { FormReactiveService } from '@app/shared/shared-forms' import { VideoChannel, VideoChannelService } from '@app/shared/shared-main' -import { HTMLServerConfig, VideoChannelUpdate } from '@shared/models' +import { HTMLServerConfig, VideoChannelUpdate } from '@peertube/peertube-models' import { VideoChannelEdit } from './video-channel-edit' -import { shallowCopy } from '@shared/core-utils' +import { shallowCopy } from '@peertube/peertube-core-utils' @Component({ selector: 'my-video-channel-update', diff --git a/client/src/app/+my-account/my-account-applications/my-account-applications.component.ts b/client/src/app/+my-account/my-account-applications/my-account-applications.component.ts index e88cdd228..281a12eda 100644 --- a/client/src/app/+my-account/my-account-applications/my-account-applications.component.ts +++ b/client/src/app/+my-account/my-account-applications/my-account-applications.component.ts @@ -1,8 +1,7 @@ import { Component, OnInit } from '@angular/core' import { AuthService, ConfirmService, Notifier, ScopedTokensService } from '@app/core' import { VideoService } from '@app/shared/shared-main' -import { FeedFormat } from '@shared/models' -import { ScopedToken } from '@shared/models/users/user-scoped-token' +import { FeedFormat, ScopedToken } from '@peertube/peertube-models' import { environment } from '../../../environments/environment' @Component({ diff --git a/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts b/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts index 1e8fa2a56..7bbd240d0 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts @@ -4,7 +4,7 @@ import { Component, OnInit } from '@angular/core' import { AuthService, Notifier, ServerService, UserService } from '@app/core' import { USER_EMAIL_VALIDATOR, USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' -import { HttpStatusCode, User } from '@shared/models' +import { HttpStatusCode, User } from '@peertube/peertube-models' @Component({ selector: 'my-account-change-email', diff --git a/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts b/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts index 805d50070..f916740be 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts @@ -7,7 +7,7 @@ import { USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' -import { HttpStatusCode, User } from '@shared/models' +import { HttpStatusCode, User } from '@peertube/peertube-models' @Component({ selector: 'my-account-change-password', diff --git a/client/src/app/+my-account/my-account-settings/my-account-email-preferences/my-account-email-preferences.component.ts b/client/src/app/+my-account/my-account-settings/my-account-email-preferences/my-account-email-preferences.component.ts index 381d18922..bf6accc3e 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-email-preferences/my-account-email-preferences.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-email-preferences/my-account-email-preferences.component.ts @@ -2,7 +2,7 @@ import { Subject } from 'rxjs' import { Component, Input, OnInit } from '@angular/core' import { Notifier, UserService } from '@app/core' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' -import { User, UserUpdateMe } from '@shared/models' +import { User, UserUpdateMe } from '@peertube/peertube-models' @Component({ selector: 'my-account-email-preferences', diff --git a/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts b/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts index 2adc276a9..f4181340d 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts @@ -3,8 +3,8 @@ import { Subject } from 'rxjs' import { Component, Input, OnInit } from '@angular/core' import { Notifier, ServerService, User } from '@app/core' import { UserNotificationService } from '@app/shared/shared-main' -import { objectKeysTyped } from '@shared/core-utils' -import { UserNotificationSetting, UserNotificationSettingValue, UserRight } from '@shared/models' +import { objectKeysTyped } from '@peertube/peertube-core-utils' +import { UserNotificationSetting, UserNotificationSettingValue, UserRight, UserRightType } from '@peertube/peertube-models' @Component({ selector: 'my-account-notification-preferences', @@ -19,7 +19,7 @@ export class MyAccountNotificationPreferencesComponent implements OnInit { emailNotifications: { [ id in keyof UserNotificationSetting ]?: boolean } = {} webNotifications: { [ id in keyof UserNotificationSetting ]?: boolean } = {} labelNotifications: { [ id in keyof UserNotificationSetting ]?: string } = {} - rightNotifications: { [ id in keyof Partial ]?: UserRight } = {} + rightNotifications: { [ id in keyof Partial ]?: UserRightType } = {} emailEnabled = false private savePreferences = debounce(this.savePreferencesImpl.bind(this), 500) diff --git a/client/src/app/+my-account/my-account-settings/my-account-settings.component.ts b/client/src/app/+my-account/my-account-settings/my-account-settings.component.ts index a276bb126..4b3b33bcc 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-settings.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-settings.component.ts @@ -3,7 +3,7 @@ import { HttpErrorResponse } from '@angular/common/http' import { AfterViewChecked, Component, OnInit } from '@angular/core' import { AuthService, Notifier, User, UserService } from '@app/core' import { genericUploadErrorHandler } from '@app/helpers' -import { shallowCopy } from '@shared/core-utils' +import { shallowCopy } from '@peertube/peertube-core-utils' @Component({ selector: 'my-account-settings', diff --git a/client/src/app/+my-library/my-follows/my-followers.component.ts b/client/src/app/+my-library/my-follows/my-followers.component.ts index 0dd9bf6f5..4e3e5bcc4 100644 --- a/client/src/app/+my-library/my-follows/my-followers.component.ts +++ b/client/src/app/+my-library/my-follows/my-followers.component.ts @@ -4,7 +4,7 @@ import { ActivatedRoute } from '@angular/router' import { AuthService, ComponentPagination, Notifier } from '@app/core' import { AdvancedInputFilter } from '@app/shared/shared-forms' import { UserSubscriptionService } from '@app/shared/shared-user-subscription' -import { ActorFollow } from '@shared/models' +import { ActorFollow } from '@peertube/peertube-models' @Component({ templateUrl: './my-followers.component.html', diff --git a/client/src/app/+my-library/my-library.component.ts b/client/src/app/+my-library/my-library.component.ts index ff901952f..35eb617ab 100644 --- a/client/src/app/+my-library/my-library.component.ts +++ b/client/src/app/+my-library/my-library.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit } from '@angular/core' import { AuthService, AuthUser, ScreenService, ServerService } from '@app/core' -import { HTMLServerConfig } from '@shared/models' +import { HTMLServerConfig } from '@peertube/peertube-models' import { TopMenuDropdownParam } from '../shared/shared-main/misc/top-menu-dropdown.component' @Component({ diff --git a/client/src/app/+my-library/my-ownership/my-accept-ownership/my-accept-ownership.component.ts b/client/src/app/+my-library/my-ownership/my-accept-ownership/my-accept-ownership.component.ts index ca7eb680b..87e389411 100644 --- a/client/src/app/+my-library/my-ownership/my-accept-ownership/my-accept-ownership.component.ts +++ b/client/src/app/+my-library/my-ownership/my-accept-ownership/my-accept-ownership.component.ts @@ -6,7 +6,7 @@ import { OWNERSHIP_CHANGE_CHANNEL_VALIDATOR } from '@app/shared/form-validators/ import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' import { VideoOwnershipService } from '@app/shared/shared-main' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' -import { VideoChangeOwnership } from '@shared/models' +import { VideoChangeOwnership } from '@peertube/peertube-models' @Component({ selector: 'my-accept-ownership', diff --git a/client/src/app/+my-library/my-ownership/my-ownership.component.ts b/client/src/app/+my-library/my-ownership/my-ownership.component.ts index 8d6a42dfb..4838eca27 100644 --- a/client/src/app/+my-library/my-ownership/my-ownership.component.ts +++ b/client/src/app/+my-library/my-ownership/my-ownership.component.ts @@ -2,7 +2,7 @@ import { SortMeta } from 'primeng/api' import { Component, OnInit, ViewChild } from '@angular/core' import { Notifier, RestPagination, RestTable } from '@app/core' import { Account, VideoOwnershipService } from '@app/shared/shared-main' -import { VideoChangeOwnership, VideoChangeOwnershipStatus } from '@shared/models' +import { VideoChangeOwnership, VideoChangeOwnershipStatus, VideoChangeOwnershipStatusType } from '@peertube/peertube-models' import { MyAcceptOwnershipComponent } from './my-accept-ownership/my-accept-ownership.component' @Component({ @@ -32,7 +32,7 @@ export class MyOwnershipComponent extends RestTable implements OnInit { return 'MyOwnershipComponent' } - getStatusClass (status: VideoChangeOwnershipStatus) { + getStatusClass (status: VideoChangeOwnershipStatusType) { switch (status) { case VideoChangeOwnershipStatus.ACCEPTED: return 'badge-green' diff --git a/client/src/app/+my-library/my-video-channel-syncs/my-video-channel-syncs.component.ts b/client/src/app/+my-library/my-video-channel-syncs/my-video-channel-syncs.component.ts index 1f7287f44..44e5c45b9 100644 --- a/client/src/app/+my-library/my-video-channel-syncs/my-video-channel-syncs.component.ts +++ b/client/src/app/+my-library/my-video-channel-syncs/my-video-channel-syncs.component.ts @@ -3,8 +3,7 @@ import { mergeMap } from 'rxjs' import { Component, OnInit } from '@angular/core' import { AuthService, Notifier, RestPagination, RestTable, ServerService } from '@app/core' import { DropdownAction, VideoChannelService, VideoChannelSyncService } from '@app/shared/shared-main' -import { HTMLServerConfig } from '@shared/models/server' -import { VideoChannelSync, VideoChannelSyncState } from '@shared/models/videos' +import { HTMLServerConfig, VideoChannelSync, VideoChannelSyncState, VideoChannelSyncStateType } from '@peertube/peertube-models' @Component({ templateUrl: './my-video-channel-syncs.component.html', @@ -124,7 +123,7 @@ export class MyVideoChannelSyncsComponent extends RestTable implements OnInit { return '/my-library/video-channel-syncs/create' } - getSyncStateClass (stateId: VideoChannelSyncState) { + getSyncStateClass (stateId: VideoChannelSyncStateType) { return [ 'pt-badge', MyVideoChannelSyncsComponent.STATE_CLASS_BY_ID[stateId] ] } diff --git a/client/src/app/+my-library/my-video-channel-syncs/video-channel-sync-edit/video-channel-sync-edit.component.ts b/client/src/app/+my-library/my-video-channel-syncs/video-channel-sync-edit/video-channel-sync-edit.component.ts index a14ab5b92..a40a68764 100644 --- a/client/src/app/+my-library/my-video-channel-syncs/video-channel-sync-edit/video-channel-sync-edit.component.ts +++ b/client/src/app/+my-library/my-video-channel-syncs/video-channel-sync-edit/video-channel-sync-edit.component.ts @@ -7,7 +7,7 @@ import { listUserChannelsForSelect } from '@app/helpers' import { VIDEO_CHANNEL_EXTERNAL_URL_VALIDATOR } from '@app/shared/form-validators/video-channel-validators' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' import { VideoChannelService, VideoChannelSyncService } from '@app/shared/shared-main' -import { VideoChannelSyncCreate } from '@shared/models/videos' +import { VideoChannelSyncCreate } from '@peertube/peertube-models' @Component({ selector: 'my-video-channel-sync-edit', diff --git a/client/src/app/+my-library/my-video-imports/my-video-imports.component.ts b/client/src/app/+my-library/my-video-imports/my-video-imports.component.ts index 7d82f62b9..76cefa7bd 100644 --- a/client/src/app/+my-library/my-video-imports/my-video-imports.component.ts +++ b/client/src/app/+my-library/my-video-imports/my-video-imports.component.ts @@ -2,7 +2,7 @@ import { SortMeta } from 'primeng/api' import { Component, OnInit } from '@angular/core' import { Notifier, RestPagination, RestTable } from '@app/core' import { Video, VideoImportService } from '@app/shared/shared-main' -import { VideoImport, VideoImportState } from '@shared/models' +import { VideoImport, VideoImportState, VideoImportStateType } from '@peertube/peertube-models' @Component({ templateUrl: './my-video-imports.component.html', @@ -29,7 +29,7 @@ export class MyVideoImportsComponent extends RestTable implements OnInit { return 'MyVideoImportsComponent' } - getVideoImportStateClass (state: VideoImportState) { + getVideoImportStateClass (state: VideoImportStateType) { switch (state) { case VideoImportState.FAILED: return 'badge-red' diff --git a/client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.ts b/client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.ts index 63f72df3f..a54b3ca86 100644 --- a/client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.ts +++ b/client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.ts @@ -11,8 +11,7 @@ import { } from '@app/shared/form-validators/video-playlist-validators' import { FormReactiveService } from '@app/shared/shared-forms' import { VideoPlaylistService } from '@app/shared/shared-video-playlist' -import { VideoPlaylistCreate } from '@shared/models/videos/playlist/video-playlist-create.model' -import { VideoPlaylistPrivacy } from '@shared/models/videos/playlist/video-playlist-privacy.model' +import { VideoPlaylistCreate, VideoPlaylistPrivacy } from '@peertube/peertube-models' import { MyVideoPlaylistEdit } from './my-video-playlist-edit' @Component({ diff --git a/client/src/app/+my-library/my-video-playlists/my-video-playlist-edit.ts b/client/src/app/+my-library/my-video-playlists/my-video-playlist-edit.ts index 71db0592a..127960a58 100644 --- a/client/src/app/+my-library/my-video-playlists/my-video-playlist-edit.ts +++ b/client/src/app/+my-library/my-video-playlists/my-video-playlist-edit.ts @@ -1,13 +1,12 @@ import { FormReactive } from '@app/shared/shared-forms' -import { VideoConstant, VideoPlaylistPrivacy } from '@shared/models' -import { VideoPlaylist } from '@shared/models/videos/playlist/video-playlist.model' +import { VideoConstant, VideoPlaylist, VideoPlaylistPrivacyType } from '@peertube/peertube-models' import { SelectChannelItem } from '../../../types/select-options-item.model' export abstract class MyVideoPlaylistEdit extends FormReactive { // Declare it here to avoid errors in create template videoPlaylistToUpdate: VideoPlaylist userVideoChannels: SelectChannelItem[] = [] - videoPlaylistPrivacies: VideoConstant[] = [] + videoPlaylistPrivacies: VideoConstant[] = [] abstract isCreation (): boolean abstract getFormButtonTitle (): string diff --git a/client/src/app/+my-library/my-video-playlists/my-video-playlist-elements.component.ts b/client/src/app/+my-library/my-video-playlists/my-video-playlist-elements.component.ts index c9739b6cc..7a9588743 100644 --- a/client/src/app/+my-library/my-video-playlists/my-video-playlist-elements.component.ts +++ b/client/src/app/+my-library/my-video-playlists/my-video-playlist-elements.component.ts @@ -6,7 +6,7 @@ import { ComponentPagination, ConfirmService, HooksService, Notifier, ScreenServ import { DropdownAction } from '@app/shared/shared-main' import { VideoShareComponent } from '@app/shared/shared-share-modal' import { VideoPlaylist, VideoPlaylistElement, VideoPlaylistService } from '@app/shared/shared-video-playlist' -import { VideoPlaylistType } from '@shared/models' +import { VideoPlaylistType } from '@peertube/peertube-models' @Component({ templateUrl: './my-video-playlist-elements.component.html', diff --git a/client/src/app/+my-library/my-video-playlists/my-video-playlist-update.component.ts b/client/src/app/+my-library/my-video-playlists/my-video-playlist-update.component.ts index bbe8a5f80..f29a0cc45 100644 --- a/client/src/app/+my-library/my-video-playlists/my-video-playlist-update.component.ts +++ b/client/src/app/+my-library/my-video-playlists/my-video-playlist-update.component.ts @@ -13,7 +13,7 @@ import { } from '@app/shared/form-validators/video-playlist-validators' import { FormReactiveService } from '@app/shared/shared-forms' import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist' -import { VideoPlaylistUpdate } from '@shared/models' +import { VideoPlaylistUpdate } from '@peertube/peertube-models' import { MyVideoPlaylistEdit } from './my-video-playlist-edit' @Component({ diff --git a/client/src/app/+my-library/my-video-playlists/my-video-playlists.component.ts b/client/src/app/+my-library/my-video-playlists/my-video-playlists.component.ts index 634176744..08bd94fae 100644 --- a/client/src/app/+my-library/my-video-playlists/my-video-playlists.component.ts +++ b/client/src/app/+my-library/my-video-playlists/my-video-playlists.component.ts @@ -3,7 +3,7 @@ import { mergeMap } from 'rxjs/operators' import { Component } from '@angular/core' import { AuthService, ComponentPagination, ConfirmService, Notifier } from '@app/core' import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist' -import { VideoPlaylistType } from '@shared/models' +import { VideoPlaylistType } from '@peertube/peertube-models' @Component({ templateUrl: './my-video-playlists.component.html', diff --git a/client/src/app/+my-library/my-videos/my-videos.component.ts b/client/src/app/+my-library/my-videos/my-videos.component.ts index 1827d6a0b..4a7604878 100644 --- a/client/src/app/+my-library/my-videos/my-videos.component.ts +++ b/client/src/app/+my-library/my-videos/my-videos.component.ts @@ -16,7 +16,7 @@ import { VideosSelectionComponent } from '@app/shared/shared-video-miniature' import { VideoPlaylistService } from '@app/shared/shared-video-playlist' -import { VideoChannel, VideoExistInPlaylist, VideosExistInPlaylists, VideoSortField } from '@shared/models' +import { VideoChannel, VideoExistInPlaylist, VideosExistInPlaylists, VideoSortField } from '@peertube/peertube-models' import { VideoChangeOwnershipComponent } from './modals/video-change-ownership.component' @Component({ diff --git a/client/src/app/+search/search-filters.component.ts b/client/src/app/+search/search-filters.component.ts index a6fc51383..b98acee18 100644 --- a/client/src/app/+search/search-filters.component.ts +++ b/client/src/app/+search/search-filters.component.ts @@ -1,7 +1,7 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' import { ServerService } from '@app/core' import { AdvancedSearch } from '@app/shared/shared-search' -import { HTMLServerConfig, VideoConstant } from '@shared/models' +import { HTMLServerConfig, VideoConstant } from '@peertube/peertube-models' type FormOption = { id: string, label: string } diff --git a/client/src/app/+search/search.component.ts b/client/src/app/+search/search.component.ts index 31394a1d1..62e349c40 100644 --- a/client/src/app/+search/search.component.ts +++ b/client/src/app/+search/search.component.ts @@ -9,7 +9,7 @@ import { Video, VideoChannel } from '@app/shared/shared-main' import { AdvancedSearch, SearchService } from '@app/shared/shared-search' import { MiniatureDisplayOptions } from '@app/shared/shared-video-miniature' import { VideoPlaylist } from '@app/shared/shared-video-playlist' -import { HTMLServerConfig, SearchTargetType } from '@shared/models' +import { HTMLServerConfig, SearchTargetType } from '@peertube/peertube-models' @Component({ selector: 'my-search', diff --git a/client/src/app/+search/shared/abstract-lazy-load.resolver.ts b/client/src/app/+search/shared/abstract-lazy-load.resolver.ts index 6765ba15e..4e8b71293 100644 --- a/client/src/app/+search/shared/abstract-lazy-load.resolver.ts +++ b/client/src/app/+search/shared/abstract-lazy-load.resolver.ts @@ -2,7 +2,7 @@ import { Observable } from 'rxjs' import { map } from 'rxjs/operators' import { ActivatedRouteSnapshot, Router } from '@angular/router' import { logger } from '@root-helpers/logger' -import { ResultList } from '@shared/models' +import { ResultList } from '@peertube/peertube-models' export abstract class AbstractLazyLoadResolver { protected router: Router diff --git a/client/src/app/+signup/+register/register.component.ts b/client/src/app/+signup/+register/register.component.ts index be51c36d1..396971d98 100644 --- a/client/src/app/+signup/+register/register.component.ts +++ b/client/src/app/+signup/+register/register.component.ts @@ -5,8 +5,7 @@ import { ActivatedRoute } from '@angular/router' import { AuthService } from '@app/core' import { HooksService } from '@app/core/plugins/hooks.service' import { InstanceAboutAccordionComponent } from '@app/shared/shared-instance' -import { UserRegister } from '@shared/models' -import { ServerConfig } from '@shared/models/server' +import { ServerConfig, UserRegister } from '@peertube/peertube-models' import { SignupService } from '../shared/signup.service' @Component({ diff --git a/client/src/app/+signup/shared/signup.service.ts b/client/src/app/+signup/shared/signup.service.ts index f647298be..7c331437e 100644 --- a/client/src/app/+signup/shared/signup.service.ts +++ b/client/src/app/+signup/shared/signup.service.ts @@ -2,7 +2,7 @@ import { catchError, tap } from 'rxjs/operators' import { HttpClient } from '@angular/common/http' import { Injectable } from '@angular/core' import { RestExtractor, UserService } from '@app/core' -import { UserRegister, UserRegistrationRequest } from '@shared/models' +import { UserRegister, UserRegistrationRequest } from '@peertube/peertube-models' @Injectable() export class SignupService { diff --git a/client/src/app/+stats/video/video-stats.component.ts b/client/src/app/+stats/video/video-stats.component.ts index fa5e33ab6..5bde5b01d 100644 --- a/client/src/app/+stats/video/video-stats.component.ts +++ b/client/src/app/+stats/video/video-stats.component.ts @@ -7,15 +7,15 @@ import { ActivatedRoute } from '@angular/router' import { Notifier, PeerTubeRouterService } from '@app/core' import { NumberFormatterPipe, VideoDetails } from '@app/shared/shared-main' import { LiveVideoService } from '@app/shared/shared-video-live' -import { secondsToTime } from '@shared/core-utils' -import { HttpStatusCode } from '@shared/models/http' +import { secondsToTime } from '@peertube/peertube-core-utils' import { + HttpStatusCode, LiveVideoSession, VideoStatsOverall, VideoStatsRetention, VideoStatsTimeserie, VideoStatsTimeserieMetric -} from '@shared/models/videos' +} from '@peertube/peertube-models' import { VideoStatsService } from './video-stats.service' type ActiveGraphId = VideoStatsTimeserieMetric | 'retention' | 'countries' diff --git a/client/src/app/+stats/video/video-stats.service.ts b/client/src/app/+stats/video/video-stats.service.ts index e019c87f7..5d4817892 100644 --- a/client/src/app/+stats/video/video-stats.service.ts +++ b/client/src/app/+stats/video/video-stats.service.ts @@ -4,7 +4,7 @@ import { HttpClient, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' import { RestExtractor } from '@app/core' import { VideoService } from '@app/shared/shared-main' -import { VideoStatsOverall, VideoStatsRetention, VideoStatsTimeserie, VideoStatsTimeserieMetric } from '@shared/models/videos' +import { VideoStatsOverall, VideoStatsRetention, VideoStatsTimeserie, VideoStatsTimeserieMetric } from '@peertube/peertube-models' @Injectable({ providedIn: 'root' diff --git a/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts b/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts index 5e3946bf5..725990300 100644 --- a/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts +++ b/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts @@ -4,7 +4,7 @@ import { AfterViewInit, Component, OnDestroy, OnInit } from '@angular/core' import { ComponentPaginationLight, DisableForReuseHook, HooksService, ScreenService } from '@app/core' import { VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main' import { MiniatureDisplayOptions, VideoFilters } from '@app/shared/shared-video-miniature' -import { Video, VideoSortField } from '@shared/models' +import { Video, VideoSortField } from '@peertube/peertube-models' @Component({ selector: 'my-video-channel-videos', diff --git a/client/src/app/+video-channels/video-channels.component.ts b/client/src/app/+video-channels/video-channels.component.ts index f5bea66ec..40b3b19b7 100644 --- a/client/src/app/+video-channels/video-channels.component.ts +++ b/client/src/app/+video-channels/video-channels.component.ts @@ -8,7 +8,7 @@ import { Account, ListOverflowItem, VideoChannel, VideoChannelService, VideoServ import { BlocklistService } from '@app/shared/shared-moderation' import { SupportModalComponent } from '@app/shared/shared-support-modal' import { SubscribeButtonComponent } from '@app/shared/shared-user-subscription' -import { HttpStatusCode, UserRight } from '@shared/models' +import { HttpStatusCode, UserRight } from '@peertube/peertube-models' @Component({ templateUrl: './video-channels.component.html', diff --git a/client/src/app/+video-studio/edit/video-studio-edit.component.ts b/client/src/app/+video-studio/edit/video-studio-edit.component.ts index 3d618fbe1..40e9cf40a 100644 --- a/client/src/app/+video-studio/edit/video-studio-edit.component.ts +++ b/client/src/app/+video-studio/edit/video-studio-edit.component.ts @@ -5,8 +5,8 @@ import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' import { VideoDetails } from '@app/shared/shared-main' import { LoadingBarService } from '@ngx-loading-bar/core' import { logger } from '@root-helpers/logger' -import { secondsToTime } from '@shared/core-utils' -import { VideoStudioTask, VideoStudioTaskCut } from '@shared/models' +import { secondsToTime } from '@peertube/peertube-core-utils' +import { VideoStudioTask, VideoStudioTaskCut } from '@peertube/peertube-models' import { VideoStudioService } from '../shared' @Component({ diff --git a/client/src/app/+video-studio/shared/video-studio.service.ts b/client/src/app/+video-studio/shared/video-studio.service.ts index 8d8b2f0e5..a3aabd347 100644 --- a/client/src/app/+video-studio/shared/video-studio.service.ts +++ b/client/src/app/+video-studio/shared/video-studio.service.ts @@ -4,7 +4,7 @@ import { Injectable } from '@angular/core' import { RestExtractor } from '@app/core' import { objectToFormData } from '@app/helpers' import { VideoService } from '@app/shared/shared-main' -import { VideoStudioCreateEdition, VideoStudioTask } from '@shared/models' +import { VideoStudioCreateEdition, VideoStudioTask } from '@peertube/peertube-models' @Injectable() export class VideoStudioService { diff --git a/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts b/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts index 4ab2d42db..e595cf2c9 100644 --- a/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts +++ b/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts @@ -4,7 +4,7 @@ import { VIDEO_CAPTION_FILE_VALIDATOR, VIDEO_CAPTION_LANGUAGE_VALIDATOR } from ' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' import { VideoCaptionEdit } from '@app/shared/shared-main' import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' -import { HTMLServerConfig, VideoConstant } from '@shared/models' +import { HTMLServerConfig, VideoConstant } from '@peertube/peertube-models' @Component({ selector: 'my-video-caption-add-modal', diff --git a/client/src/app/+videos/+video-edit/shared/video-caption-edit-modal-content/video-caption-edit-modal-content.component.ts b/client/src/app/+videos/+video-edit/shared/video-caption-edit-modal-content/video-caption-edit-modal-content.component.ts index 2cb470a24..6c6a30d96 100644 --- a/client/src/app/+videos/+video-edit/shared/video-caption-edit-modal-content/video-caption-edit-modal-content.component.ts +++ b/client/src/app/+videos/+video-edit/shared/video-caption-edit-modal-content/video-caption-edit-modal-content.component.ts @@ -3,7 +3,7 @@ import { VIDEO_CAPTION_FILE_CONTENT_VALIDATOR } from '@app/shared/form-validator import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' import { VideoCaptionEdit, VideoCaptionService, VideoCaptionWithPathEdit } from '@app/shared/shared-main' import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' -import { HTMLServerConfig, VideoConstant } from '@shared/models' +import { HTMLServerConfig, VideoConstant } from '@peertube/peertube-models' import { ServerService } from '../../../../core' /** diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts index 460960a01..b0c1352f3 100644 --- a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts +++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts @@ -24,8 +24,6 @@ import { FormReactiveValidationMessages, FormValidatorService } from '@app/share import { InstanceService } from '@app/shared/shared-instance' import { VideoCaptionEdit, VideoCaptionWithPathEdit, VideoEdit, VideoService } from '@app/shared/shared-main' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' -import { logger } from '@root-helpers/logger' -import { PluginInfo } from '@root-helpers/plugins-manager' import { HTMLServerConfig, LiveVideo, @@ -34,9 +32,12 @@ import { RegisterClientVideoFieldOptions, VideoConstant, VideoDetails, - VideoPrivacy -} from '@shared/models' -import { VideoSource } from '@shared/models/videos/video-source' + VideoPrivacy, + VideoPrivacyType, + VideoSource +} from '@peertube/peertube-models' +import { logger } from '@root-helpers/logger' +import { PluginInfo } from '@root-helpers/plugins-manager' import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service' import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component' import { VideoCaptionEditModalContentComponent } from './video-caption-edit-modal-content/video-caption-edit-modal-content.component' @@ -81,8 +82,8 @@ export class VideoEditComponent implements OnInit, OnDestroy { // So that it can be accessed in the template readonly SPECIAL_SCHEDULED_PRIVACY = VideoEdit.SPECIAL_SCHEDULED_PRIVACY - videoPrivacies: VideoConstant [] = [] - replayPrivacies: VideoConstant [] = [] + videoPrivacies: VideoConstant [] = [] + replayPrivacies: VideoConstant [] = [] videoCategories: VideoConstant[] = [] videoLicences: VideoConstant[] = [] videoLanguages: VideoLanguages[] = [] diff --git a/client/src/app/+videos/+video-edit/shared/video-upload.service.ts b/client/src/app/+videos/+video-edit/shared/video-upload.service.ts index 50ca1a60b..c3f8936a9 100644 --- a/client/src/app/+videos/+video-edit/shared/video-upload.service.ts +++ b/client/src/app/+videos/+video-edit/shared/video-upload.service.ts @@ -3,7 +3,7 @@ import { HttpErrorResponse, HttpEventType, HttpHeaders } from '@angular/common/h import { Injectable } from '@angular/core' import { AuthService, Notifier, ServerService } from '@app/core' import { BytesPipe, VideoService } from '@app/shared/shared-main' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode } from '@peertube/peertube-models' import { UploaderXFormData } from './uploaderx-form-data' @Injectable() diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts index ba612f553..f7a570ed3 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts @@ -16,7 +16,7 @@ import { PeerTubeProblemDocument, ServerErrorCode, VideoPrivacy -} from '@shared/models' +} from '@peertube/peertube-models' import { VideoSend } from './video-send' @Component({ diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts index 4a1408a4a..97517e1c7 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts @@ -7,7 +7,7 @@ import { FormReactiveService } from '@app/shared/shared-forms' import { VideoCaptionService, VideoEdit, VideoImportService, VideoService } from '@app/shared/shared-main' import { LoadingBarService } from '@ngx-loading-bar/core' import { logger } from '@root-helpers/logger' -import { PeerTubeProblemDocument, ServerErrorCode, VideoUpdate } from '@shared/models' +import { PeerTubeProblemDocument, ServerErrorCode, VideoUpdate } from '@peertube/peertube-models' import { hydrateFormFromVideo } from '../shared/video-edit-utils' import { VideoSend } from './video-send' diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts index 502f3818e..634bd9914 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts @@ -8,7 +8,7 @@ import { FormReactiveService } from '@app/shared/shared-forms' import { VideoCaptionService, VideoEdit, VideoImportService, VideoService } from '@app/shared/shared-main' import { LoadingBarService } from '@ngx-loading-bar/core' import { logger } from '@root-helpers/logger' -import { VideoUpdate } from '@shared/models' +import { VideoUpdate } from '@peertube/peertube-models' import { hydrateFormFromVideo } from '../shared/video-edit-utils' import { VideoSend } from './video-send' diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-send.ts b/client/src/app/+videos/+video-edit/video-add-components/video-send.ts index 9de373cd3..56dcfa0e6 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-send.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-send.ts @@ -6,16 +6,16 @@ import { listUserChannelsForSelect } from '@app/helpers' import { FormReactive } from '@app/shared/shared-forms' import { VideoCaptionEdit, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' import { LoadingBarService } from '@ngx-loading-bar/core' -import { HTMLServerConfig, VideoConstant, VideoPrivacy } from '@shared/models' +import { HTMLServerConfig, VideoConstant, VideoPrivacyType } from '@peertube/peertube-models' @Directive() // eslint-disable-next-line @angular-eslint/directive-class-suffix export abstract class VideoSend extends FormReactive implements OnInit { userVideoChannels: SelectChannelItem[] = [] - videoPrivacies: VideoConstant[] = [] + videoPrivacies: VideoConstant[] = [] videoCaptions: VideoCaptionEdit[] = [] - firstStepPrivacyId: VideoPrivacy + firstStepPrivacyId: VideoPrivacyType firstStepChannelId: number abstract firstStepDone: EventEmitter @@ -31,7 +31,7 @@ export abstract class VideoSend extends FormReactive implements OnInit { protected serverConfig: HTMLServerConfig - protected highestPrivacy: VideoPrivacy + protected highestPrivacy: VideoPrivacyType abstract canDeactivate (): CanComponentDeactivateResult diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts index f7e1872a5..cbf43ee5f 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts @@ -10,7 +10,7 @@ import { FormReactiveService } from '@app/shared/shared-forms' import { Video, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' import { LoadingBarService } from '@ngx-loading-bar/core' import { logger } from '@root-helpers/logger' -import { HttpStatusCode, VideoCreateResult } from '@shared/models' +import { HttpStatusCode, VideoCreateResult } from '@peertube/peertube-models' import { VideoUploadService } from '../shared/video-upload.service' import { VideoSend } from './video-send' diff --git a/client/src/app/+videos/+video-edit/video-add.component.ts b/client/src/app/+videos/+video-edit/video-add.component.ts index 460c37a38..413fe4780 100644 --- a/client/src/app/+videos/+video-edit/video-add.component.ts +++ b/client/src/app/+videos/+video-edit/video-add.component.ts @@ -8,7 +8,7 @@ import { ServerService, UserService } from '@app/core' -import { HTMLServerConfig } from '@shared/models' +import { HTMLServerConfig } from '@peertube/peertube-models' import { VideoEditType } from './shared/video-edit.type' import { VideoGoLiveComponent } from './video-add-components/video-go-live.component' import { VideoImportTorrentComponent } from './video-add-components/video-import-torrent.component' diff --git a/client/src/app/+videos/+video-edit/video-update.component.ts b/client/src/app/+videos/+video-edit/video-update.component.ts index 6ad08cbad..24d91a69a 100644 --- a/client/src/app/+videos/+video-edit/video-update.component.ts +++ b/client/src/app/+videos/+video-edit/video-update.component.ts @@ -12,9 +12,8 @@ import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' import { Video, VideoCaptionEdit, VideoCaptionService, VideoDetails, VideoEdit, VideoService } from '@app/shared/shared-main' import { LiveVideoService } from '@app/shared/shared-video-live' import { LoadingBarService } from '@ngx-loading-bar/core' -import { pick, simpleObjectsDeepEqual } from '@shared/core-utils' -import { HttpStatusCode, LiveVideo, LiveVideoUpdate, VideoPrivacy, VideoState } from '@shared/models' -import { VideoSource } from '@shared/models/videos/video-source' +import { pick, simpleObjectsDeepEqual } from '@peertube/peertube-core-utils' +import { HttpStatusCode, LiveVideo, LiveVideoUpdate, VideoPrivacy, VideoSource, VideoState } from '@peertube/peertube-models' import { hydrateFormFromVideo } from './shared/video-edit-utils' import { VideoUploadService } from './shared/video-upload.service' diff --git a/client/src/app/+videos/+video-edit/video-update.resolver.ts b/client/src/app/+videos/+video-edit/video-update.resolver.ts index 2c99b36a8..d114bfb2d 100644 --- a/client/src/app/+videos/+video-edit/video-update.resolver.ts +++ b/client/src/app/+videos/+video-edit/video-update.resolver.ts @@ -4,9 +4,9 @@ import { Injectable } from '@angular/core' import { ActivatedRouteSnapshot } from '@angular/router' import { AuthService } from '@app/core' import { listUserChannelsForSelect } from '@app/helpers' -import { VideoCaptionService, VideoDetails, VideoService, VideoPasswordService } from '@app/shared/shared-main' +import { VideoCaptionService, VideoDetails, VideoPasswordService, VideoService } from '@app/shared/shared-main' import { LiveVideoService } from '@app/shared/shared-video-live' -import { VideoPrivacy } from '@shared/models/videos' +import { VideoPrivacy } from '@peertube/peertube-models' @Injectable() export class VideoUpdateResolver { diff --git a/client/src/app/+videos/+video-watch/shared/action-buttons/action-buttons.component.ts b/client/src/app/+videos/+video-watch/shared/action-buttons/action-buttons.component.ts index e6c0d4de1..7c89b7e62 100644 --- a/client/src/app/+videos/+video-watch/shared/action-buttons/action-buttons.component.ts +++ b/client/src/app/+videos/+video-watch/shared/action-buttons/action-buttons.component.ts @@ -5,7 +5,7 @@ import { VideoShareComponent } from '@app/shared/shared-share-modal' import { SupportModalComponent } from '@app/shared/shared-support-modal' import { VideoActionsDisplayType, VideoDownloadComponent } from '@app/shared/shared-video-miniature' import { VideoPlaylist } from '@app/shared/shared-video-playlist' -import { UserVideoRateType, VideoCaption, VideoPrivacy } from '@shared/models/videos' +import { UserVideoRateType, VideoCaption, VideoPrivacy } from '@peertube/peertube-models' @Component({ selector: 'my-action-buttons', diff --git a/client/src/app/+videos/+video-watch/shared/action-buttons/video-rate.component.ts b/client/src/app/+videos/+video-watch/shared/action-buttons/video-rate.component.ts index 11966ce34..13a709cb0 100644 --- a/client/src/app/+videos/+video-watch/shared/action-buttons/video-rate.component.ts +++ b/client/src/app/+videos/+video-watch/shared/action-buttons/video-rate.component.ts @@ -3,7 +3,7 @@ import { Observable } from 'rxjs' import { Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output } from '@angular/core' import { Notifier, ScreenService } from '@app/core' import { VideoDetails, VideoService } from '@app/shared/shared-main' -import { UserVideoRateType } from '@shared/models' +import { UserVideoRateType } from '@peertube/peertube-models' @Component({ selector: 'my-video-rate', diff --git a/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts b/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts index 1d9e10d0a..a01bd31fe 100644 --- a/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts +++ b/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts @@ -19,7 +19,7 @@ import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' import { Video } from '@app/shared/shared-main' import { VideoComment, VideoCommentService } from '@app/shared/shared-video-comment' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' -import { VideoCommentCreate } from '@shared/models' +import { VideoCommentCreate } from '@peertube/peertube-models' @Component({ selector: 'my-video-comment-add', diff --git a/client/src/app/+videos/+video-watch/shared/comment/video-comment.component.ts b/client/src/app/+videos/+video-watch/shared/comment/video-comment.component.ts index 4c85df657..14422010f 100644 --- a/client/src/app/+videos/+video-watch/shared/comment/video-comment.component.ts +++ b/client/src/app/+videos/+video-watch/shared/comment/video-comment.component.ts @@ -5,7 +5,7 @@ import { AuthService } from '@app/core/auth' import { Account, DropdownAction, Video } from '@app/shared/shared-main' import { CommentReportComponent } from '@app/shared/shared-moderation/report-modals/comment-report.component' import { VideoComment, VideoCommentThreadTree } from '@app/shared/shared-video-comment' -import { User, UserRight } from '@shared/models' +import { User, UserRight } from '@peertube/peertube-models' @Component({ selector: 'my-video-comment', diff --git a/client/src/app/+videos/+video-watch/shared/comment/video-comments.component.ts b/client/src/app/+videos/+video-watch/shared/comment/video-comments.component.ts index 848936f91..1a8c89bdc 100644 --- a/client/src/app/+videos/+video-watch/shared/comment/video-comments.component.ts +++ b/client/src/app/+videos/+video-watch/shared/comment/video-comments.component.ts @@ -5,7 +5,7 @@ import { AuthService, ComponentPagination, ConfirmService, hasMoreItems, Notifie import { HooksService } from '@app/core/plugins/hooks.service' import { Syndication, VideoDetails } from '@app/shared/shared-main' import { VideoComment, VideoCommentService, VideoCommentThreadTree } from '@app/shared/shared-video-comment' -import { PeerTubeProblemDocument, ServerErrorCode } from '@shared/models' +import { PeerTubeProblemDocument, ServerErrorCode } from '@peertube/peertube-models' @Component({ selector: 'my-video-comments', diff --git a/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts b/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts index b51457e02..d2f8aa45d 100644 --- a/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts +++ b/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts @@ -2,7 +2,7 @@ import { Component, Input, OnInit } from '@angular/core' import { ServerService, User, UserService } from '@app/core' import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' import { isP2PEnabled } from '@root-helpers/video' -import { HTMLServerConfig, Video } from '@shared/models' +import { HTMLServerConfig, Video } from '@peertube/peertube-models' @Component({ selector: 'my-privacy-concerns', diff --git a/client/src/app/+videos/+video-watch/shared/information/video-alert.component.ts b/client/src/app/+videos/+video-watch/shared/information/video-alert.component.ts index 8781ead7e..497c48813 100644 --- a/client/src/app/+videos/+video-watch/shared/information/video-alert.component.ts +++ b/client/src/app/+videos/+video-watch/shared/information/video-alert.component.ts @@ -1,7 +1,7 @@ import { Component, Input } from '@angular/core' import { AuthUser } from '@app/core' import { VideoDetails } from '@app/shared/shared-main' -import { VideoPrivacy, VideoState } from '@shared/models' +import { VideoPrivacy, VideoState } from '@peertube/peertube-models' @Component({ selector: 'my-video-alert', diff --git a/client/src/app/+videos/+video-watch/shared/playlist/video-watch-playlist.component.ts b/client/src/app/+videos/+video-watch/shared/playlist/video-watch-playlist.component.ts index 97d71a510..eca7cf87c 100644 --- a/client/src/app/+videos/+video-watch/shared/playlist/video-watch-playlist.component.ts +++ b/client/src/app/+videos/+video-watch/shared/playlist/video-watch-playlist.component.ts @@ -5,7 +5,7 @@ import { isInViewport } from '@app/helpers' import { VideoPlaylist, VideoPlaylistElement, VideoPlaylistService } from '@app/shared/shared-video-playlist' import { getBoolOrDefault } from '@root-helpers/local-storage-utils' import { peertubeSessionStorage } from '@root-helpers/peertube-web-storage' -import { VideoPlaylistPrivacy } from '@shared/models' +import { VideoPlaylistPrivacy } from '@peertube/peertube-models' @Component({ selector: 'my-video-watch-playlist', diff --git a/client/src/app/+videos/+video-watch/shared/recommendations/recent-videos-recommendation.service.ts b/client/src/app/+videos/+video-watch/shared/recommendations/recent-videos-recommendation.service.ts index ba0d30f3d..174fd6610 100644 --- a/client/src/app/+videos/+video-watch/shared/recommendations/recent-videos-recommendation.service.ts +++ b/client/src/app/+videos/+video-watch/shared/recommendations/recent-videos-recommendation.service.ts @@ -4,7 +4,7 @@ import { Injectable } from '@angular/core' import { ServerService, UserService } from '@app/core' import { Video, VideoService } from '@app/shared/shared-main' import { AdvancedSearch, SearchService } from '@app/shared/shared-search' -import { HTMLServerConfig } from '@shared/models' +import { HTMLServerConfig } from '@peertube/peertube-models' import { RecommendationInfo } from './recommendation-info.model' import { RecommendationService } from './recommendations.service' diff --git a/client/src/app/+videos/+video-watch/video-watch.component.ts b/client/src/app/+videos/+video-watch/video-watch.component.ts index 45de62519..f109427cc 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.ts +++ b/client/src/app/+videos/+video-watch/video-watch.component.ts @@ -22,9 +22,7 @@ import { Video, VideoCaptionService, VideoDetails, VideoFileTokenService, VideoS import { SubscribeButtonComponent } from '@app/shared/shared-user-subscription' import { LiveVideoService } from '@app/shared/shared-video-live' import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist' -import { logger } from '@root-helpers/logger' -import { isP2PEnabled, videoRequiresFileToken, videoRequiresUserAuth } from '@root-helpers/video' -import { timeToInt } from '@shared/core-utils' +import { timeToInt } from '@peertube/peertube-core-utils' import { HTMLServerConfig, HttpStatusCode, @@ -34,8 +32,11 @@ import { Storyboard, VideoCaption, VideoPrivacy, - VideoState -} from '@shared/models' + VideoState, + VideoStateType +} from '@peertube/peertube-models' +import { logger } from '@root-helpers/logger' +import { isP2PEnabled, videoRequiresFileToken, videoRequiresUserAuth } from '@root-helpers/video' import { HLSOptions, PeerTubePlayer, @@ -812,7 +813,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { }) } - private handleLiveStateChange (newState: VideoState) { + private handleLiveStateChange (newState: VideoStateType) { if (newState !== VideoState.PUBLISHED) return logger.info('Loading video after live update.') diff --git a/client/src/app/+videos/video-list/overview/overview.service.ts b/client/src/app/+videos/video-list/overview/overview.service.ts index 67a1adb28..581c6b846 100644 --- a/client/src/app/+videos/video-list/overview/overview.service.ts +++ b/client/src/app/+videos/video-list/overview/overview.service.ts @@ -5,9 +5,8 @@ import { Injectable } from '@angular/core' import { RestExtractor, ServerService } from '@app/core' import { immutableAssign } from '@app/helpers' import { VideoService } from '@app/shared/shared-main' -import { objectKeysTyped } from '@shared/core-utils' -import { peertubeTranslate } from '@shared/core-utils/i18n' -import { VideosOverview as VideosOverviewServer } from '@shared/models' +import { objectKeysTyped, peertubeTranslate } from '@peertube/peertube-core-utils' +import { VideosOverview as VideosOverviewServer } from '@peertube/peertube-models' import { environment } from '../../../../environments/environment' import { VideosOverview } from './videos-overview.model' diff --git a/client/src/app/+videos/video-list/overview/videos-overview.model.ts b/client/src/app/+videos/video-list/overview/videos-overview.model.ts index 6765ad9b7..1208d5a00 100644 --- a/client/src/app/+videos/video-list/overview/videos-overview.model.ts +++ b/client/src/app/+videos/video-list/overview/videos-overview.model.ts @@ -1,5 +1,5 @@ import { Video } from '@app/shared/shared-main' -import { VideoChannelSummary, VideoConstant, VideosOverview as VideosOverviewServer } from '@shared/models' +import { VideoChannelSummary, VideoConstant, VideosOverview as VideosOverviewServer } from '@peertube/peertube-models' export class VideosOverview implements VideosOverviewServer { channels: { diff --git a/client/src/app/+videos/video-list/video-user-subscriptions.component.ts b/client/src/app/+videos/video-list/video-user-subscriptions.component.ts index 04f02c138..c9926488d 100644 --- a/client/src/app/+videos/video-list/video-user-subscriptions.component.ts +++ b/client/src/app/+videos/video-list/video-user-subscriptions.component.ts @@ -7,7 +7,7 @@ import { HooksService } from '@app/core/plugins/hooks.service' import { VideoService } from '@app/shared/shared-main' import { UserSubscriptionService } from '@app/shared/shared-user-subscription' import { VideoFilters } from '@app/shared/shared-video-miniature' -import { VideoSortField } from '@shared/models' +import { VideoSortField } from '@peertube/peertube-models' @Component({ selector: 'my-videos-user-subscriptions', diff --git a/client/src/app/+videos/video-list/videos-list-common-page.component.ts b/client/src/app/+videos/video-list/videos-list-common-page.component.ts index c8fa8ef30..32954f373 100644 --- a/client/src/app/+videos/video-list/videos-list-common-page.component.ts +++ b/client/src/app/+videos/video-list/videos-list-common-page.component.ts @@ -4,7 +4,7 @@ import { ComponentPaginationLight, DisableForReuseHook, MetaService, RedirectSer import { HooksService } from '@app/core/plugins/hooks.service' import { VideoService } from '@app/shared/shared-main' import { VideoFilters, VideoFilterScope } from '@app/shared/shared-video-miniature/video-filters.model' -import { ClientFilterHookName, VideoSortField } from '@shared/models' +import { ClientFilterHookName, VideoSortField } from '@peertube/peertube-models' import { Subscription } from 'rxjs' export type VideosListCommonPageRouteData = { diff --git a/client/src/app/app-routing.module.ts b/client/src/app/app-routing.module.ts index 40e4ec35d..360524d69 100644 --- a/client/src/app/app-routing.module.ts +++ b/client/src/app/app-routing.module.ts @@ -2,7 +2,7 @@ import { NgModule } from '@angular/core' import { RouteReuseStrategy, RouterModule, Routes, UrlMatchResult, UrlSegment } from '@angular/router' import { CustomReuseStrategy } from '@app/core/routing/custom-reuse-strategy' import { MenuGuards } from '@app/core/routing/menu-guard.service' -import { POSSIBLE_LOCALES } from '@shared/core-utils/i18n' +import { POSSIBLE_LOCALES } from '@peertube/peertube-core-utils' import { HomepageRedirectComponent, MetaGuard, PreloadSelectedModulesList } from './core' import { EmptyComponent } from './empty.component' import { USER_USERNAME_REGEX_CHARACTERS } from './shared/form-validators/user-validators' diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts index f6d90cb64..4ad20bfd6 100644 --- a/client/src/app/app.component.ts +++ b/client/src/app/app.component.ts @@ -25,10 +25,10 @@ import { CustomModalComponent } from '@app/modal/custom-modal.component' import { InstanceConfigWarningModalComponent } from '@app/modal/instance-config-warning-modal.component' import { NgbConfig, NgbModal } from '@ng-bootstrap/ng-bootstrap' import { LoadingBarService } from '@ngx-loading-bar/core' +import { getShortLocale } from '@peertube/peertube-core-utils' +import { BroadcastMessageLevel, HTMLServerConfig, UserRole } from '@peertube/peertube-models' import { logger } from '@root-helpers/logger' import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' -import { getShortLocale } from '@shared/core-utils/i18n' -import { BroadcastMessageLevel, HTMLServerConfig, UserRole } from '@shared/models' import { MenuService } from './core/menu/menu.service' import { POP_STATE_MODAL_DISMISS } from './helpers' import { GlobalIconName } from './shared/shared-icons' diff --git a/client/src/app/core/auth/auth-user.model.ts b/client/src/app/core/auth/auth-user.model.ts index 226075265..a1e23bfbb 100644 --- a/client/src/app/core/auth/auth-user.model.ts +++ b/client/src/app/core/auth/auth-user.model.ts @@ -1,16 +1,16 @@ import { Observable, of } from 'rxjs' import { map } from 'rxjs/operators' import { User } from '@app/core/users/user.model' -import { OAuthUserTokens } from '@root-helpers/users' -import { hasUserRight } from '@shared/core-utils/users' +import { hasUserRight } from '@peertube/peertube-core-utils' import { MyUser as ServerMyUserModel, MyUserSpecialPlaylist, User as ServerUserModel, - UserRight, + UserRightType, UserRole, UserVideoQuota -} from '@shared/models' +} from '@peertube/peertube-models' +import { OAuthUserTokens } from '@root-helpers/users' export class AuthUser extends User implements ServerMyUserModel { oauthTokens: OAuthUserTokens @@ -42,7 +42,7 @@ export class AuthUser extends User implements ServerMyUserModel { this.oauthTokens.refreshToken = refreshToken } - hasRight (right: UserRight) { + hasRight (right: UserRightType) { return hasUserRight(this.role.id, right) } diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts index 6fe601d8d..bc67ab7a0 100644 --- a/client/src/app/core/auth/auth.service.ts +++ b/client/src/app/core/auth/auth.service.ts @@ -6,7 +6,7 @@ import { Injectable } from '@angular/core' import { Router } from '@angular/router' import { Notifier } from '@app/core/notification/notifier.service' import { logger, OAuthUserTokens, objectToUrlEncoded, peertubeLocalStorage } from '@root-helpers/index' -import { HttpStatusCode, MyUser as UserServerModel, OAuthClientLocal, User, UserLogin, UserRefreshToken } from '@shared/models' +import { HttpStatusCode, MyUser as UserServerModel, OAuthClientLocal, User, UserLogin, UserRefreshToken } from '@peertube/peertube-models' import { environment } from '../../../environments/environment' import { RestExtractor } from '../rest/rest-extractor.service' import { RedirectService } from '../routing' diff --git a/client/src/app/core/menu/menu.service.ts b/client/src/app/core/menu/menu.service.ts index d865c7da2..39e89f6e3 100644 --- a/client/src/app/core/menu/menu.service.ts +++ b/client/src/app/core/menu/menu.service.ts @@ -2,7 +2,7 @@ import { fromEvent } from 'rxjs' import { debounceTime } from 'rxjs/operators' import { Injectable } from '@angular/core' import { GlobalIconName } from '@app/shared/shared-icons' -import { HTMLServerConfig } from '@shared/models/server' +import { HTMLServerConfig } from '@peertube/peertube-models' import { ScreenService } from '../wrappers' export type MenuLink = { diff --git a/client/src/app/core/notification/peertube-socket.service.ts b/client/src/app/core/notification/peertube-socket.service.ts index 50a11e948..15af9a310 100644 --- a/client/src/app/core/notification/peertube-socket.service.ts +++ b/client/src/app/core/notification/peertube-socket.service.ts @@ -1,7 +1,7 @@ import { Subject } from 'rxjs' import { ManagerOptions, Socket, SocketOptions } from 'socket.io-client' import { Injectable } from '@angular/core' -import { LiveVideoEventPayload, LiveVideoEventType, UserNotification as UserNotificationServer } from '@shared/models' +import { LiveVideoEventPayload, LiveVideoEventType, UserNotification as UserNotificationServer } from '@peertube/peertube-models' import { environment } from '../../../environments/environment' import { AuthService } from '../auth' diff --git a/client/src/app/core/plugins/hooks.service.ts b/client/src/app/core/plugins/hooks.service.ts index d9fef8389..59c627c05 100644 --- a/client/src/app/core/plugins/hooks.service.ts +++ b/client/src/app/core/plugins/hooks.service.ts @@ -3,7 +3,7 @@ import { mergeMap, switchMap } from 'rxjs/operators' import { Injectable } from '@angular/core' import { PluginService } from '@app/core/plugins/plugin.service' import { logger } from '@root-helpers/logger' -import { ClientActionHookName, ClientFilterHookName, PluginClientScope } from '@shared/models' +import { ClientActionHookName, ClientFilterHookName, PluginClientScope } from '@peertube/peertube-models' import { AuthService, AuthStatus } from '../auth' type RawFunction = (params: U) => T diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts index bd8c61d9a..d37b2e5f7 100644 --- a/client/src/app/core/plugins/plugin.service.ts +++ b/client/src/app/core/plugins/plugin.service.ts @@ -10,22 +10,22 @@ import { RestExtractor } from '@app/core/rest' import { ServerService } from '@app/core/server/server.service' import { getDevLocale, isOnDevLocale } from '@app/helpers' import { CustomModalComponent } from '@app/modal/custom-modal.component' -import { PluginInfo, PluginsManager } from '@root-helpers/plugins-manager' -import { getKeys } from '@shared/core-utils' -import { getCompleteLocale, isDefaultLocale, peertubeTranslate } from '@shared/core-utils/i18n' +import { getCompleteLocale, getKeys, isDefaultLocale, peertubeTranslate } from '@peertube/peertube-core-utils' import { ClientHook, ClientHookName, PluginClientScope, PluginTranslation, PluginType, + PluginType_Type, PublicServerSetting, RegisterClientFormFieldOptions, RegisterClientRouteOptions, RegisterClientSettingsScriptOptions, RegisterClientVideoFieldOptions, ServerConfigPlugin -} from '@shared/models' +} from '@peertube/peertube-models' +import { PluginInfo, PluginsManager } from '@root-helpers/plugins-manager' import { environment } from '../../../environments/environment' import { RegisterClientHelpers } from '../../../types/register-client-option.model' @@ -110,7 +110,7 @@ export class PluginService implements ClientHook { return this.pluginsManager.removePlugin(plugin) } - nameToNpmName (name: string, type: PluginType) { + nameToNpmName (name: string, type: PluginType_Type) { const prefix = type === PluginType.PLUGIN ? 'peertube-plugin-' : 'peertube-theme-' diff --git a/client/src/app/core/renderer/html-renderer.service.ts b/client/src/app/core/renderer/html-renderer.service.ts index 7776ccad5..37741c079 100644 --- a/client/src/app/core/renderer/html-renderer.service.ts +++ b/client/src/app/core/renderer/html-renderer.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core' -import { getCustomMarkupSanitizeOptions, getDefaultSanitizeOptions } from '@shared/core-utils/renderer/html' +import { getCustomMarkupSanitizeOptions, getDefaultSanitizeOptions } from '@peertube/peertube-core-utils' import { LinkifierService } from './linkifier.service' @Injectable() diff --git a/client/src/app/core/renderer/markdown.service.ts b/client/src/app/core/renderer/markdown.service.ts index ec3b683bb..907b92232 100644 --- a/client/src/app/core/renderer/markdown.service.ts +++ b/client/src/app/core/renderer/markdown.service.ts @@ -1,13 +1,14 @@ import * as MarkdownIt from 'markdown-it' import { Injectable } from '@angular/core' -import { buildVideoLink, decorateVideoLink } from '@shared/core-utils' import { + buildVideoLink, COMPLETE_RULES, + decorateVideoLink, ENHANCED_RULES, ENHANCED_WITH_HTML_RULES, TEXT_RULES, TEXT_WITH_HTML_RULES -} from '@shared/core-utils/renderer/markdown' +} from '@peertube/peertube-core-utils' import { HtmlRendererService } from './html-renderer.service' type MarkdownParsers = { diff --git a/client/src/app/core/rest/rest-extractor.service.ts b/client/src/app/core/rest/rest-extractor.service.ts index c6c1e183f..bcc50c0f4 100644 --- a/client/src/app/core/rest/rest-extractor.service.ts +++ b/client/src/app/core/rest/rest-extractor.service.ts @@ -1,10 +1,10 @@ import { throwError as observableThrowError } from 'rxjs' +import { HttpHeaderResponse } from '@angular/common/http' import { Inject, Injectable, LOCALE_ID } from '@angular/core' import { Router } from '@angular/router' import { DateFormat, dateToHuman } from '@app/helpers' +import { HttpStatusCode, HttpStatusCodeType, ResultList } from '@peertube/peertube-models' import { logger } from '@root-helpers/logger' -import { HttpStatusCode, ResultList } from '@shared/models' -import { HttpHeaderResponse } from '@angular/common/http' @Injectable() export class RestExtractor { @@ -45,7 +45,11 @@ export class RestExtractor { return target } - redirectTo404IfNotFound (obj: { status: number }, type: 'video' | 'other', status = [ HttpStatusCode.NOT_FOUND_404 ]) { + redirectTo404IfNotFound ( + obj: { status: HttpStatusCodeType }, + type: 'video' | 'other', + status: HttpStatusCodeType[] = [ HttpStatusCode.NOT_FOUND_404 ] + ) { if (obj?.status && status.includes(obj.status)) { // Do not use redirectService to avoid circular dependencies this.router.navigate([ '/404' ], { state: { type, obj }, skipLocationChange: true }) diff --git a/client/src/app/core/routing/homepage-redirect.component.ts b/client/src/app/core/routing/homepage-redirect.component.ts index 9e3848038..e9be832e0 100644 --- a/client/src/app/core/routing/homepage-redirect.component.ts +++ b/client/src/app/core/routing/homepage-redirect.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit } from '@angular/core' import { ActivatedRoute } from '@angular/router' -import { is18nPath } from '@shared/core-utils/i18n/i18n' +import { is18nPath } from '@peertube/peertube-core-utils' import { RedirectService } from './redirect.service' /* diff --git a/client/src/app/core/routing/meta.service.ts b/client/src/app/core/routing/meta.service.ts index 97e440faf..d50f0d65a 100644 --- a/client/src/app/core/routing/meta.service.ts +++ b/client/src/app/core/routing/meta.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core' import { Meta, Title } from '@angular/platform-browser' -import { HTMLServerConfig } from '@shared/models/server' +import { HTMLServerConfig } from '@peertube/peertube-models' import { ServerService } from '../server' export interface MetaSettings { diff --git a/client/src/app/core/scoped-tokens/scoped-tokens.service.ts b/client/src/app/core/scoped-tokens/scoped-tokens.service.ts index 038e5031c..f7d192feb 100644 --- a/client/src/app/core/scoped-tokens/scoped-tokens.service.ts +++ b/client/src/app/core/scoped-tokens/scoped-tokens.service.ts @@ -1,7 +1,7 @@ import { catchError } from 'rxjs/operators' import { HttpClient } from '@angular/common/http' import { Injectable } from '@angular/core' -import { ScopedToken } from '@shared/models/users/user-scoped-token' +import { ScopedToken } from '@peertube/peertube-models' import { environment } from '../../../environments/environment' import { RestExtractor } from '../rest' diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts index 41cb4791a..75ac8ddc1 100644 --- a/client/src/app/core/server/server.service.ts +++ b/client/src/app/core/server/server.service.ts @@ -3,9 +3,16 @@ import { first, map, share, shareReplay, switchMap, tap } from 'rxjs/operators' import { HttpClient } from '@angular/common/http' import { Inject, Injectable, LOCALE_ID } from '@angular/core' import { getDevLocale, isOnDevLocale } from '@app/helpers' +import { getCompleteLocale, isDefaultLocale, peertubeTranslate } from '@peertube/peertube-core-utils' +import { + HTMLServerConfig, + ServerConfig, + ServerStats, + VideoConstant, + VideoPlaylistPrivacyType, + VideoPrivacyType +} from '@peertube/peertube-models' import { logger } from '@root-helpers/logger' -import { getCompleteLocale, isDefaultLocale, peertubeTranslate } from '@shared/core-utils/i18n' -import { HTMLServerConfig, ServerConfig, ServerStats, VideoConstant } from '@shared/models' import { environment } from '../../../environments/environment' @Injectable() @@ -21,8 +28,8 @@ export class ServerService { private localeObservable: Observable private videoLicensesObservable: Observable[]> private videoCategoriesObservable: Observable[]> - private videoPrivaciesObservable: Observable[]> - private videoPlaylistPrivaciesObservable: Observable[]> + private videoPrivaciesObservable: Observable[]> + private videoPlaylistPrivaciesObservable: Observable[]> private videoLanguagesObservable: Observable[]> private configObservable: Observable @@ -123,7 +130,7 @@ export class ServerService { getVideoPrivacies () { if (!this.videoPrivaciesObservable) { - this.videoPrivaciesObservable = this.loadAttributeEnum(ServerService.BASE_VIDEO_URL, 'privacies') + this.videoPrivaciesObservable = this.loadAttributeEnum(ServerService.BASE_VIDEO_URL, 'privacies') } return this.videoPrivaciesObservable.pipe(first()) @@ -131,7 +138,10 @@ export class ServerService { getVideoPlaylistPrivacies () { if (!this.videoPlaylistPrivaciesObservable) { - this.videoPlaylistPrivaciesObservable = this.loadAttributeEnum(ServerService.BASE_VIDEO_PLAYLIST_URL, 'privacies') + this.videoPlaylistPrivaciesObservable = this.loadAttributeEnum( + ServerService.BASE_VIDEO_PLAYLIST_URL, + 'privacies' + ) } return this.videoPlaylistPrivaciesObservable.pipe(first()) diff --git a/client/src/app/core/theme/theme.service.ts b/client/src/app/core/theme/theme.service.ts index ead1770ba..22eb5ddd3 100644 --- a/client/src/app/core/theme/theme.service.ts +++ b/client/src/app/core/theme/theme.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core' import { logger } from '@root-helpers/logger' import { capitalizeFirstLetter } from '@root-helpers/string' import { UserLocalStorageKeys } from '@root-helpers/users' -import { HTMLServerConfig, ServerConfigTheme } from '@shared/models' +import { HTMLServerConfig, ServerConfigTheme } from '@peertube/peertube-models' import { environment } from '../../../environments/environment' import { AuthService } from '../auth' import { PluginService } from '../plugins/plugin.service' diff --git a/client/src/app/core/users/user-local-storage.service.ts b/client/src/app/core/users/user-local-storage.service.ts index a87f3b98a..431a57343 100644 --- a/client/src/app/core/users/user-local-storage.service.ts +++ b/client/src/app/core/users/user-local-storage.service.ts @@ -1,13 +1,11 @@ - import { filter, throttleTime } from 'rxjs' import { Injectable } from '@angular/core' import { AuthService, AuthStatus } from '@app/core/auth' +import { objectKeysTyped } from '@peertube/peertube-core-utils' +import { NSFWPolicyType, UserRoleType, UserUpdateMe } from '@peertube/peertube-models' import { getBoolOrDefault } from '@root-helpers/local-storage-utils' import { logger } from '@root-helpers/logger' import { OAuthUserTokens, UserLocalStorageKeys } from '@root-helpers/users' -import { objectKeysTyped } from '@shared/core-utils' -import { UserRole, UserUpdateMe } from '@shared/models' -import { NSFWPolicyType } from '@shared/models/videos' import { ServerService } from '../server' import { LocalStorageService } from '../wrappers/storage.service' @@ -61,7 +59,7 @@ export class UserLocalStorageService { username: this.localStorageService.getItem(UserLocalStorageKeys.USERNAME), email: this.localStorageService.getItem(UserLocalStorageKeys.EMAIL), role: { - id: parseInt(this.localStorageService.getItem(UserLocalStorageKeys.ROLE), 10) as UserRole, + id: parseInt(this.localStorageService.getItem(UserLocalStorageKeys.ROLE), 10) as UserRoleType, label: '' }, @@ -74,7 +72,7 @@ export class UserLocalStorageService { username: string email: string role: { - id: UserRole + id: UserRoleType } }) { this.localStorageService.setItem(UserLocalStorageKeys.ID, user.id.toString()) diff --git a/client/src/app/core/users/user.model.ts b/client/src/app/core/users/user.model.ts index 54b749a4c..ffc7c2b44 100644 --- a/client/src/app/core/users/user.model.ts +++ b/client/src/app/core/users/user.model.ts @@ -1,17 +1,18 @@ import { Account } from '@app/shared/shared-main/account/account.model' -import { objectKeysTyped } from '@shared/core-utils' -import { hasUserRight } from '@shared/core-utils/users' +import { hasUserRight, objectKeysTyped } from '@peertube/peertube-core-utils' import { ActorImage, HTMLServerConfig, NSFWPolicyType, User as UserServerModel, UserAdminFlag, + UserAdminFlagType, UserNotificationSetting, - UserRight, + UserRightType, UserRole, + UserRoleType, VideoChannel -} from '@shared/models' +} from '@peertube/peertube-models' export class User implements UserServerModel { id: number @@ -23,7 +24,7 @@ export class User implements UserServerModel { emailPublic: boolean nsfwPolicy: NSFWPolicyType - adminFlags?: UserAdminFlag + adminFlags?: UserAdminFlagType autoPlayVideo: boolean autoPlayNextVideo: boolean @@ -35,7 +36,7 @@ export class User implements UserServerModel { videoLanguages: string[] role: { - id: UserRole + id: UserRoleType label: string } @@ -124,7 +125,7 @@ export class User implements UserServerModel { } } - hasRight (right: UserRight) { + hasRight (right: UserRightType) { return hasUserRight(this.role.id, right) } diff --git a/client/src/app/core/users/user.service.ts b/client/src/app/core/users/user.service.ts index b4024c02d..7ad0ee9bf 100644 --- a/client/src/app/core/users/user.service.ts +++ b/client/src/app/core/users/user.service.ts @@ -3,7 +3,7 @@ import { catchError, first, map, shareReplay } from 'rxjs/operators' import { HttpClient, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' import { AuthService } from '@app/core/auth' -import { ActorImage, User as UserServerModel, UserUpdateMe, UserVideoQuota } from '@shared/models' +import { ActorImage, User as UserServerModel, UserUpdateMe, UserVideoQuota } from '@peertube/peertube-models' import { environment } from '../../../environments/environment' import { RestExtractor } from '../rest' import { UserLocalStorageService } from './user-local-storage.service' diff --git a/client/src/app/header/search-typeahead.component.ts b/client/src/app/header/search-typeahead.component.ts index d2549315c..a3a04041f 100644 --- a/client/src/app/header/search-typeahead.component.ts +++ b/client/src/app/header/search-typeahead.component.ts @@ -5,7 +5,7 @@ import { AfterViewChecked, Component, OnDestroy, OnInit, QueryList, ViewChildren import { ActivatedRoute, Params, Router } from '@angular/router' import { AuthService, ServerService } from '@app/core' import { logger } from '@root-helpers/logger' -import { HTMLServerConfig, SearchTargetType } from '@shared/models' +import { HTMLServerConfig, SearchTargetType } from '@peertube/peertube-models' import { SuggestionComponent, SuggestionPayload, SuggestionPayloadType } from './suggestion.component' @Component({ diff --git a/client/src/app/helpers/utils/channel.ts b/client/src/app/helpers/utils/channel.ts index 83f36b70f..fe59ea567 100644 --- a/client/src/app/helpers/utils/channel.ts +++ b/client/src/app/helpers/utils/channel.ts @@ -1,7 +1,7 @@ import { minBy } from 'lodash-es' import { first, map } from 'rxjs/operators' import { SelectChannelItem } from 'src/types/select-options-item.model' -import { VideoChannel } from '@shared/models' +import { VideoChannel } from '@peertube/peertube-models' import { AuthService } from '../../core/auth' function listUserChannelsForSelect (authService: AuthService) { diff --git a/client/src/app/helpers/utils/upload.ts b/client/src/app/helpers/utils/upload.ts index b60951612..b55415064 100644 --- a/client/src/app/helpers/utils/upload.ts +++ b/client/src/app/helpers/utils/upload.ts @@ -1,6 +1,6 @@ import { HttpErrorResponse } from '@angular/common/http' import { Notifier } from '@app/core' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode } from '@peertube/peertube-models' function genericUploadErrorHandler (options: { err: Pick diff --git a/client/src/app/menu/language-chooser.component.ts b/client/src/app/menu/language-chooser.component.ts index f7ae69717..1ec5987c2 100644 --- a/client/src/app/menu/language-chooser.component.ts +++ b/client/src/app/menu/language-chooser.component.ts @@ -1,8 +1,7 @@ import { Component, ElementRef, Inject, LOCALE_ID, ViewChild } from '@angular/core' import { getDevLocale, isOnDevLocale, sortBy } from '@app/helpers' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' -import { objectKeysTyped } from '@shared/core-utils' -import { getCompleteLocale, getShortLocale, I18N_LOCALES } from '@shared/core-utils/i18n' +import { getCompleteLocale, getShortLocale, I18N_LOCALES, objectKeysTyped } from '@peertube/peertube-core-utils' @Component({ selector: 'my-language-chooser', diff --git a/client/src/app/menu/menu.component.ts b/client/src/app/menu/menu.component.ts index 410abe6fa..6d309f15a 100644 --- a/client/src/app/menu/menu.component.ts +++ b/client/src/app/menu/menu.component.ts @@ -22,7 +22,7 @@ import { LanguageChooserComponent } from '@app/menu/language-chooser.component' import { QuickSettingsModalComponent } from '@app/modal/quick-settings-modal.component' import { PeertubeModalService } from '@app/shared/shared-main/peertube-modal/peertube-modal.service' import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap' -import { HTMLServerConfig, ServerConfig, UserRight, VideoConstant } from '@shared/models' +import { HTMLServerConfig, ServerConfig, UserRight, UserRightType, VideoConstant } from '@peertube/peertube-models' const debugLogger = debug('peertube:menu:MenuComponent') @@ -54,7 +54,7 @@ export class MenuComponent implements OnInit, OnDestroy { private htmlServerConfig: HTMLServerConfig private serverConfig: ServerConfig - private routesPerRight: { [role in UserRight]?: string } = { + private routesPerRight: { [role in UserRightType]?: string } = { [UserRight.MANAGE_USERS]: '/admin/users', [UserRight.MANAGE_SERVER_FOLLOW]: '/admin/friends', [UserRight.MANAGE_ABUSES]: '/admin/moderation/abuses', diff --git a/client/src/app/modal/instance-config-warning-modal.component.ts b/client/src/app/modal/instance-config-warning-modal.component.ts index 23c2c777e..f8ab155ae 100644 --- a/client/src/app/modal/instance-config-warning-modal.component.ts +++ b/client/src/app/modal/instance-config-warning-modal.component.ts @@ -2,9 +2,9 @@ import { Location } from '@angular/common' import { Component, ElementRef, ViewChild } from '@angular/core' import { Notifier, User, UserService } from '@app/core' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' +import { About, ServerConfig } from '@peertube/peertube-models' import { logger } from '@root-helpers/logger' import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' -import { About, ServerConfig } from '@shared/models/server' @Component({ selector: 'my-instance-config-warning-modal', diff --git a/client/src/app/shared/form-validators/video-playlist-validators.ts b/client/src/app/shared/form-validators/video-playlist-validators.ts index 63af637a3..3cddcaad2 100644 --- a/client/src/app/shared/form-validators/video-playlist-validators.ts +++ b/client/src/app/shared/form-validators/video-playlist-validators.ts @@ -1,6 +1,6 @@ import { Validators, AbstractControl } from '@angular/forms' import { BuildFormValidator } from './form-validator.model' -import { VideoPlaylistPrivacy } from '@shared/models' +import { VideoPlaylistPrivacy, VideoPlaylistPrivacyType } from '@peertube/peertube-models' export const VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR: BuildFormValidator = { VALIDATORS: [ @@ -42,7 +42,7 @@ export const VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR: BuildFormValidator = { } } -export function setPlaylistChannelValidator (channelControl: AbstractControl, privacy: VideoPlaylistPrivacy) { +export function setPlaylistChannelValidator (channelControl: AbstractControl, privacy: VideoPlaylistPrivacyType) { if (privacy.toString() === VideoPlaylistPrivacy.PUBLIC.toString()) { channelControl.setValidators([ Validators.required ]) } else { diff --git a/client/src/app/shared/shared-abuse-list/abuse-details.component.ts b/client/src/app/shared/shared-abuse-list/abuse-details.component.ts index e15edf8c2..357dc4522 100644 --- a/client/src/app/shared/shared-abuse-list/abuse-details.component.ts +++ b/client/src/app/shared/shared-abuse-list/abuse-details.component.ts @@ -1,6 +1,6 @@ import { Component, Input, OnInit } from '@angular/core' import { durationToString } from '@app/helpers' -import { AbusePredefinedReasonsString } from '@shared/models' +import { AbusePredefinedReasonsString } from '@peertube/peertube-models' import { ProcessedAbuse } from './processed-abuse.model' @Component({ diff --git a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts index d8470e927..c38e1286f 100644 --- a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts +++ b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts @@ -7,8 +7,8 @@ import { ConfirmService, MarkdownService, Notifier, RestPagination, RestTable } import { Account, Actor, DropdownAction, Video, VideoService } from '@app/shared/shared-main' import { AbuseService, BlocklistService, VideoBlockService } from '@app/shared/shared-moderation' import { VideoCommentService } from '@app/shared/shared-video-comment' +import { AbuseState, AbuseStateType, AdminAbuse } from '@peertube/peertube-models' import { logger } from '@root-helpers/logger' -import { AbuseState, AdminAbuse } from '@shared/models' import { AdvancedInputFilter } from '../shared-forms' import { AbuseMessageModalComponent } from './abuse-message-modal.component' import { ModerationCommentModalComponent } from './moderation-comment-modal.component' @@ -144,7 +144,7 @@ export class AbuseListTableComponent extends RestTable implements OnInit { }) } - updateAbuseState (abuse: AdminAbuse, state: AbuseState) { + updateAbuseState (abuse: AdminAbuse, state: AbuseStateType) { this.abuseService.updateAbuse(abuse, { state }) .subscribe({ next: () => this.reloadData(), diff --git a/client/src/app/shared/shared-abuse-list/abuse-message-modal.component.ts b/client/src/app/shared/shared-abuse-list/abuse-message-modal.component.ts index 12d503f56..8d20166f6 100644 --- a/client/src/app/shared/shared-abuse-list/abuse-message-modal.component.ts +++ b/client/src/app/shared/shared-abuse-list/abuse-message-modal.component.ts @@ -4,7 +4,7 @@ import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' import { logger } from '@root-helpers/logger' -import { AbuseMessage, UserAbuse } from '@shared/models' +import { AbuseMessage, UserAbuse } from '@peertube/peertube-models' import { ABUSE_MESSAGE_VALIDATOR } from '../form-validators/abuse-validators' import { AbuseService } from '../shared-moderation' diff --git a/client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.ts b/client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.ts index 4ad807d25..e42939f96 100644 --- a/client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.ts +++ b/client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.ts @@ -4,7 +4,7 @@ import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' import { AbuseService } from '@app/shared/shared-moderation' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' -import { AdminAbuse } from '@shared/models' +import { AdminAbuse } from '@peertube/peertube-models' import { ABUSE_MODERATION_COMMENT_VALIDATOR } from '../form-validators/abuse-validators' @Component({ diff --git a/client/src/app/shared/shared-abuse-list/processed-abuse.model.ts b/client/src/app/shared/shared-abuse-list/processed-abuse.model.ts index b9a9bd889..076ccb40b 100644 --- a/client/src/app/shared/shared-abuse-list/processed-abuse.model.ts +++ b/client/src/app/shared/shared-abuse-list/processed-abuse.model.ts @@ -1,5 +1,5 @@ import { Account } from '@app/shared/shared-main' -import { AdminAbuse } from '@shared/models' +import { AdminAbuse } from '@peertube/peertube-models' // Don't use an abuse model because we need external services to compute some properties // And this model is only used in this component diff --git a/client/src/app/shared/shared-actor-image/actor-avatar.component.ts b/client/src/app/shared/shared-actor-image/actor-avatar.component.ts index ab2e02ad7..36babbe34 100644 --- a/client/src/app/shared/shared-actor-image/actor-avatar.component.ts +++ b/client/src/app/shared/shared-actor-image/actor-avatar.component.ts @@ -1,7 +1,7 @@ import { Component, Input, OnChanges, OnInit } from '@angular/core' import { VideoChannel } from '../shared-main' import { Account } from '../shared-main/account/account.model' -import { objectKeysTyped } from '@shared/core-utils' +import { objectKeysTyped } from '@peertube/peertube-core-utils' type ActorInput = { name: string diff --git a/client/src/app/shared/shared-custom-markup/custom-markup.service.ts b/client/src/app/shared/shared-custom-markup/custom-markup.service.ts index b49f64834..4ab78a250 100644 --- a/client/src/app/shared/shared-custom-markup/custom-markup.service.ts +++ b/client/src/app/shared/shared-custom-markup/custom-markup.service.ts @@ -10,7 +10,7 @@ import { PlaylistMiniatureMarkupData, VideoMiniatureMarkupData, VideosListMarkupData -} from '@shared/models' +} from '@peertube/peertube-models' import { DynamicElementService } from './dynamic-element.service' import { ButtonMarkupComponent, diff --git a/client/src/app/shared/shared-custom-markup/dynamic-element.service.ts b/client/src/app/shared/shared-custom-markup/dynamic-element.service.ts index a12907055..dc4f683ac 100644 --- a/client/src/app/shared/shared-custom-markup/dynamic-element.service.ts +++ b/client/src/app/shared/shared-custom-markup/dynamic-element.service.ts @@ -10,7 +10,7 @@ import { SimpleChanges, Type } from '@angular/core' -import { objectKeysTyped } from '@shared/core-utils' +import { objectKeysTyped } from '@peertube/peertube-core-utils' @Injectable() export class DynamicElementService { diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts index 4f00eabd3..b731ccc64 100644 --- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts @@ -3,7 +3,7 @@ import { finalize, map, switchMap, tap } from 'rxjs/operators' import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, OnInit, Output } from '@angular/core' import { MarkdownService, Notifier, UserService } from '@app/core' import { FindInBulkService } from '@app/shared/shared-search' -import { VideoSortField } from '@shared/models' +import { VideoSortField } from '@peertube/peertube-models' import { Video, VideoChannel, VideoService } from '../../shared-main' import { CustomMarkupComponent } from './shared' diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/embed-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/embed-markup.component.ts index 0baf2428b..bca7444ec 100644 --- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/embed-markup.component.ts +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/embed-markup.component.ts @@ -1,7 +1,7 @@ import { environment } from 'src/environments/environment' import { Component, ElementRef, Input, OnInit } from '@angular/core' import { buildVideoOrPlaylistEmbed } from '@root-helpers/video' -import { buildPlaylistEmbedLink, buildVideoEmbedLink } from '@shared/core-utils' +import { buildPlaylistEmbedLink, buildVideoEmbedLink } from '@peertube/peertube-core-utils' import { CustomMarkupComponent } from './shared' @Component({ diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts index bd93929c9..d692abbe3 100644 --- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts @@ -2,7 +2,7 @@ import { finalize } from 'rxjs/operators' import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, OnInit, Output } from '@angular/core' import { AuthService, Notifier } from '@app/core' import { FindInBulkService } from '@app/shared/shared-search' -import { objectKeysTyped } from '@shared/core-utils' +import { objectKeysTyped } from '@peertube/peertube-core-utils' import { Video } from '../../shared-main' import { MiniatureDisplayOptions } from '../../shared-video-miniature' import { CustomMarkupComponent } from './shared' diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts index 81363be87..cbd5c7bf5 100644 --- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts @@ -1,8 +1,8 @@ import { finalize } from 'rxjs/operators' import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, OnInit, Output } from '@angular/core' import { AuthService, Notifier } from '@app/core' -import { objectKeysTyped } from '@shared/core-utils' -import { VideoSortField } from '@shared/models' +import { objectKeysTyped } from '@peertube/peertube-core-utils' +import { VideoSortField } from '@peertube/peertube-models' import { Video, VideoService } from '../../shared-main' import { MiniatureDisplayOptions } from '../../shared-video-miniature' import { CustomMarkupComponent } from './shared' diff --git a/client/src/app/shared/shared-forms/dynamic-form-field.component.ts b/client/src/app/shared/shared-forms/dynamic-form-field.component.ts index e1a1f8034..a95463944 100644 --- a/client/src/app/shared/shared-forms/dynamic-form-field.component.ts +++ b/client/src/app/shared/shared-forms/dynamic-form-field.component.ts @@ -1,6 +1,6 @@ import { Component, Input } from '@angular/core' import { FormGroup } from '@angular/forms' -import { RegisterClientFormFieldOptions } from '@shared/models' +import { RegisterClientFormFieldOptions } from '@peertube/peertube-models' @Component({ selector: 'my-dynamic-form-field', diff --git a/client/src/app/shared/shared-forms/form-validator.service.ts b/client/src/app/shared/shared-forms/form-validator.service.ts index 14ee044b5..e7dedf52a 100644 --- a/client/src/app/shared/shared-forms/form-validator.service.ts +++ b/client/src/app/shared/shared-forms/form-validator.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core' import { AsyncValidatorFn, FormArray, FormBuilder, FormControl, FormGroup, ValidatorFn } from '@angular/forms' -import { objectKeysTyped } from '@shared/core-utils' +import { objectKeysTyped } from '@peertube/peertube-core-utils' import { BuildFormArgument, BuildFormDefaultValues } from '../form-validators/form-validator.model' import { FormReactiveErrors, FormReactiveValidationMessages } from './form-reactive.service' diff --git a/client/src/app/shared/shared-forms/markdown-textarea.component.ts b/client/src/app/shared/shared-forms/markdown-textarea.component.ts index 036fab3d9..7edcf868c 100644 --- a/client/src/app/shared/shared-forms/markdown-textarea.component.ts +++ b/client/src/app/shared/shared-forms/markdown-textarea.component.ts @@ -6,7 +6,7 @@ import { Component, ElementRef, forwardRef, Input, OnInit, ViewChild } from '@an import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' import { SafeHtml } from '@angular/platform-browser' import { MarkdownService, ScreenService } from '@app/core' -import { Video } from '@shared/models' +import { Video } from '@peertube/peertube-models' @Component({ selector: 'my-markdown-textarea', diff --git a/client/src/app/shared/shared-forms/preview-upload.component.ts b/client/src/app/shared/shared-forms/preview-upload.component.ts index cdfa26a23..3db7c34f7 100644 --- a/client/src/app/shared/shared-forms/preview-upload.component.ts +++ b/client/src/app/shared/shared-forms/preview-upload.component.ts @@ -2,7 +2,7 @@ import { Component, forwardRef, Input, OnInit } from '@angular/core' import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' import { ServerService } from '@app/core' import { imageToDataURL } from '@root-helpers/images' -import { HTMLServerConfig } from '@shared/models' +import { HTMLServerConfig } from '@peertube/peertube-models' import { BytesPipe } from '../shared-main' @Component({ diff --git a/client/src/app/shared/shared-forms/timestamp-input.component.ts b/client/src/app/shared/shared-forms/timestamp-input.component.ts index 79ca63673..280491852 100644 --- a/client/src/app/shared/shared-forms/timestamp-input.component.ts +++ b/client/src/app/shared/shared-forms/timestamp-input.component.ts @@ -1,6 +1,6 @@ import { ChangeDetectorRef, Component, EventEmitter, forwardRef, Input, OnInit, Output } from '@angular/core' import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' -import { secondsToTime, timeToInt } from '@shared/core-utils' +import { secondsToTime, timeToInt } from '@peertube/peertube-core-utils' @Component({ selector: 'my-timestamp-input', diff --git a/client/src/app/shared/shared-instance/instance-about-accordion.component.ts b/client/src/app/shared/shared-instance/instance-about-accordion.component.ts index a7c521876..78d960d93 100644 --- a/client/src/app/shared/shared-instance/instance-about-accordion.component.ts +++ b/client/src/app/shared/shared-instance/instance-about-accordion.component.ts @@ -1,8 +1,7 @@ import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' import { HooksService, Notifier } from '@app/core' import { NgbAccordionDirective } from '@ng-bootstrap/ng-bootstrap' -import { ClientFilterHookName, PluginClientScope } from '@shared/models/plugins' -import { About } from '@shared/models/server' +import { About, ClientFilterHookName, PluginClientScope } from '@peertube/peertube-models' import { InstanceService } from './instance.service' @Component({ diff --git a/client/src/app/shared/shared-instance/instance-features-table.component.ts b/client/src/app/shared/shared-instance/instance-features-table.component.ts index ab1b1458a..11c6cc0ac 100644 --- a/client/src/app/shared/shared-instance/instance-features-table.component.ts +++ b/client/src/app/shared/shared-instance/instance-features-table.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit } from '@angular/core' import { ServerService } from '@app/core' import { formatICU } from '@app/helpers' -import { ServerConfig } from '@shared/models' +import { ServerConfig } from '@peertube/peertube-models' @Component({ selector: 'my-instance-features-table', diff --git a/client/src/app/shared/shared-instance/instance-follow.service.ts b/client/src/app/shared/shared-instance/instance-follow.service.ts index 7568fbbf4..f243273ba 100644 --- a/client/src/app/shared/shared-instance/instance-follow.service.ts +++ b/client/src/app/shared/shared-instance/instance-follow.service.ts @@ -4,8 +4,8 @@ import { catchError, concatMap, toArray } from 'rxjs/operators' import { HttpClient, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' import { RestExtractor, RestPagination, RestService } from '@app/core' -import { arrayify } from '@shared/core-utils' -import { ActivityPubActorType, ActorFollow, FollowState, ResultList, ServerFollowCreate } from '@shared/models' +import { arrayify } from '@peertube/peertube-core-utils' +import { ActivityPubActorType, ActorFollow, FollowState, ResultList, ServerFollowCreate } from '@peertube/peertube-models' import { environment } from '../../../environments/environment' import { AdvancedInputFilter } from '../shared-forms' diff --git a/client/src/app/shared/shared-instance/instance.service.ts b/client/src/app/shared/shared-instance/instance.service.ts index 3088f0899..9a55cf972 100644 --- a/client/src/app/shared/shared-instance/instance.service.ts +++ b/client/src/app/shared/shared-instance/instance.service.ts @@ -3,9 +3,8 @@ import { catchError, map } from 'rxjs/operators' import { HttpClient } from '@angular/common/http' import { Injectable } from '@angular/core' import { MarkdownService, RestExtractor, ServerService } from '@app/core' -import { objectKeysTyped } from '@shared/core-utils' -import { peertubeTranslate } from '@shared/core-utils/i18n' -import { About } from '@shared/models' +import { objectKeysTyped, peertubeTranslate } from '@peertube/peertube-core-utils' +import { About } from '@peertube/peertube-models' import { environment } from '../../../environments/environment' export type AboutHTML = Pick + state: VideoConstant likesPercent: number dislikesPercent: number diff --git a/client/src/app/shared/shared-main/video/video-edit.model.ts b/client/src/app/shared/shared-main/video/video-edit.model.ts index 9129ab93f..a3e736c0f 100644 --- a/client/src/app/shared/shared-main/video/video-edit.model.ts +++ b/client/src/app/shared/shared-main/video/video-edit.model.ts @@ -1,7 +1,7 @@ import { getAbsoluteAPIUrl } from '@app/helpers' -import { VideoPassword, VideoPrivacy, VideoScheduleUpdate, VideoUpdate } from '@shared/models' +import { objectKeysTyped } from '@peertube/peertube-core-utils' +import { VideoPassword, VideoPrivacy, VideoPrivacyType, VideoScheduleUpdate, VideoUpdate } from '@peertube/peertube-models' import { VideoDetails } from './video-details.model' -import { objectKeysTyped } from '@shared/core-utils' export class VideoEdit implements VideoUpdate { static readonly SPECIAL_SCHEDULED_PRIVACY = -1 @@ -17,7 +17,7 @@ export class VideoEdit implements VideoUpdate { downloadEnabled: boolean waitTranscoding: boolean channelId: number - privacy: VideoPrivacy + privacy: VideoPrivacyType videoPassword?: string support: string thumbnailfile?: any diff --git a/client/src/app/shared/shared-main/video/video-file-token.service.ts b/client/src/app/shared/shared-main/video/video-file-token.service.ts index 9bca5b9ec..87a952895 100644 --- a/client/src/app/shared/shared-main/video/video-file-token.service.ts +++ b/client/src/app/shared/shared-main/video/video-file-token.service.ts @@ -2,7 +2,7 @@ import { catchError, map, of, tap } from 'rxjs' import { HttpClient } from '@angular/common/http' import { Injectable } from '@angular/core' import { RestExtractor } from '@app/core' -import { VideoToken } from '@shared/models' +import { VideoToken } from '@peertube/peertube-models' import { VideoService } from './video.service' import { VideoPasswordService } from './video-password.service' diff --git a/client/src/app/shared/shared-main/video/video-import.service.ts b/client/src/app/shared/shared-main/video/video-import.service.ts index 607c08d71..bb9052401 100644 --- a/client/src/app/shared/shared-main/video/video-import.service.ts +++ b/client/src/app/shared/shared-main/video/video-import.service.ts @@ -5,8 +5,8 @@ import { HttpClient, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' import { RestExtractor, RestPagination, RestService, ServerService, UserService } from '@app/core' import { objectToFormData } from '@app/helpers' -import { peertubeTranslate } from '@shared/core-utils/i18n' -import { ResultList, VideoImport, VideoImportCreate, VideoUpdate } from '@shared/models' +import { peertubeTranslate } from '@peertube/peertube-core-utils' +import { ResultList, VideoImport, VideoImportCreate, VideoUpdate } from '@peertube/peertube-models' import { environment } from '../../../../environments/environment' @Injectable() diff --git a/client/src/app/shared/shared-main/video/video-ownership.service.ts b/client/src/app/shared/shared-main/video/video-ownership.service.ts index 1e8f7f68c..03e8fc946 100644 --- a/client/src/app/shared/shared-main/video/video-ownership.service.ts +++ b/client/src/app/shared/shared-main/video/video-ownership.service.ts @@ -4,7 +4,7 @@ import { catchError } from 'rxjs/operators' import { HttpClient, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' import { RestExtractor, RestPagination, RestService } from '@app/core' -import { ResultList, VideoChangeOwnership, VideoChangeOwnershipAccept, VideoChangeOwnershipCreate } from '@shared/models' +import { ResultList, VideoChangeOwnership, VideoChangeOwnershipAccept, VideoChangeOwnershipCreate } from '@peertube/peertube-models' import { environment } from '../../../../environments/environment' @Injectable() diff --git a/client/src/app/shared/shared-main/video/video-password.service.ts b/client/src/app/shared/shared-main/video/video-password.service.ts index d5b0406f8..156efd60f 100644 --- a/client/src/app/shared/shared-main/video/video-password.service.ts +++ b/client/src/app/shared/shared-main/video/video-password.service.ts @@ -1,4 +1,4 @@ -import { ResultList, VideoPassword } from '@shared/models' +import { ResultList, VideoPassword } from '@peertube/peertube-models' import { Injectable } from '@angular/core' import { catchError, switchMap } from 'rxjs' import { HttpClient, HttpHeaders } from '@angular/common/http' diff --git a/client/src/app/shared/shared-main/video/video.model.ts b/client/src/app/shared/shared-main/video/video.model.ts index 1d077a613..ed28fb3f8 100644 --- a/client/src/app/shared/shared-main/video/video.model.ts +++ b/client/src/app/shared/shared-main/video/video.model.ts @@ -2,8 +2,7 @@ import { AuthUser } from '@app/core' import { User } from '@app/core/users/user.model' import { durationToString, formatICU, getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers' import { Actor } from '@app/shared/shared-main/account/actor.model' -import { buildVideoWatchPath, getAllFiles } from '@shared/core-utils' -import { peertubeTranslate } from '@shared/core-utils/i18n' +import { buildVideoWatchPath, getAllFiles, peertubeTranslate } from '@peertube/peertube-core-utils' import { ActorImage, HTMLServerConfig, @@ -12,11 +11,13 @@ import { VideoConstant, VideoFile, VideoPrivacy, + VideoPrivacyType, VideoScheduleUpdate, VideoState, + VideoStateType, VideoStreamingPlaylist, VideoStreamingPlaylistType -} from '@shared/models' +} from '@peertube/peertube-models' export class Video implements VideoServerModel { byVideoChannel: string @@ -30,7 +31,7 @@ export class Video implements VideoServerModel { category: VideoConstant licence: VideoConstant language: VideoConstant - privacy: VideoConstant + privacy: VideoConstant truncatedDescription: string description: string @@ -70,7 +71,7 @@ export class Video implements VideoServerModel { originInstanceHost: string waitTranscoding?: boolean - state?: VideoConstant + state?: VideoConstant scheduledUpdate?: VideoScheduleUpdate blacklisted?: boolean diff --git a/client/src/app/shared/shared-main/video/video.service.ts b/client/src/app/shared/shared-main/video/video.service.ts index a980c2dcf..9b2bc5dee 100644 --- a/client/src/app/shared/shared-main/video/video.service.ts +++ b/client/src/app/shared/shared-main/video/video.service.ts @@ -5,7 +5,7 @@ import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http' import { Injectable } from '@angular/core' import { AuthService, ComponentPaginationLight, ConfirmService, RestExtractor, RestService, ServerService, UserService } from '@app/core' import { objectToFormData } from '@app/helpers' -import { arrayify } from '@shared/core-utils' +import { arrayify } from '@peertube/peertube-core-utils' import { BooleanBothQuery, FeedFormat, @@ -21,13 +21,14 @@ import { VideoConstant, VideoDetails as VideoDetailsServerModel, VideoFileMetadata, - VideoInclude, + VideoIncludeType, VideoPrivacy, + VideoPrivacyType, VideoSortField, + VideoSource, VideoTranscodingCreate, VideoUpdate -} from '@shared/models' -import { VideoSource } from '@shared/models/videos/video-source' +} from '@peertube/peertube-models' import { environment } from '../../../../environments/environment' import { Account } from '../account/account.model' import { AccountService } from '../account/account.service' @@ -40,11 +41,11 @@ import { Video } from './video.model' export type CommonVideoParams = { videoPagination?: ComponentPaginationLight sort: VideoSortField | SortMeta - include?: VideoInclude + include?: VideoIncludeType isLocal?: boolean categoryOneOf?: number[] languageOneOf?: string[] - privacyOneOf?: VideoPrivacy[] + privacyOneOf?: VideoPrivacyType[] isLive?: boolean skipCount?: boolean nsfw?: BooleanBothQuery @@ -455,7 +456,7 @@ export class VideoService { ) } - explainedPrivacyLabels (serverPrivacies: VideoConstant[], defaultPrivacyId = VideoPrivacy.PUBLIC) { + explainedPrivacyLabels (serverPrivacies: VideoConstant[], defaultPrivacyId: VideoPrivacyType = VideoPrivacy.PUBLIC) { const descriptions = { [VideoPrivacy.PRIVATE]: $localize`Only I can see this video`, [VideoPrivacy.UNLISTED]: $localize`Only shareable via a private link`, @@ -478,7 +479,7 @@ export class VideoService { } } - getHighestAvailablePrivacy (serverPrivacies: VideoConstant[]) { + getHighestAvailablePrivacy (serverPrivacies: VideoConstant[]) { // We do not add a password as this requires additional configuration. const order = [ VideoPrivacy.PRIVATE, diff --git a/client/src/app/shared/shared-moderation/abuse.service.ts b/client/src/app/shared/shared-moderation/abuse.service.ts index 5d1539f69..8055b6dd1 100644 --- a/client/src/app/shared/shared-moderation/abuse.service.ts +++ b/client/src/app/shared/shared-moderation/abuse.service.ts @@ -15,7 +15,7 @@ import { AdminAbuse, ResultList, UserAbuse -} from '@shared/models' +} from '@peertube/peertube-models' import { environment } from '../../../environments/environment' @Injectable() diff --git a/client/src/app/shared/shared-moderation/account-block.model.ts b/client/src/app/shared/shared-moderation/account-block.model.ts index 8f76c69dc..a5bde327a 100644 --- a/client/src/app/shared/shared-moderation/account-block.model.ts +++ b/client/src/app/shared/shared-moderation/account-block.model.ts @@ -1,4 +1,4 @@ -import { AccountBlock as AccountBlockServer } from '@shared/models' +import { AccountBlock as AccountBlockServer } from '@peertube/peertube-models' import { Account } from '@app/shared/shared-main' export class AccountBlock implements AccountBlockServer { diff --git a/client/src/app/shared/shared-moderation/blocklist.service.ts b/client/src/app/shared/shared-moderation/blocklist.service.ts index 0fb7536e5..f755b812a 100644 --- a/client/src/app/shared/shared-moderation/blocklist.service.ts +++ b/client/src/app/shared/shared-moderation/blocklist.service.ts @@ -4,8 +4,8 @@ import { catchError, concatMap, map, toArray } from 'rxjs/operators' import { HttpClient, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' import { RestExtractor, RestPagination, RestService } from '@app/core' -import { arrayify } from '@shared/core-utils' -import { AccountBlock as AccountBlockServer, BlockStatus, ResultList, ServerBlock } from '@shared/models' +import { arrayify } from '@peertube/peertube-core-utils' +import { AccountBlock as AccountBlockServer, BlockStatus, ResultList, ServerBlock } from '@peertube/peertube-models' import { environment } from '../../../environments/environment' import { Account } from '../shared-main' import { AccountBlock } from './account-block.model' diff --git a/client/src/app/shared/shared-moderation/bulk.service.ts b/client/src/app/shared/shared-moderation/bulk.service.ts index f0b869421..36d1b0b1e 100644 --- a/client/src/app/shared/shared-moderation/bulk.service.ts +++ b/client/src/app/shared/shared-moderation/bulk.service.ts @@ -2,7 +2,7 @@ import { catchError } from 'rxjs/operators' import { HttpClient } from '@angular/common/http' import { Injectable } from '@angular/core' import { RestExtractor } from '@app/core' -import { BulkRemoveCommentsOfBody } from '@shared/models' +import { BulkRemoveCommentsOfBody } from '@peertube/peertube-models' import { environment } from '../../../environments/environment' @Injectable() diff --git a/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts b/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts index d587a9709..042b57aa7 100644 --- a/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts +++ b/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts @@ -6,8 +6,8 @@ import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' import { Account } from '@app/shared/shared-main' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' -import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' -import { AbusePredefinedReasonsString } from '@shared/models' +import { abusePredefinedReasonsMap } from '@peertube/peertube-core-utils' +import { AbusePredefinedReasonsString } from '@peertube/peertube-models' import { AbuseService } from '../abuse.service' @Component({ diff --git a/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts b/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts index e35d70c8f..fd50b745a 100644 --- a/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts +++ b/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts @@ -6,8 +6,8 @@ import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' import { VideoComment } from '@app/shared/shared-video-comment' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' -import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' -import { AbusePredefinedReasonsString } from '@shared/models' +import { abusePredefinedReasonsMap } from '@peertube/peertube-core-utils' +import { AbusePredefinedReasonsString } from '@peertube/peertube-models' import { AbuseService } from '../abuse.service' @Component({ diff --git a/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts b/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts index 16be8e0a1..479957d21 100644 --- a/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts +++ b/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts @@ -6,8 +6,8 @@ import { ABUSE_REASON_VALIDATOR } from '@app/shared/form-validators/abuse-valida import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' -import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' -import { AbusePredefinedReasonsString } from '@shared/models' +import { abusePredefinedReasonsMap } from '@peertube/peertube-core-utils' +import { AbusePredefinedReasonsString } from '@peertube/peertube-models' import { Video } from '../../shared-main' import { AbuseService } from '../abuse.service' diff --git a/client/src/app/shared/shared-moderation/server-blocklist.component.ts b/client/src/app/shared/shared-moderation/server-blocklist.component.ts index f1bcbd561..4105645fa 100644 --- a/client/src/app/shared/shared-moderation/server-blocklist.component.ts +++ b/client/src/app/shared/shared-moderation/server-blocklist.component.ts @@ -2,7 +2,7 @@ import { SortMeta } from 'primeng/api' import { Directive, OnInit, ViewChild } from '@angular/core' import { Notifier, RestPagination, RestTable } from '@app/core' import { BatchDomainsModalComponent } from '@app/shared/shared-moderation/batch-domains-modal.component' -import { ServerBlock } from '@shared/models' +import { ServerBlock } from '@peertube/peertube-models' import { BlocklistComponentType, BlocklistService } from './blocklist.service' @Directive() diff --git a/client/src/app/shared/shared-moderation/user-ban-modal.component.ts b/client/src/app/shared/shared-moderation/user-ban-modal.component.ts index 34295c34a..fcada7acc 100644 --- a/client/src/app/shared/shared-moderation/user-ban-modal.component.ts +++ b/client/src/app/shared/shared-moderation/user-ban-modal.component.ts @@ -5,7 +5,7 @@ import { formatICU } from '@app/helpers' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' -import { User } from '@shared/models' +import { User } from '@peertube/peertube-models' import { USER_BAN_REASON_VALIDATOR } from '../form-validators/user-validators' import { Account } from '../shared-main' import { UserAdminService } from '../shared-users' diff --git a/client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts b/client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts index 50dccf862..7de152e60 100644 --- a/client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts +++ b/client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts @@ -1,7 +1,7 @@ import { Component, EventEmitter, Input, OnChanges, OnInit, Output, ViewChild } from '@angular/core' import { AuthService, ConfirmService, Notifier, ServerService } from '@app/core' import { Account, DropdownAction } from '@app/shared/shared-main' -import { BulkRemoveCommentsOfBody, User, UserRight } from '@shared/models' +import { BulkRemoveCommentsOfBody, User, UserRight } from '@peertube/peertube-models' import { UserAdminService } from '../shared-users' import { BlocklistService } from './blocklist.service' import { BulkService } from './bulk.service' diff --git a/client/src/app/shared/shared-moderation/video-block.service.ts b/client/src/app/shared/shared-moderation/video-block.service.ts index ab352a2d6..18950c92b 100644 --- a/client/src/app/shared/shared-moderation/video-block.service.ts +++ b/client/src/app/shared/shared-moderation/video-block.service.ts @@ -4,8 +4,8 @@ import { catchError, concatMap, toArray } from 'rxjs/operators' import { HttpClient, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' import { RestExtractor, RestPagination, RestService } from '@app/core' -import { arrayify } from '@shared/core-utils' -import { ResultList, VideoBlacklist, VideoBlacklistType } from '@shared/models' +import { arrayify } from '@peertube/peertube-core-utils' +import { ResultList, VideoBlacklist, VideoBlacklistType, VideoBlacklistType_Type } from '@peertube/peertube-models' import { environment } from '../../../environments/environment' @Injectable() @@ -22,7 +22,7 @@ export class VideoBlockService { pagination: RestPagination sort: SortMeta search?: string - type?: VideoBlacklistType + type?: VideoBlacklistType_Type }): Observable> { const { pagination, sort, search, type } = options diff --git a/client/src/app/shared/shared-search/advanced-search.model.ts b/client/src/app/shared/shared-search/advanced-search.model.ts index 29fe3e8dc..b977a4801 100644 --- a/client/src/app/shared/shared-search/advanced-search.model.ts +++ b/client/src/app/shared/shared-search/advanced-search.model.ts @@ -6,7 +6,7 @@ import { VideoChannelsSearchQuery, VideoPlaylistsSearchQuery, VideosSearchQuery -} from '@shared/models' +} from '@peertube/peertube-models' export type AdvancedSearchResultType = 'videos' | 'playlists' | 'channels' diff --git a/client/src/app/shared/shared-search/find-in-bulk.service.ts b/client/src/app/shared/shared-search/find-in-bulk.service.ts index 125d5e2b8..de57c7f64 100644 --- a/client/src/app/shared/shared-search/find-in-bulk.service.ts +++ b/client/src/app/shared/shared-search/find-in-bulk.service.ts @@ -3,11 +3,11 @@ import { Observable, Subject } from 'rxjs' import { filter, first, map } from 'rxjs/operators' import { Injectable } from '@angular/core' import { buildBulkObservable } from '@app/helpers' -import { ResultList } from '@shared/models/common' +import { ResultList } from '@peertube/peertube-models' import { Video, VideoChannel } from '../shared-main' import { VideoPlaylist } from '../shared-video-playlist' -import { SearchService } from './search.service' import { AdvancedSearch } from './advanced-search.model' +import { SearchService } from './search.service' const debugLogger = debug('peertube:search:FindInBulkService') diff --git a/client/src/app/shared/shared-search/search.service.ts b/client/src/app/shared/shared-search/search.service.ts index ad2de0f37..281e0b4bd 100644 --- a/client/src/app/shared/shared-search/search.service.ts +++ b/client/src/app/shared/shared-search/search.service.ts @@ -9,7 +9,7 @@ import { Video as VideoServerModel, VideoChannel as VideoChannelServerModel, VideoPlaylist as VideoPlaylistServerModel -} from '@shared/models' +} from '@peertube/peertube-models' import { environment } from '../../../environments/environment' import { VideoPlaylist, VideoPlaylistService } from '../shared-video-playlist' import { AdvancedSearch } from './advanced-search.model' diff --git a/client/src/app/shared/shared-share-modal/video-share.component.ts b/client/src/app/shared/shared-share-modal/video-share.component.ts index b09222c3e..24c9cdeca 100644 --- a/client/src/app/shared/shared-share-modal/video-share.component.ts +++ b/client/src/app/shared/shared-share-modal/video-share.component.ts @@ -5,8 +5,8 @@ import { VideoDetails } from '@app/shared/shared-main' import { VideoPlaylist } from '@app/shared/shared-video-playlist' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { buildVideoOrPlaylistEmbed } from '@root-helpers/video' -import { buildPlaylistLink, buildVideoLink, decoratePlaylistLink, decorateVideoLink } from '@shared/core-utils' -import { VideoCaption, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' +import { buildPlaylistLink, buildVideoLink, decoratePlaylistLink, decorateVideoLink } from '@peertube/peertube-core-utils' +import { VideoCaption, VideoPlaylistPrivacy, VideoPrivacy } from '@peertube/peertube-models' type Customizations = { startAtCheckbox: boolean diff --git a/client/src/app/shared/shared-support-modal/support-modal.component.ts b/client/src/app/shared/shared-support-modal/support-modal.component.ts index f330228e1..d911b45d8 100644 --- a/client/src/app/shared/shared-support-modal/support-modal.component.ts +++ b/client/src/app/shared/shared-support-modal/support-modal.component.ts @@ -2,7 +2,7 @@ import { Component, Input, ViewChild } from '@angular/core' import { MarkdownService } from '@app/core' import { VideoDetails } from '@app/shared/shared-main' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' -import { VideoChannel } from '@shared/models' +import { VideoChannel } from '@peertube/peertube-models' @Component({ selector: 'my-support-modal', diff --git a/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts b/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts index ad5d30db2..c9a5c97db 100644 --- a/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts +++ b/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts @@ -1,6 +1,6 @@ import { Component, EventEmitter, Input, Output } from '@angular/core' import { ScreenService } from '@app/core' -import { VideoState } from '@shared/models' +import { VideoState } from '@peertube/peertube-models' import { Video } from '../shared-main' @Component({ diff --git a/client/src/app/shared/shared-user-settings/user-interface-settings.component.ts b/client/src/app/shared/shared-user-settings/user-interface-settings.component.ts index c2c30d38b..08c6b6933 100644 --- a/client/src/app/shared/shared-user-settings/user-interface-settings.component.ts +++ b/client/src/app/shared/shared-user-settings/user-interface-settings.component.ts @@ -2,7 +2,7 @@ import { Subject, Subscription } from 'rxjs' import { Component, Input, OnDestroy, OnInit } from '@angular/core' import { AuthService, Notifier, ServerService, ThemeService, UserService } from '@app/core' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' -import { HTMLServerConfig, User, UserUpdateMe } from '@shared/models' +import { HTMLServerConfig, User, UserUpdateMe } from '@peertube/peertube-models' import { SelectOptionsItem } from 'src/types' @Component({ diff --git a/client/src/app/shared/shared-user-settings/user-video-settings.component.ts b/client/src/app/shared/shared-user-settings/user-video-settings.component.ts index ed6e7fffd..234d5b217 100644 --- a/client/src/app/shared/shared-user-settings/user-video-settings.component.ts +++ b/client/src/app/shared/shared-user-settings/user-video-settings.component.ts @@ -4,8 +4,7 @@ import { first } from 'rxjs/operators' import { Component, Input, OnDestroy, OnInit } from '@angular/core' import { AuthService, Notifier, ServerService, User, UserService } from '@app/core' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' -import { UserUpdateMe } from '@shared/models' -import { NSFWPolicyType } from '@shared/models/videos/nsfw-policy.type' +import { NSFWPolicyType, UserUpdateMe } from '@peertube/peertube-models' @Component({ selector: 'my-user-video-settings', diff --git a/client/src/app/shared/shared-user-subscription/subscribe-button.component.ts b/client/src/app/shared/shared-user-subscription/subscribe-button.component.ts index a002bf4e7..2a5751824 100644 --- a/client/src/app/shared/shared-user-subscription/subscribe-button.component.ts +++ b/client/src/app/shared/shared-user-subscription/subscribe-button.component.ts @@ -2,7 +2,7 @@ import { concat, forkJoin, merge } from 'rxjs' import { Component, Input, OnChanges, OnInit } from '@angular/core' import { AuthService, Notifier, RedirectService } from '@app/core' import { Account, VideoChannel, VideoService } from '@app/shared/shared-main' -import { FeedFormat } from '@shared/models' +import { FeedFormat } from '@peertube/peertube-models' import { UserSubscriptionService } from './user-subscription.service' @Component({ diff --git a/client/src/app/shared/shared-user-subscription/user-subscription.service.ts b/client/src/app/shared/shared-user-subscription/user-subscription.service.ts index 9cf6b4d16..b83f7ebc5 100644 --- a/client/src/app/shared/shared-user-subscription/user-subscription.service.ts +++ b/client/src/app/shared/shared-user-subscription/user-subscription.service.ts @@ -6,7 +6,7 @@ import { Injectable } from '@angular/core' import { ComponentPaginationLight, RestExtractor, RestService } from '@app/core' import { buildBulkObservable } from '@app/helpers' import { Video, VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main' -import { ActorFollow, ResultList, VideoChannel as VideoChannelServer, VideoSortField } from '@shared/models' +import { ActorFollow, ResultList, VideoChannel as VideoChannelServer, VideoSortField } from '@peertube/peertube-models' import { environment } from '../../../environments/environment' const debugLogger = debug('peertube:subscriptions:UserSubscriptionService') diff --git a/client/src/app/shared/shared-users/two-factor.service.ts b/client/src/app/shared/shared-users/two-factor.service.ts index 9ff916f15..cb4450e8f 100644 --- a/client/src/app/shared/shared-users/two-factor.service.ts +++ b/client/src/app/shared/shared-users/two-factor.service.ts @@ -2,7 +2,7 @@ import { catchError } from 'rxjs/operators' import { HttpClient } from '@angular/common/http' import { Injectable } from '@angular/core' import { RestExtractor, UserService } from '@app/core' -import { TwoFactorEnableResult } from '@shared/models' +import { TwoFactorEnableResult } from '@peertube/peertube-models' @Injectable() export class TwoFactorService { diff --git a/client/src/app/shared/shared-users/user-admin.service.ts b/client/src/app/shared/shared-users/user-admin.service.ts index 5842bd271..cc706343f 100644 --- a/client/src/app/shared/shared-users/user-admin.service.ts +++ b/client/src/app/shared/shared-users/user-admin.service.ts @@ -5,8 +5,8 @@ import { HttpClient, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' import { RestExtractor, RestPagination, RestService, ServerService, UserService } from '@app/core' import { getBytes } from '@root-helpers/bytes' -import { arrayify, peertubeTranslate } from '@shared/core-utils' -import { ResultList, User as UserServerModel, UserCreate, UserUpdate } from '@shared/models' +import { arrayify, peertubeTranslate } from '@peertube/peertube-core-utils' +import { ResultList, User as UserServerModel, UserCreate, UserUpdate } from '@peertube/peertube-models' @Injectable() export class UserAdminService { diff --git a/client/src/app/shared/shared-video-comment/video-comment-thread-tree.model.ts b/client/src/app/shared/shared-video-comment/video-comment-thread-tree.model.ts index 9956c88a6..62683f57f 100644 --- a/client/src/app/shared/shared-video-comment/video-comment-thread-tree.model.ts +++ b/client/src/app/shared/shared-video-comment/video-comment-thread-tree.model.ts @@ -1,4 +1,4 @@ -import { VideoCommentThreadTree as VideoCommentThreadTreeServerModel } from '@shared/models' +import { VideoCommentThreadTree as VideoCommentThreadTreeServerModel } from '@peertube/peertube-models' import { VideoComment } from './video-comment.model' export class VideoCommentThreadTree implements VideoCommentThreadTreeServerModel { diff --git a/client/src/app/shared/shared-video-comment/video-comment.model.ts b/client/src/app/shared/shared-video-comment/video-comment.model.ts index adab4cfbd..7048ed66f 100644 --- a/client/src/app/shared/shared-video-comment/video-comment.model.ts +++ b/client/src/app/shared/shared-video-comment/video-comment.model.ts @@ -4,7 +4,7 @@ import { Account as AccountInterface, VideoComment as VideoCommentServerModel, VideoCommentAdmin as VideoCommentAdminServerModel -} from '@shared/models' +} from '@peertube/peertube-models' export class VideoComment implements VideoCommentServerModel { id: number diff --git a/client/src/app/shared/shared-video-comment/video-comment.service.ts b/client/src/app/shared/shared-video-comment/video-comment.service.ts index 3906652be..d1db773c4 100644 --- a/client/src/app/shared/shared-video-comment/video-comment.service.ts +++ b/client/src/app/shared/shared-video-comment/video-comment.service.ts @@ -14,7 +14,7 @@ import { VideoCommentAdmin, VideoCommentCreate, VideoCommentThreadTree as VideoCommentThreadTreeServerModel -} from '@shared/models' +} from '@peertube/peertube-models' import { environment } from '../../../environments/environment' import { VideoCommentThreadTree } from './video-comment-thread-tree.model' import { VideoComment } from './video-comment.model' diff --git a/client/src/app/shared/shared-video-live/live-stream-information.component.ts b/client/src/app/shared/shared-video-live/live-stream-information.component.ts index 400a6fa01..4089c88fb 100644 --- a/client/src/app/shared/shared-video-live/live-stream-information.component.ts +++ b/client/src/app/shared/shared-video-live/live-stream-information.component.ts @@ -1,7 +1,7 @@ import { Component, ElementRef, ViewChild } from '@angular/core' import { Video } from '@app/shared/shared-main' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' -import { LiveVideo, LiveVideoError, LiveVideoSession } from '@shared/models' +import { LiveVideo, LiveVideoError, LiveVideoErrorType, LiveVideoSession } from '@peertube/peertube-models' import { LiveVideoService } from './live-video.service' @Component({ @@ -38,7 +38,7 @@ export class LiveStreamInformationComponent { getErrorLabel (session: LiveVideoSession) { if (!session.error) return undefined - const errors: { [ id in LiveVideoError ]: string } = { + const errors: { [ id in LiveVideoErrorType ]: string } = { [LiveVideoError.BAD_SOCKET_HEALTH]: $localize`Server too slow`, [LiveVideoError.BLACKLISTED]: $localize`Live blacklisted`, [LiveVideoError.DURATION_EXCEEDED]: $localize`Max duration exceeded`, diff --git a/client/src/app/shared/shared-video-live/live-video.service.ts b/client/src/app/shared/shared-video-live/live-video.service.ts index 89bfd84a0..8ac0eb924 100644 --- a/client/src/app/shared/shared-video-live/live-video.service.ts +++ b/client/src/app/shared/shared-video-live/live-video.service.ts @@ -2,7 +2,7 @@ import { catchError } from 'rxjs/operators' import { HttpClient } from '@angular/common/http' import { Injectable } from '@angular/core' import { RestExtractor } from '@app/core' -import { LiveVideo, LiveVideoCreate, LiveVideoSession, LiveVideoUpdate, ResultList, VideoCreateResult } from '@shared/models' +import { LiveVideo, LiveVideoCreate, LiveVideoSession, LiveVideoUpdate, ResultList, VideoCreateResult } from '@peertube/peertube-models' import { environment } from '../../../environments/environment' import { VideoService } from '../shared-main' diff --git a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts index 9891aae2e..4b3ed6e99 100644 --- a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts +++ b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts @@ -2,7 +2,7 @@ import { Component, EventEmitter, Input, OnChanges, Output, ViewChild } from '@a import { AuthService, ConfirmService, Notifier, ScreenService, ServerService } from '@app/core' import { BlocklistService, VideoBlockComponent, VideoBlockService, VideoReportComponent } from '@app/shared/shared-moderation' import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap' -import { VideoCaption } from '@shared/models' +import { VideoCaption } from '@peertube/peertube-models' import { Actor, DropdownAction, diff --git a/client/src/app/shared/shared-video-miniature/video-download.component.ts b/client/src/app/shared/shared-video-miniature/video-download.component.ts index 146ea7dfe..123f40b2f 100644 --- a/client/src/app/shared/shared-video-miniature/video-download.component.ts +++ b/client/src/app/shared/shared-video-miniature/video-download.component.ts @@ -6,8 +6,8 @@ import { HooksService } from '@app/core' import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' import { logger } from '@root-helpers/logger' import { videoRequiresFileToken } from '@root-helpers/video' -import { objectKeysTyped, pick } from '@shared/core-utils' -import { VideoCaption, VideoFile } from '@shared/models' +import { objectKeysTyped, pick } from '@peertube/peertube-core-utils' +import { VideoCaption, VideoFile } from '@peertube/peertube-models' import { BytesPipe, NumberFormatterPipe, VideoDetails, VideoFileTokenService, VideoService } from '../shared-main' type DownloadType = 'video' | 'subtitles' diff --git a/client/src/app/shared/shared-video-miniature/video-filters-header.component.ts b/client/src/app/shared/shared-video-miniature/video-filters-header.component.ts index a5da9ebf3..2826408e7 100644 --- a/client/src/app/shared/shared-video-miniature/video-filters-header.component.ts +++ b/client/src/app/shared/shared-video-miniature/video-filters-header.component.ts @@ -4,7 +4,7 @@ import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angu import { FormBuilder, FormGroup } from '@angular/forms' import { AuthService } from '@app/core' import { ServerService } from '@app/core/server/server.service' -import { UserRight } from '@shared/models' +import { UserRight } from '@peertube/peertube-models' import { PeertubeModalService } from '../shared-main' import { VideoFilters } from './video-filters.model' diff --git a/client/src/app/shared/shared-video-miniature/video-filters.model.ts b/client/src/app/shared/shared-video-miniature/video-filters.model.ts index f57a45eb1..8db17c015 100644 --- a/client/src/app/shared/shared-video-miniature/video-filters.model.ts +++ b/client/src/app/shared/shared-video-miniature/video-filters.model.ts @@ -1,8 +1,14 @@ import { splitIntoArray, toBoolean } from '@app/helpers' -import { getAllPrivacies } from '@shared/core-utils' -import { escapeHTML } from '@shared/core-utils/renderer' -import { BooleanBothQuery, NSFWPolicyType, VideoInclude, VideoPrivacy, VideoSortField } from '@shared/models' -import { AttributesOnly } from '@shared/typescript-utils' +import { escapeHTML, getAllPrivacies } from '@peertube/peertube-core-utils' +import { + BooleanBothQuery, + NSFWPolicyType, + VideoInclude, + VideoIncludeType, + VideoPrivacyType, + VideoSortField +} from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' type VideoFiltersKeys = { [ id in keyof AttributesOnly ]: any @@ -207,8 +213,8 @@ export class VideoFilters { toVideosAPIObject () { let isLocal: boolean - let include: VideoInclude - let privacyOneOf: VideoPrivacy[] + let include: VideoIncludeType + let privacyOneOf: VideoPrivacyType[] if (this.scope === 'local') { isLocal = true diff --git a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts index d453f37a1..11cd6726e 100644 --- a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts +++ b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts @@ -11,7 +11,7 @@ import { Output } from '@angular/core' import { AuthService, ScreenService, ServerService, User } from '@app/core' -import { HTMLServerConfig, VideoExistInPlaylist, VideoPlaylistType, VideoPrivacy, VideoState } from '@shared/models' +import { HTMLServerConfig, VideoExistInPlaylist, VideoPlaylistType, VideoPrivacy, VideoState } from '@peertube/peertube-models' import { LinkType } from '../../../types/link.type' import { ActorAvatarSize } from '../shared-actor-image/actor-avatar.component' import { Video, VideoService } from '../shared-main' diff --git a/client/src/app/shared/shared-video-miniature/videos-list.component.ts b/client/src/app/shared/shared-video-miniature/videos-list.component.ts index 14a5abd7a..afdef5ace 100644 --- a/client/src/app/shared/shared-video-miniature/videos-list.component.ts +++ b/client/src/app/shared/shared-video-miniature/videos-list.component.ts @@ -15,8 +15,8 @@ import { } from '@app/core' import { GlobalIconName } from '@app/shared/shared-icons' import { logger } from '@root-helpers/logger' -import { isLastMonth, isLastWeek, isThisMonth, isToday, isYesterday } from '@shared/core-utils' -import { ResultList, UserRight, VideoSortField } from '@shared/models' +import { isLastMonth, isLastWeek, isThisMonth, isToday, isYesterday } from '@peertube/peertube-core-utils' +import { ResultList, UserRight, VideoSortField } from '@peertube/peertube-models' import { Syndication, Video } from '../shared-main' import { VideoFilters, VideoFilterScope } from './video-filters.model' import { MiniatureDisplayOptions } from './video-miniature.component' diff --git a/client/src/app/shared/shared-video-miniature/videos-selection.component.ts b/client/src/app/shared/shared-video-miniature/videos-selection.component.ts index 86fe502e2..286b33dd4 100644 --- a/client/src/app/shared/shared-video-miniature/videos-selection.component.ts +++ b/client/src/app/shared/shared-video-miniature/videos-selection.component.ts @@ -2,8 +2,8 @@ import { Observable, Subject } from 'rxjs' import { AfterContentInit, Component, ContentChildren, EventEmitter, Input, Output, QueryList, TemplateRef } from '@angular/core' import { ComponentPagination, Notifier, User } from '@app/core' import { logger } from '@root-helpers/logger' -import { objectKeysTyped } from '@shared/core-utils' -import { ResultList, VideosExistInPlaylists, VideoSortField } from '@shared/models' +import { objectKeysTyped } from '@peertube/peertube-core-utils' +import { ResultList, VideosExistInPlaylists, VideoSortField } from '@peertube/peertube-models' import { PeerTubeTemplateDirective, Video } from '../shared-main' import { MiniatureDisplayOptions } from './video-miniature.component' diff --git a/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts b/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts index f802416a4..84173ba69 100644 --- a/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts +++ b/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts @@ -4,7 +4,7 @@ import { debounceTime, filter } from 'rxjs/operators' import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core' import { AuthService, DisableForReuseHook, Notifier } from '@app/core' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' -import { secondsToTime } from '@shared/core-utils' +import { secondsToTime } from '@peertube/peertube-core-utils' import { CachedVideoExistInPlaylist, Video, @@ -12,7 +12,7 @@ import { VideoPlaylistElementCreate, VideoPlaylistElementUpdate, VideoPlaylistPrivacy -} from '@shared/models' +} from '@peertube/peertube-models' import { VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR } from '../form-validators/video-playlist-validators' import { CachedPlaylist, VideoPlaylistService } from './video-playlist.service' diff --git a/client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts b/client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts index b9a1d9623..0c0f11ecc 100644 --- a/client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts +++ b/client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts @@ -2,8 +2,8 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, In import { AuthService, Notifier, ServerService } from '@app/core' import { Video, VideoService } from '@app/shared/shared-main' import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap' -import { secondsToTime } from '@shared/core-utils' -import { HTMLServerConfig, VideoPlaylistElementType, VideoPlaylistElementUpdate, VideoPrivacy } from '@shared/models' +import { secondsToTime } from '@peertube/peertube-core-utils' +import { HTMLServerConfig, VideoPlaylistElementType, VideoPlaylistElementUpdate, VideoPrivacy } from '@peertube/peertube-models' import { VideoPlaylistElement } from './video-playlist-element.model' import { VideoPlaylist } from './video-playlist.model' import { VideoPlaylistService } from './video-playlist.service' diff --git a/client/src/app/shared/shared-video-playlist/video-playlist-element.model.ts b/client/src/app/shared/shared-video-playlist/video-playlist-element.model.ts index b661378bd..16b212281 100644 --- a/client/src/app/shared/shared-video-playlist/video-playlist-element.model.ts +++ b/client/src/app/shared/shared-video-playlist/video-playlist-element.model.ts @@ -1,5 +1,5 @@ import { Video } from '@app/shared/shared-main' -import { VideoPlaylistElement as ServerVideoPlaylistElement, VideoPlaylistElementType } from '@shared/models' +import { VideoPlaylistElement as ServerVideoPlaylistElement, VideoPlaylistElementType_Type } from '@peertube/peertube-models' export class VideoPlaylistElement implements ServerVideoPlaylistElement { id: number @@ -7,7 +7,7 @@ export class VideoPlaylistElement implements ServerVideoPlaylistElement { startTimestamp: number stopTimestamp: number - type: VideoPlaylistElementType + type: VideoPlaylistElementType_Type video?: Video diff --git a/client/src/app/shared/shared-video-playlist/video-playlist.model.ts b/client/src/app/shared/shared-video-playlist/video-playlist.model.ts index 6b38d9ca3..24f1041ce 100644 --- a/client/src/app/shared/shared-video-playlist/video-playlist.model.ts +++ b/client/src/app/shared/shared-video-playlist/video-playlist.model.ts @@ -1,15 +1,15 @@ import { getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers' import { Actor } from '@app/shared/shared-main' -import { buildPlaylistWatchPath } from '@shared/core-utils' -import { peertubeTranslate } from '@shared/core-utils/i18n' +import { buildPlaylistWatchPath, peertubeTranslate } from '@peertube/peertube-core-utils' import { AccountSummary, VideoChannelSummary, VideoConstant, VideoPlaylist as ServerVideoPlaylist, - VideoPlaylistPrivacy, - VideoPlaylistType -} from '@shared/models' + VideoPlaylistPrivacyType, + VideoPlaylistType, + VideoPlaylistType_Type +} from '@peertube/peertube-models' export class VideoPlaylist implements ServerVideoPlaylist { id: number @@ -22,11 +22,11 @@ export class VideoPlaylist implements ServerVideoPlaylist { displayName: string description: string - privacy: VideoConstant + privacy: VideoConstant videosLength: number - type: VideoConstant + type: VideoConstant createdAt: Date | string updatedAt: Date | string diff --git a/client/src/app/shared/shared-video-playlist/video-playlist.service.ts b/client/src/app/shared/shared-video-playlist/video-playlist.service.ts index bc9fb0d74..7f0da2be8 100644 --- a/client/src/app/shared/shared-video-playlist/video-playlist.service.ts +++ b/client/src/app/shared/shared-video-playlist/video-playlist.service.ts @@ -20,7 +20,7 @@ import { VideoPlaylistReorder, VideoPlaylistUpdate, VideosExistInPlaylists -} from '@shared/models' +} from '@peertube/peertube-models' import { environment } from '../../../environments/environment' import { VideoPlaylistElement } from './video-playlist-element.model' import { VideoPlaylist } from './video-playlist.model' diff --git a/client/src/assets/player/peertube-player.ts b/client/src/assets/player/peertube-player.ts index 69ca1a566..4da681a08 100644 --- a/client/src/assets/player/peertube-player.ts +++ b/client/src/assets/player/peertube-player.ts @@ -30,7 +30,7 @@ import { PluginsManager } from '@root-helpers/plugins-manager' import { copyToClipboard } from '@root-helpers/utils' import { buildVideoOrPlaylistEmbed } from '@root-helpers/video' import { isMobile } from '@root-helpers/web-browser' -import { buildVideoLink, decorateVideoLink, isDefaultLocale, pick } from '@shared/core-utils' +import { buildVideoLink, decorateVideoLink, isDefaultLocale, pick } from '@peertube/peertube-core-utils' import { saveAverageBandwidth } from './peertube-player-local-storage' import { ControlBarOptionsBuilder, HLSOptionsBuilder, WebVideoOptionsBuilder } from './shared/player-options-builder' import { TranslationsManager } from './translations-manager' @@ -51,6 +51,8 @@ if (PlayProgressBar.prototype.options_.children.includes('timeTooltip') !== true PlayProgressBar.prototype.options_.children.push('timeTooltip') } +export { videojs } + export class PeerTubePlayer { private pluginsManager: PluginsManager @@ -516,9 +518,3 @@ export class PeerTubePlayer { return { content } } } - -// ############################################################################ - -export { - videojs -} diff --git a/client/src/assets/player/shared/common/utils.ts b/client/src/assets/player/shared/common/utils.ts index 609240626..4a7182021 100644 --- a/client/src/assets/player/shared/common/utils.ts +++ b/client/src/assets/player/shared/common/utils.ts @@ -1,4 +1,4 @@ -import { VideoFile } from '@shared/models' +import { VideoFile } from '@peertube/peertube-models' function toTitleCase (str: string) { return str.charAt(0).toUpperCase() + str.slice(1) diff --git a/client/src/assets/player/shared/control-bar/peertube-link-button.ts b/client/src/assets/player/shared/control-bar/peertube-link-button.ts index 8242b9cea..f93c265d6 100644 --- a/client/src/assets/player/shared/control-bar/peertube-link-button.ts +++ b/client/src/assets/player/shared/control-bar/peertube-link-button.ts @@ -1,5 +1,5 @@ import videojs from 'video.js' -import { buildVideoLink, decorateVideoLink } from '@shared/core-utils' +import { buildVideoLink, decorateVideoLink } from '@peertube/peertube-core-utils' import { PeerTubeLinkButtonOptions } from '../../types' const Component = videojs.getComponent('Component') diff --git a/client/src/assets/player/shared/metrics/metrics-plugin.ts b/client/src/assets/player/shared/metrics/metrics-plugin.ts index 06ca0c2f2..0ad16338c 100644 --- a/client/src/assets/player/shared/metrics/metrics-plugin.ts +++ b/client/src/assets/player/shared/metrics/metrics-plugin.ts @@ -1,7 +1,7 @@ import debug from 'debug' import videojs from 'video.js' +import { PlaybackMetricCreate, VideoResolutionType } from '@peertube/peertube-models' import { logger } from '@root-helpers/logger' -import { PlaybackMetricCreate } from '../../../../../../shared/models' import { MetricsPluginOptions, PlayerNetworkInfo } from '../../types' const debugLogger = debug('peertube:player:metrics') @@ -102,7 +102,7 @@ class MetricsPlugin extends Plugin { } const body: PlaybackMetricCreate = { - resolution, + resolution: resolution as VideoResolutionType, fps, playerMode: this.options_.mode(), diff --git a/client/src/assets/player/shared/p2p-media-loader/p2p-media-loader-plugin.ts b/client/src/assets/player/shared/p2p-media-loader/p2p-media-loader-plugin.ts index 8c376cd21..1e47fe486 100644 --- a/client/src/assets/player/shared/p2p-media-loader/p2p-media-loader-plugin.ts +++ b/client/src/assets/player/shared/p2p-media-loader/p2p-media-loader-plugin.ts @@ -3,7 +3,7 @@ import videojs from 'video.js' import { Events, Segment } from '@peertube/p2p-media-loader-core' import { Engine, initHlsJsPlayer, initVideoJsContribHlsJsPlayer } from '@peertube/p2p-media-loader-hlsjs' import { logger } from '@root-helpers/logger' -import { addQueryParams } from '@shared/core-utils' +import { addQueryParams } from '@peertube/peertube-core-utils' import { P2PMediaLoaderPluginOptions, PlayerNetworkInfo } from '../../types' import { SettingsButton } from '../settings/settings-menu-button' diff --git a/client/src/assets/player/shared/p2p-media-loader/segment-validator.ts b/client/src/assets/player/shared/p2p-media-loader/segment-validator.ts index 9cb6344a9..75d483015 100644 --- a/client/src/assets/player/shared/p2p-media-loader/segment-validator.ts +++ b/client/src/assets/player/shared/p2p-media-loader/segment-validator.ts @@ -2,7 +2,7 @@ import { basename } from 'path' import { Segment } from '@peertube/p2p-media-loader-core' import { logger } from '@root-helpers/logger' import { wait } from '@root-helpers/utils' -import { removeQueryParams } from '@shared/core-utils' +import { removeQueryParams } from '@peertube/peertube-core-utils' import { isSameOrigin } from '../common' type SegmentsJSON = { [filename: string]: string | { [byterange: string]: string } } diff --git a/client/src/assets/player/shared/peertube/peertube-plugin.ts b/client/src/assets/player/shared/peertube/peertube-plugin.ts index f93593415..cf866723c 100644 --- a/client/src/assets/player/shared/peertube/peertube-plugin.ts +++ b/client/src/assets/player/shared/peertube/peertube-plugin.ts @@ -1,9 +1,9 @@ import debug from 'debug' import videojs from 'video.js' +import { timeToInt } from '@peertube/peertube-core-utils' +import { VideoView, VideoViewEvent } from '@peertube/peertube-models' import { logger } from '@root-helpers/logger' import { isIOS, isMobile, isSafari } from '@root-helpers/web-browser' -import { timeToInt } from '@shared/core-utils' -import { VideoView, VideoViewEvent } from '@shared/models/videos' import { getStoredLastSubtitle, getStoredMute, diff --git a/client/src/assets/player/shared/player-options-builder/hls-options-builder.ts b/client/src/assets/player/shared/player-options-builder/hls-options-builder.ts index fd632d90d..41198afbe 100644 --- a/client/src/assets/player/shared/player-options-builder/hls-options-builder.ts +++ b/client/src/assets/player/shared/player-options-builder/hls-options-builder.ts @@ -1,7 +1,7 @@ import { HybridLoaderSettings } from '@peertube/p2p-media-loader-core' import { HlsJsEngineSettings } from '@peertube/p2p-media-loader-hlsjs' import { logger } from '@root-helpers/logger' -import { LiveVideoLatencyMode } from '@shared/models' +import { LiveVideoLatencyMode } from '@peertube/peertube-models' import { getAverageBandwidthInStore } from '../../peertube-player-local-storage' import { P2PMediaLoader, P2PMediaLoaderPluginOptions, PeerTubePlayerContructorOptions, PeerTubePlayerLoadOptions } from '../../types' import { getRtcConfig, isSameOrigin } from '../common' diff --git a/client/src/assets/player/shared/playlist/playlist-menu-item.ts b/client/src/assets/player/shared/playlist/playlist-menu-item.ts index f9366332d..66c92d9e5 100644 --- a/client/src/assets/player/shared/playlist/playlist-menu-item.ts +++ b/client/src/assets/player/shared/playlist/playlist-menu-item.ts @@ -1,6 +1,6 @@ import videojs from 'video.js' -import { secondsToTime } from '@shared/core-utils' -import { VideoPlaylistElement } from '@shared/models' +import { secondsToTime } from '@peertube/peertube-core-utils' +import { VideoPlaylistElement } from '@peertube/peertube-models' import { PlaylistItemOptions } from '../../types' const Component = videojs.getComponent('Component') diff --git a/client/src/assets/player/shared/playlist/playlist-menu.ts b/client/src/assets/player/shared/playlist/playlist-menu.ts index 53a5a7274..f6795390c 100644 --- a/client/src/assets/player/shared/playlist/playlist-menu.ts +++ b/client/src/assets/player/shared/playlist/playlist-menu.ts @@ -1,5 +1,5 @@ import videojs from 'video.js' -import { VideoPlaylistElement } from '@shared/models' +import { VideoPlaylistElement } from '@peertube/peertube-models' import { PlaylistPluginOptions } from '../../types' import { PlaylistMenuItem } from './playlist-menu-item' diff --git a/client/src/assets/player/shared/stats/stats-card.ts b/client/src/assets/player/shared/stats/stats-card.ts index 13334d91a..fefe8483e 100644 --- a/client/src/assets/player/shared/stats/stats-card.ts +++ b/client/src/assets/player/shared/stats/stats-card.ts @@ -1,6 +1,6 @@ import videojs from 'video.js' import { logger } from '@root-helpers/logger' -import { secondsToTime } from '@shared/core-utils' +import { secondsToTime } from '@peertube/peertube-core-utils' import { PlayerNetworkInfo as EventPlayerNetworkInfo } from '../../types' import { bytes } from '../common' diff --git a/client/src/assets/player/shared/web-video/web-video-plugin.ts b/client/src/assets/player/shared/web-video/web-video-plugin.ts index b839062f2..18d911108 100644 --- a/client/src/assets/player/shared/web-video/web-video-plugin.ts +++ b/client/src/assets/player/shared/web-video/web-video-plugin.ts @@ -1,8 +1,8 @@ import debug from 'debug' import videojs from 'video.js' import { logger } from '@root-helpers/logger' -import { addQueryParams } from '@shared/core-utils' -import { VideoFile } from '@shared/models' +import { addQueryParams } from '@peertube/peertube-core-utils' +import { VideoFile } from '@peertube/peertube-models' import { PeerTubeResolution, PlayerNetworkInfo, WebVideoPluginOptions } from '../../types' const debugLogger = debug('peertube:player:web-video-plugin') diff --git a/client/src/assets/player/translations-manager.ts b/client/src/assets/player/translations-manager.ts index bf9c2d471..03d5dd91e 100644 --- a/client/src/assets/player/translations-manager.ts +++ b/client/src/assets/player/translations-manager.ts @@ -1,5 +1,5 @@ +import { getCompleteLocale, getShortLocale, is18nLocale, isDefaultLocale } from '@peertube/peertube-core-utils' import { logger } from '@root-helpers/logger' -import { getCompleteLocale, getShortLocale, is18nLocale, isDefaultLocale } from '@shared/core-utils/i18n' export class TranslationsManager { private static videojsLocaleCache: { [ path: string ]: any } = {} diff --git a/client/src/assets/player/types/peertube-player-options.ts b/client/src/assets/player/types/peertube-player-options.ts index e1b8c7fab..352f7d8dd 100644 --- a/client/src/assets/player/types/peertube-player-options.ts +++ b/client/src/assets/player/types/peertube-player-options.ts @@ -1,5 +1,5 @@ +import { LiveVideoLatencyModeType, VideoFile } from '@peertube/peertube-models' import { PluginsManager } from '@root-helpers/plugins-manager' -import { LiveVideoLatencyMode, VideoFile } from '@shared/models' import { PeerTubeDockPluginOptions } from '../shared/dock/peertube-dock-plugin' import { PlaylistPluginOptions, VideoJSCaption, VideoJSStoryboard } from './peertube-videojs-typings' @@ -59,7 +59,7 @@ export type PeerTubePlayerLoadOptions = { isLive: boolean liveOptions?: { - latencyMode: LiveVideoLatencyMode + latencyMode: LiveVideoLatencyModeType } videoCaptions: VideoJSCaption[] diff --git a/client/src/assets/player/types/peertube-videojs-typings.ts b/client/src/assets/player/types/peertube-videojs-typings.ts index 73b38d0d3..dae9e14c8 100644 --- a/client/src/assets/player/types/peertube-videojs-typings.ts +++ b/client/src/assets/player/types/peertube-videojs-typings.ts @@ -1,7 +1,7 @@ import { HlsConfig, Level } from 'hls.js' import videojs from 'video.js' import { Engine } from '@peertube/p2p-media-loader-hlsjs' -import { VideoFile, VideoPlaylist, VideoPlaylistElement } from '@shared/models' +import { VideoFile, VideoPlaylist, VideoPlaylistElement } from '@peertube/peertube-models' import { BezelsPlugin } from '../shared/bezels/bezels-plugin' import { StoryboardPlugin } from '../shared/control-bar/storyboard-plugin' import { PeerTubeDockPlugin, PeerTubeDockPluginOptions } from '../shared/dock/peertube-dock-plugin' diff --git a/client/src/assets/player/utils.ts b/client/src/assets/player/utils.ts index cc303b80b..b56e3df8f 100644 --- a/client/src/assets/player/utils.ts +++ b/client/src/assets/player/utils.ts @@ -1,4 +1,4 @@ -import { HTMLServerConfig, Video, VideoFile } from '@shared/models' +import { HTMLServerConfig, Video, VideoFile } from '@peertube/peertube-models' function toTitleCase (str: string) { return str.charAt(0).toUpperCase() + str.slice(1) diff --git a/client/src/root-helpers/logger.ts b/client/src/root-helpers/logger.ts index 8181c13f3..108228d84 100644 --- a/client/src/root-helpers/logger.ts +++ b/client/src/root-helpers/logger.ts @@ -1,4 +1,4 @@ -import { ClientLogCreate } from '@shared/models/server' +import { ClientLogCreate } from '@peertube/peertube-models' import { peertubeLocalStorage } from './peertube-web-storage' import { OAuthUserTokens } from './users' diff --git a/client/src/root-helpers/plugins-manager.ts b/client/src/root-helpers/plugins-manager.ts index fd7b5233b..e987f16d6 100644 --- a/client/src/root-helpers/plugins-manager.ts +++ b/client/src/root-helpers/plugins-manager.ts @@ -3,7 +3,7 @@ import * as debug from 'debug' import { firstValueFrom, ReplaySubject } from 'rxjs' import { first, shareReplay } from 'rxjs/operators' import { RegisterClientHelpers } from 'src/types/register-client-option.model' -import { getExternalAuthHref, getHookType, internalRunHook } from '@shared/core-utils/plugins/hooks' +import { getExternalAuthHref, getHookType, internalRunHook } from '@peertube/peertube-core-utils' import { ClientHookName, clientHookObject, @@ -11,13 +11,14 @@ import { HTMLServerConfig, PluginClientScope, PluginType, + PluginType_Type, RegisterClientFormFieldOptions, RegisterClientHookOptions, RegisterClientRouteOptions, RegisterClientSettingsScriptOptions, RegisterClientVideoFieldOptions, ServerConfigPlugin -} from '@shared/models' +} from '@peertube/peertube-models' import { environment } from '../environments/environment' import { ClientScript } from '../types' import { logger } from './logger' @@ -32,7 +33,7 @@ type Hooks = { [ name: string ]: HookStructValue[] } type PluginInfo = { plugin: ServerConfigPlugin clientScript: ClientScriptJSON - pluginType: PluginType + pluginType: PluginType_Type isTheme: boolean } diff --git a/client/src/root-helpers/video.ts b/client/src/root-helpers/video.ts index 4a44615fb..4ee29df13 100644 --- a/client/src/root-helpers/video.ts +++ b/client/src/root-helpers/video.ts @@ -1,4 +1,4 @@ -import { HTMLServerConfig, Video, VideoPrivacy } from '@shared/models' +import { HTMLServerConfig, Video, VideoPrivacy, VideoPrivacyType } from '@peertube/peertube-models' function buildVideoOrPlaylistEmbed (options: { embedUrl: string @@ -42,13 +42,13 @@ function isP2PEnabled (video: Video, config: HTMLServerConfig, userP2PEnabled: b } function videoRequiresUserAuth (video: Video, videoPassword?: string) { - return new Set([ VideoPrivacy.PRIVATE, VideoPrivacy.INTERNAL ]).has(video.privacy.id) || + return new Set([ VideoPrivacy.PRIVATE, VideoPrivacy.INTERNAL ]).has(video.privacy.id) || (video.privacy.id === VideoPrivacy.PASSWORD_PROTECTED && !videoPassword) } -function videoRequiresFileToken (video: Video, videoPassword?: string) { - return new Set([ VideoPrivacy.PRIVATE, VideoPrivacy.INTERNAL, VideoPrivacy.PASSWORD_PROTECTED ]).has(video.privacy.id) +function videoRequiresFileToken (video: Video) { + return new Set([ VideoPrivacy.PRIVATE, VideoPrivacy.INTERNAL, VideoPrivacy.PASSWORD_PROTECTED ]).has(video.privacy.id) } export { diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index 78b812ffd..e4f723079 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts @@ -11,7 +11,7 @@ import { VideoPlaylist, VideoPlaylistElement, VideoState -} from '../../../../shared/models' +} from '@peertube/peertube-models' import { PeerTubePlayer } from '../../assets/player/peertube-player' import { TranslationsManager } from '../../assets/player/translations-manager' import { getParamString, logger, videoRequiresFileToken } from '../../root-helpers' diff --git a/client/src/standalone/videos/shared/auth-http.ts b/client/src/standalone/videos/shared/auth-http.ts index c1e9f7750..3dfc47b88 100644 --- a/client/src/standalone/videos/shared/auth-http.ts +++ b/client/src/standalone/videos/shared/auth-http.ts @@ -1,4 +1,4 @@ -import { HttpStatusCode, OAuth2ErrorCode, UserRefreshToken } from '../../../../../shared/models' +import { HttpStatusCode, OAuth2ErrorCode, OAuth2ErrorCodeType, UserRefreshToken } from '@peertube/peertube-models' import { OAuthUserTokens, objectToUrlEncoded } from '../../../root-helpers' import { peertubeLocalStorage } from '../../../root-helpers/peertube-web-storage' @@ -66,7 +66,7 @@ export class AuthHTTP { if (res.status === HttpStatusCode.UNAUTHORIZED_401) return undefined return res.json() - }).then((obj: UserRefreshToken & { code?: OAuth2ErrorCode }) => { + }).then((obj: UserRefreshToken & { code?: OAuth2ErrorCodeType }) => { if (!obj || obj.code === OAuth2ErrorCode.INVALID_GRANT) { OAuthUserTokens.flushLocalStorage(peertubeLocalStorage) this.removeTokensFromHeaders() diff --git a/client/src/standalone/videos/shared/live-manager.ts b/client/src/standalone/videos/shared/live-manager.ts index 5fac229ba..274f70d9c 100644 --- a/client/src/standalone/videos/shared/live-manager.ts +++ b/client/src/standalone/videos/shared/live-manager.ts @@ -1,5 +1,5 @@ import { Socket } from 'socket.io-client' -import { LiveVideoEventPayload, VideoDetails, VideoState } from '../../../../../shared/models' +import { LiveVideoEventPayload, VideoDetails, VideoState, VideoStateType } from '@peertube/peertube-models' import { PlayerHTML } from './player-html' import { Translations } from './translations' @@ -49,7 +49,7 @@ export class LiveManager { } displayInfo (options: { - state: VideoState + state: VideoStateType translations: Translations }) { const { state, translations } = options diff --git a/client/src/standalone/videos/shared/peertube-plugin.ts b/client/src/standalone/videos/shared/peertube-plugin.ts index daf6f2b03..95433299e 100644 --- a/client/src/standalone/videos/shared/peertube-plugin.ts +++ b/client/src/standalone/videos/shared/peertube-plugin.ts @@ -1,5 +1,5 @@ -import { peertubeTranslate } from '../../../../../shared/core-utils/i18n' -import { HTMLServerConfig, PublicServerSetting } from '../../../../../shared/models' +import { peertubeTranslate } from '@peertube/peertube-core-utils' +import { HTMLServerConfig, PublicServerSetting } from '@peertube/peertube-models' import { PluginInfo, PluginsManager } from '../../../root-helpers' import { RegisterClientHelpers } from '../../../types' import { AuthHTTP } from './auth-http' diff --git a/client/src/standalone/videos/shared/player-html.ts b/client/src/standalone/videos/shared/player-html.ts index 0defa0d70..ada2aaaf7 100644 --- a/client/src/standalone/videos/shared/player-html.ts +++ b/client/src/standalone/videos/shared/player-html.ts @@ -1,4 +1,4 @@ -import { peertubeTranslate } from '../../../../../shared/core-utils/i18n' +import { peertubeTranslate } from '@peertube/peertube-core-utils' import { logger } from '../../../root-helpers' import { Translations } from './translations' diff --git a/client/src/standalone/videos/shared/player-options-builder.ts b/client/src/standalone/videos/shared/player-options-builder.ts index 8a4e32444..3437ef421 100644 --- a/client/src/standalone/videos/shared/player-options-builder.ts +++ b/client/src/standalone/videos/shared/player-options-builder.ts @@ -1,4 +1,4 @@ -import { peertubeTranslate } from '../../../../../shared/core-utils/i18n' +import { peertubeTranslate } from '@peertube/peertube-core-utils' import { HTMLServerConfig, LiveVideo, @@ -9,7 +9,7 @@ import { VideoPlaylistElement, VideoState, VideoStreamingPlaylistType -} from '../../../../../shared/models' +} from '@peertube/peertube-models' import { HLSOptions, PeerTubePlayerContructorOptions, PeerTubePlayerLoadOptions, PlayerMode, VideoJSCaption } from '../../../assets/player' import { getBoolOrDefault, diff --git a/client/src/standalone/videos/shared/playlist-fetcher.ts b/client/src/standalone/videos/shared/playlist-fetcher.ts index 713d82e3a..db38e3d6c 100644 --- a/client/src/standalone/videos/shared/playlist-fetcher.ts +++ b/client/src/standalone/videos/shared/playlist-fetcher.ts @@ -1,4 +1,4 @@ -import { HttpStatusCode, ResultList, VideoPlaylistElement } from '../../../../../shared/models' +import { HttpStatusCode, ResultList, VideoPlaylistElement } from '@peertube/peertube-models' import { logger } from '../../../root-helpers' import { AuthHTTP } from './auth-http' diff --git a/client/src/standalone/videos/shared/playlist-tracker.ts b/client/src/standalone/videos/shared/playlist-tracker.ts index d8708826d..dc9a084b7 100644 --- a/client/src/standalone/videos/shared/playlist-tracker.ts +++ b/client/src/standalone/videos/shared/playlist-tracker.ts @@ -1,4 +1,4 @@ -import { VideoPlaylist, VideoPlaylistElement } from '../../../../../shared/models' +import { VideoPlaylist, VideoPlaylistElement } from '@peertube/peertube-models' import { logger } from '../../../root-helpers' export class PlaylistTracker { diff --git a/client/src/standalone/videos/shared/video-fetcher.ts b/client/src/standalone/videos/shared/video-fetcher.ts index 7fb94fbf3..9149d946e 100644 --- a/client/src/standalone/videos/shared/video-fetcher.ts +++ b/client/src/standalone/videos/shared/video-fetcher.ts @@ -1,4 +1,4 @@ -import { HttpStatusCode, LiveVideo, VideoDetails, VideoToken } from '../../../../../shared/models' +import { HttpStatusCode, LiveVideo, VideoDetails, VideoToken } from '@peertube/peertube-models' import { logger } from '../../../root-helpers' import { PeerTubeServerError } from '../../../types' import { AuthHTTP } from './auth-http' diff --git a/client/src/types/job-state-client.type.ts b/client/src/types/job-state-client.type.ts index 6123678df..6697539a3 100644 --- a/client/src/types/job-state-client.type.ts +++ b/client/src/types/job-state-client.type.ts @@ -1,3 +1,3 @@ -import { JobState } from '@shared/models' +import { JobState } from '@peertube/peertube-models' export type JobStateClient = JobState diff --git a/client/src/types/job-type-client.type.ts b/client/src/types/job-type-client.type.ts index 7d51f1db2..930809081 100644 --- a/client/src/types/job-type-client.type.ts +++ b/client/src/types/job-type-client.type.ts @@ -1,3 +1,3 @@ -import { JobType } from '@shared/models' +import { JobType } from '@peertube/peertube-models' export type JobTypeClient = 'all' | JobType diff --git a/client/src/types/register-client-option.model.ts b/client/src/types/register-client-option.model.ts index 2c09f15a7..2336119bb 100644 --- a/client/src/types/register-client-option.model.ts +++ b/client/src/types/register-client-option.model.ts @@ -5,7 +5,7 @@ import { RegisterClientSettingsScriptOptions, RegisterClientVideoFieldOptions, ServerConfig, SettingEntries -} from '@shared/models' +} from '@peertube/peertube-models' export type RegisterClientOptions = { registerHook: (options: RegisterClientHookOptions) => void diff --git a/client/src/types/server-error.model.ts b/client/src/types/server-error.model.ts index 4a57287fe..096deb50b 100644 --- a/client/src/types/server-error.model.ts +++ b/client/src/types/server-error.model.ts @@ -1,9 +1,9 @@ -import { ServerErrorCode } from '@shared/models/index' +import { ServerErrorCodeType } from '@peertube/peertube-models' export class PeerTubeServerError extends Error { - serverCode: ServerErrorCode + serverCode: ServerErrorCodeType - constructor (message: string, serverCode: ServerErrorCode) { + constructor (message: string, serverCode: ServerErrorCodeType) { super(message) this.name = 'CustomError' this.serverCode = serverCode diff --git a/client/tsconfig.eslint.json b/client/tsconfig.eslint.json index a18c461fe..91bb53e1d 100644 --- a/client/tsconfig.eslint.json +++ b/client/tsconfig.eslint.json @@ -4,5 +4,10 @@ // adjust "includes" to what makes sense for you and your project "src/**/*.ts", "e2e/**/*.ts" + ], + "references": [ + { "path": "../packages/core-utils" }, + { "path": "../packages/models" }, + { "path": "../packages/typescript-utils" } ] } diff --git a/client/tsconfig.json b/client/tsconfig.json index 5dee39362..48c2ff7f7 100644 --- a/client/tsconfig.json +++ b/client/tsconfig.json @@ -11,6 +11,7 @@ "noImplicitAny": true, "noImplicitThis": true, "alwaysStrict": true, + "allowJs": true, "importHelpers": true, "allowSyntheticDefaultImports": true, "strictBindCallApply": true, @@ -37,24 +38,6 @@ "@app/*": [ "src/app/*" ], - "@shared/models/*": [ - "../shared/models/*" - ], - "@shared/models": [ - "../shared/models" - ], - "@shared/core-utils": [ - "../shared/core-utils" - ], - "@shared/core-utils/*": [ - "../shared/core-utils/*" - ], - "@shared/typescript-utils": [ - "../shared/typescript-utils" - ], - "@shared/typescript-utils/*": [ - "../shared/typescript-utils/*" - ], "@root-helpers/*": [ "src/root-helpers/*" ], @@ -70,6 +53,11 @@ }, "useDefineForClassFields": false }, + "references": [ + { "path": "../packages/core-utils" }, + { "path": "../packages/models" }, + { "path": "../packages/typescript-utils" } + ], "files": [ "src/polyfills.ts" ], @@ -78,10 +66,6 @@ "src/**/*.d.ts", "src/shims/*.ts" ], - "exclude": [ - "../node_modules", - "../server" - ], "angularCompilerOptions": { "strictInjectionParameters": true, "fullTemplateTypeCheck": true, diff --git a/client/tsconfig.types.json b/client/tsconfig.types.json index 99d96d413..1481bc9b9 100644 --- a/client/tsconfig.types.json +++ b/client/tsconfig.types.json @@ -4,15 +4,12 @@ "stripInternal": true, "removeComments": false, "declaration": true, - "outDir": "../packages/types/dist/client/", + "outDir": "../packages/types-generator/dist/client/", "emitDeclarationOnly": true, "composite": true, "rootDir": "src/", - "tsBuildInfoFile": "../packages/types/dist/tsconfig.client.tsbuildinfo" + "tsBuildInfoFile": "../packages/types-generator/dist/tsconfig.client.tsbuildinfo" }, - "references": [ - { "path": "../shared/tsconfig.types.json" } - ], "files": [ "src/types/index.ts" ], "include": [ "src/types/**/*" diff --git a/client/webpack/webpack.video-embed.js b/client/webpack/webpack.video-embed.js index 47d440c25..30a8ec27c 100644 --- a/client/webpack/webpack.video-embed.js +++ b/client/webpack/webpack.video-embed.js @@ -29,9 +29,7 @@ module.exports = function () { alias: { 'video.js$': path.resolve('node_modules/video.js/core.js'), 'hls.js$': path.resolve('node_modules/hls.js/dist/hls.light.js'), - '@root-helpers': path.resolve('src/root-helpers'), - '@shared/models': path.resolve('../shared/models'), - '@shared/core-utils': path.resolve('../shared/core-utils') + '@root-helpers': path.resolve('src/root-helpers') }, fallback: { diff --git a/client/yarn.lock b/client/yarn.lock index 5c9f4bf42..cc0bd23a6 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -1353,6 +1353,13 @@ "@babel/helper-validator-identifier" "^7.19.1" to-fast-properties "^2.0.0" +"@cspotcode/source-map-support@^0.8.0": + version "0.8.1" + resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" + integrity sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw== + dependencies: + "@jridgewell/trace-mapping" "0.3.9" + "@csstools/css-parser-algorithms@^2.1.1": version "2.1.1" resolved "https://registry.yarnpkg.com/@csstools/css-parser-algorithms/-/css-parser-algorithms-2.1.1.tgz#7b62e6412a468a2d1096ed267edd1e4a7fd4a119" @@ -1818,6 +1825,11 @@ resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78" integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w== +"@jridgewell/resolve-uri@^3.0.3": + version "3.1.1" + resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz#c08679063f279615a3326583ba3a90d1d82cc721" + integrity sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA== + "@jridgewell/set-array@^1.0.1": version "1.1.2" resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72" @@ -1841,6 +1853,14 @@ resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32" integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg== +"@jridgewell/trace-mapping@0.3.9": + version "0.3.9" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz#6534fd5933a53ba7cbf3a17615e273a0d1273ff9" + integrity sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ== + dependencies: + "@jridgewell/resolve-uri" "^3.0.3" + "@jridgewell/sourcemap-codec" "^1.4.10" + "@jridgewell/trace-mapping@^0.3.17", "@jridgewell/trace-mapping@^0.3.9": version "0.3.18" resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.18.tgz#25783b2086daf6ff1dcb53c9249ae480e4dd4cd6" @@ -2204,6 +2224,26 @@ resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf" integrity sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A== +"@tsconfig/node10@^1.0.7": + version "1.0.9" + resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.9.tgz#df4907fc07a886922637b15e02d4cebc4c0021b2" + integrity sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA== + +"@tsconfig/node12@^1.0.7": + version "1.0.11" + resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.11.tgz#ee3def1f27d9ed66dac6e46a295cffb0152e058d" + integrity sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag== + +"@tsconfig/node14@^1.0.0": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.3.tgz#e4386316284f00b98435bf40f72f75a09dabf6c1" + integrity sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow== + +"@tsconfig/node16@^1.0.2": + version "1.0.4" + resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.4.tgz#0b92dcc0cc1c81f6f306a381f28e31b1a56536e9" + integrity sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA== + "@tufjs/canonical-json@1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@tufjs/canonical-json/-/canonical-json-1.0.0.tgz#eade9fd1f537993bc1f0949f3aea276ecc4fab31" @@ -3140,7 +3180,7 @@ acorn-jsx@^5.3.2: resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== -acorn-walk@^8.0.0: +acorn-walk@^8.0.0, acorn-walk@^8.1.1: version "8.2.0" resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== @@ -3150,6 +3190,11 @@ acorn@^8.0.4, acorn@^8.5.0, acorn@^8.7.1, acorn@^8.8.0: resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a" integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw== +acorn@^8.4.1: + version "8.10.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.10.0.tgz#8be5b3907a67221a81ab23c7889c4c5526b62ec5" + integrity sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw== + addr-to-ip-port@^1.0.1: version "1.5.4" resolved "https://registry.yarnpkg.com/addr-to-ip-port/-/addr-to-ip-port-1.5.4.tgz#9542b1c6219fdb8c9ce6cc72c14ee880ab7ddd88" @@ -3392,6 +3437,11 @@ are-we-there-yet@^3.0.0: delegates "^1.0.0" readable-stream "^3.6.0" +arg@^4.1.0: + version "4.1.3" + resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" + integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== + argparse@^1.0.7: version "1.0.10" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" @@ -3512,7 +3562,7 @@ available-typed-arrays@^1.0.5: resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7" integrity sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw== -axios@^1.0.0, axios@^1.2.1: +axios@^1.0.0, axios@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/axios/-/axios-1.4.0.tgz#38a7bf1224cd308de271146038b551d725f0be1f" integrity sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA== @@ -4088,14 +4138,14 @@ chrome-trace-event@^1.0.2: resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz#1015eced4741e15d06664a957dbbf50d041e26ac" integrity sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg== -chromedriver@^113.0.0: - version "113.0.0" - resolved "https://registry.yarnpkg.com/chromedriver/-/chromedriver-113.0.0.tgz#d4855f156ee51cea4282e04aadd29fa154e44dbb" - integrity sha512-UnQlt2kPicYXVNHPzy9HfcWvEbKJjjKAEaatdcnP/lCIRwuSoZFVLH0HVDAGdbraXp3dNVhfE2Qx7gw8TnHnPw== +chromedriver@^115.0.1: + version "115.0.1" + resolved "https://registry.yarnpkg.com/chromedriver/-/chromedriver-115.0.1.tgz#76cbf35f16e0c1f5e29ab821fb3b8b06d22c3e40" + integrity sha512-faE6WvIhXfhnoZ3nAxUXYzeDCKy612oPwpkUp0mVkA7fZPg2JHSUiYOQhUYgzHQgGvDWD5Fy2+M2xV55GKHBVQ== dependencies: "@testim/chrome-version" "^1.1.3" - axios "^1.2.1" - compare-versions "^5.0.1" + axios "^1.4.0" + compare-versions "^6.0.0" extract-zip "^2.0.1" https-proxy-agent "^5.0.1" proxy-from-env "^1.1.0" @@ -4307,10 +4357,10 @@ compact2string@^1.4.1: dependencies: ipaddr.js ">= 0.1.5" -compare-versions@^5.0.1: - version "5.0.3" - resolved "https://registry.yarnpkg.com/compare-versions/-/compare-versions-5.0.3.tgz#a9b34fea217472650ef4a2651d905f42c28ebfd7" - integrity sha512-4UZlZP8Z99MGEY+Ovg/uJxJuvoXuN4M6B3hKaiackiHrgzQFEe3diJi1mf1PNHbFujM7FvLrK2bpgIaImbtZ1A== +compare-versions@^6.0.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/compare-versions/-/compare-versions-6.1.0.tgz#3f2131e3ae93577df111dba133e6db876ffe127a" + integrity sha512-LNZQXhqUvqUTotpZ00qLSaify3b4VFD588aRr8MKFw4CMUr98ytzCW5wDH5qx/DEY5kCDXcbcRuCqL0szEf2tg== compress-commons@^4.1.0: version "4.1.1" @@ -4453,6 +4503,11 @@ crc32-stream@^4.0.2: crc-32 "^1.2.0" readable-stream "^3.4.0" +create-require@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" + integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== + critters@0.0.16: version "0.0.16" resolved "https://registry.yarnpkg.com/critters/-/critters-0.0.16.tgz#ffa2c5561a65b43c53b940036237ce72dcebfe93" @@ -4799,6 +4854,11 @@ diff@5.0.0: resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b" integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w== +diff@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" + integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== + diff@^5.0.0: version "5.1.0" resolved "https://registry.yarnpkg.com/diff/-/diff-5.1.0.tgz#bc52d298c5ea8df9194800224445ed43ffc87e40" @@ -7694,6 +7754,11 @@ make-dir@^3.0.2: dependencies: semver "^6.0.0" +make-error@^1.1.1: + version "1.3.6" + resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" + integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== + make-fetch-happen@^10.0.3: version "10.2.1" resolved "https://registry.yarnpkg.com/make-fetch-happen/-/make-fetch-happen-10.2.1.tgz#f5e3835c5e9817b617f2770870d9492d28678164" @@ -10802,6 +10867,25 @@ ts-loader@^9.3.0: micromatch "^4.0.0" semver "^7.3.4" +ts-node@^10.9.1: + version "10.9.1" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.1.tgz#e73de9102958af9e1f0b168a6ff320e25adcff4b" + integrity sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw== + dependencies: + "@cspotcode/source-map-support" "^0.8.0" + "@tsconfig/node10" "^1.0.7" + "@tsconfig/node12" "^1.0.7" + "@tsconfig/node14" "^1.0.0" + "@tsconfig/node16" "^1.0.2" + acorn "^8.4.1" + acorn-walk "^8.1.1" + arg "^4.1.0" + create-require "^1.1.0" + diff "^4.0.1" + make-error "^1.1.1" + v8-compile-cache-lib "^3.0.1" + yn "3.1.1" + tsconfig-paths@^3.14.1: version "3.14.2" resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz#6e32f1f79412decd261f92d633a9dc1cfa99f088" @@ -11096,6 +11180,11 @@ uuid@^9.0.0: resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.0.tgz#592f550650024a38ceb0c562f2f6aa435761efb5" integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg== +v8-compile-cache-lib@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" + integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== + v8-compile-cache@2.3.0, v8-compile-cache@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee" @@ -11792,6 +11881,11 @@ yauzl@^2.10.0: buffer-crc32 "~0.2.3" fd-slicer "~1.1.0" +yn@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" + integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== + yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" diff --git a/config/default.yaml b/config/default.yaml index 9d217b56b..fcd634d1d 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -261,6 +261,7 @@ open_telemetry: port: 9091 tracing: + # If tracing is enabled, you must provide --experimental-loader=@opentelemetry/instrumentation/hook.mjs flag to the node binary enabled: false # Send traces to a Jaeger compatible endpoint diff --git a/config/production.yaml.example b/config/production.yaml.example index 2afc5f982..2ec7c3fca 100644 --- a/config/production.yaml.example +++ b/config/production.yaml.example @@ -259,6 +259,7 @@ open_telemetry: port: 9091 tracing: + # If tracing is enabled, you must provide --experimental-loader=@opentelemetry/instrumentation/hook.mjs flag to the node binary enabled: false # Send traces to a Jaeger compatible endpoint diff --git a/package.json b/package.json index 7573232a1..89f8fd4ed 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,7 @@ "node": ">=16.x", "yarn": ">=1.x" }, - "bin": { - "peertube": "dist/server/tools/peertube.js" - }, + "type": "module", "author": { "name": "Chocobozzz", "email": "chocobozzz@framasoft.org", @@ -21,49 +19,60 @@ "url": "git+https://github.com/Chocobozzz/PeerTube.git" }, "typings": "*.d.ts", + "workspaces": [ + "packages/*", + "server" + ], "scripts": { "e2e:browserstack": "bash ./scripts/e2e/browserstack.sh", "e2e:local": "bash ./scripts/e2e/local.sh", - "setup:cli": "bash ./scripts/setup/cli.sh", "build": "bash ./scripts/build/index.sh", "build:embed": "bash ./scripts/build/embed.sh", "build:server": "bash ./scripts/build/server.sh", "build:client": "bash ./scripts/build/client.sh", "build:peertube-runner": "bash ./scripts/build/peertube-runner.sh", + "build:peertube-cli": "bash ./scripts/build/peertube-cli.sh", + "build:tests": "bash ./scripts/build/tests.sh", "clean:client": "bash ./scripts/clean/client/index.sh", "clean:server:test": "bash ./scripts/clean/server/test.sh", "i18n:update": "bash ./scripts/i18n/update.sh", - "plugin:install": "node ./dist/scripts/plugin/install.js", - "plugin:uninstall": "node ./dist/scripts/plugin/uninstall.js", - "i18n:create-custom-files": "node ./dist/scripts/i18n/create-custom-files.js", - "reset-password": "node ./dist/scripts/reset-password.js", "dev": "bash ./scripts/dev/index.sh", "dev:server": "bash ./scripts/dev/server.sh", "dev:embed": "bash ./scripts/dev/embed.sh", "dev:client": "bash ./scripts/dev/client.sh", - "dev:cli": "bash ./scripts/dev/cli.sh", + "dev:peertube-cli": "bash ./scripts/dev/peertube-cli.sh", "dev:peertube-runner": "bash ./scripts/dev/peertube-runner.sh", "start": "node dist/server", "start:server": "node dist/server --no-client", + "plugin:install": "node ./dist/scripts/plugin/install.js", + "plugin:uninstall": "node ./dist/scripts/plugin/uninstall.js", + "reset-password": "node ./dist/scripts/reset-password.js", "update-host": "node ./dist/scripts/update-host.js", "regenerate-thumbnails": "node ./dist/scripts/regenerate-thumbnails.js", "create-import-video-file-job": "node ./dist/scripts/create-import-video-file-job.js", "create-move-video-storage-job": "node ./dist/scripts/create-move-video-storage-job.js", "create-generate-storyboard-job": "node ./dist/scripts/create-generate-storyboard-job.js", - "test": "bash ./scripts/test.sh", - "generate-cli-doc": "bash ./scripts/generate-cli-doc.sh", - "generate-types-package": "ts-node ./packages/types/generate-package.ts", "parse-log": "node ./dist/scripts/parse-log.js", "prune-storage": "node ./dist/scripts/prune-storage.js", + "test": "bash ./scripts/test.sh", + "generate-cli-doc": "bash ./scripts/generate-cli-doc.sh", + "generate-types-package": "tsx --conditions=peertube:tsx ./packages/types-generator/generate-package.ts", + "i18n:create-custom-files": "tsx --conditions=peertube:tsx ./scripts/i18n/create-custom-files.ts", + "benchmark-server": "tsx --conditions=peertube:tsx ./scripts/benchmark.ts", + "client:build-stats": "tsx --conditions=peertube:tsx ./scripts/client-build-stats.ts", + "generate-code-contributors": "tsx --conditions=peertube:tsx ./scripts/generate-code-contributors.ts", + "simulate-many-viewers": "tsx --conditions=peertube:tsx ./scripts/simulate-many-viewers.ts", "postinstall": "test -n \"$NOCLIENT\" || (cd client && yarn install --pure-lockfile)", "tsc": "tsc", "commander": "commander", "lint": "npm run ci -- lint", "ng": "ng", - "ts-node": "ts-node", + "tsx": "tsx", "eslint": "eslint", "resolve-tspaths": "resolve-tspaths", - "resolve-tspaths:server": "npm run resolve-tspaths -- --project tsconfig.json --src . --out dist", + "resolve-tspaths:server": "npm run resolve-tspaths -- --project server/tsconfig.json --src server --out dist", + "resolve-tspaths:server-lib": "npm run resolve-tspaths -- --project server/tsconfig.lib.json --src server --out server/dist", + "resolve-tspaths:tests": "npm run resolve-tspaths -- --project packages/tests/tsconfig.json --src packages/tests/src --out packages/tests/dist", "concurrently": "concurrently", "mocha": "mocha", "ci": "bash ./scripts/ci.sh", @@ -80,29 +89,30 @@ "@aws-sdk/node-http-handler": "^3.190.0", "@aws-sdk/s3-request-presigner": "^3.345.0", "@babel/parser": "^7.17.8", + "@commander-js/extra-typings": "^11.0.0", "@node-oauth/oauth2-server": "^4.2.0", "@opentelemetry/api": "^1.1.0", - "@opentelemetry/exporter-jaeger": "^1.3.1", - "@opentelemetry/exporter-prometheus": "~0.39.1", - "@opentelemetry/instrumentation": "^0.39.1", - "@opentelemetry/instrumentation-dns": "^0.31.2", - "@opentelemetry/instrumentation-express": "^0.32.1", - "@opentelemetry/instrumentation-fs": "^0.7.0", - "@opentelemetry/instrumentation-http": "^0.39.1", - "@opentelemetry/instrumentation-ioredis": "^0.34.2", - "@opentelemetry/instrumentation-pg": "^0.35.2", - "@opentelemetry/resources": "^1.3.1", - "@opentelemetry/sdk-metrics": "^1.8.0", - "@opentelemetry/sdk-trace-base": "^1.3.1", - "@opentelemetry/sdk-trace-node": "^1.3.1", - "@opentelemetry/semantic-conventions": "^1.3.1", + "@opentelemetry/exporter-jaeger": "^1.15.1", + "@opentelemetry/exporter-prometheus": "~0.41.1", + "@opentelemetry/instrumentation": "^0.41.1", + "@opentelemetry/instrumentation-dns": "^0.32.0", + "@opentelemetry/instrumentation-express": "^0.33.0", + "@opentelemetry/instrumentation-fs": "^0.8.0", + "@opentelemetry/instrumentation-http": "^0.41.1", + "@opentelemetry/instrumentation-ioredis": "^0.35.0", + "@opentelemetry/instrumentation-pg": "^0.36.0", + "@opentelemetry/resources": "^1.15.1", + "@opentelemetry/sdk-metrics": "^1.15.1", + "@opentelemetry/sdk-trace-base": "^1.15.1", + "@opentelemetry/sdk-trace-node": "^1.15.1", + "@opentelemetry/semantic-conventions": "^1.15.1", "@peertube/feed": "^5.1.0", "@peertube/http-signature": "^1.7.0", "@uploadx/core": "^6.0.0", "async-lru": "^1.1.1", "async-mutex": "^0.4.0", "bcrypt": "5.1.0", - "bencode": "^2.0.2", + "bencode": "^3.1.1", "bittorrent-tracker": "^9", "bluebird": "^3.5.0", "bullmq": "^3.6.6", @@ -122,7 +132,7 @@ "flat": "^5.0.0", "fluent-ffmpeg": "^2.1.0", "fs-extra": "^11.1.0", - "got": "^11.8.2", + "got": "^13.0.0", "helmet": "^7.0.0", "hpagent": "^1.0.0", "http-problem-details": "^0.1.5", @@ -130,11 +140,11 @@ "ip-anonymize": "^0.1.0", "ipaddr.js": "2.0.1", "is-cidr": "^4.0.0", - "iso-639-3": "2.2.0", + "iso-639-3": "3.0.1", "jimp": "^0.22.4", "js-yaml": "^4.0.0", "jsonld": "~8.2.0", - "lodash": "^4.17.21", + "lodash-es": "^4.17.21", "lru-cache": "^9.1.1", "magnet-uri": "^6", "markdown-it": "^13.0.1", @@ -145,9 +155,9 @@ "multer": "^1.4.5-lts.1", "node-media-server": "^2.1.4", "nodemailer": "^6.0.0", - "opentelemetry-instrumentation-sequelize": "^0.35.0", + "opentelemetry-instrumentation-sequelize": "^0.39.1", "otpauth": "^9.0.2", - "p-queue": "^6", + "p-queue": "^7.3.4", "parse-torrent": "^9", "password-generator": "^2.0.2", "pg": "^8.2.1", @@ -164,7 +174,6 @@ "socket.io": "^4.5.4", "sql-formatter": "^12.0.1", "srt-to-vtt": "^1.1.2", - "tsconfig-paths": "^4.0.0", "tslib": "^2.0.0", "useragent": "^2.3.0", "validator": "^13.0.0", @@ -175,6 +184,7 @@ }, "devDependencies": { "@peertube/maildev": "^1.2.0", + "@peertube/resolve-tspaths": "^0.8.14", "@types/bcrypt": "^5.0.0", "@types/bencode": "^2.0.0", "@types/bluebird": "^3.5.33", @@ -188,7 +198,8 @@ "@types/express": "4.17.9", "@types/fluent-ffmpeg": "^2.1.16", "@types/fs-extra": "^11.0.1", - "@types/lodash": "^4.14.64", + "@types/jsonld": "^1.5.9", + "@types/lodash-es": "^4.17.8", "@types/magnet-uri": "^5.1.1", "@types/maildev": "^0.0.4", "@types/memoizee": "^0.4.2", @@ -200,7 +211,7 @@ "@types/oauth2-server": "^3.0.8", "@types/request": "^2.0.3", "@types/supertest": "^2.0.3", - "@types/validator": "^13.0.0", + "@types/validator": "^13.9.0", "@types/webtorrent": "^0.109.0", "@types/ws": "^8.2.0", "@typescript-eslint/eslint-plugin": "^5.0.0", @@ -210,6 +221,7 @@ "chai-xml": "^0.4.0", "concurrently": "^8.0.1", "depcheck": "^1.4.2", + "esbuild": "^0.19.0", "eslint": "8.41.0", "eslint-config-standard-with-typescript": "34.0.1", "eslint-plugin-import": "^2.20.1", @@ -222,12 +234,11 @@ "pixelmatch": "^5.3.0", "pngjs": "^7.0.0", "proxy": "^2.1.1", - "resolve-tspaths": "^0.8.8", "socket.io-client": "^4.5.4", "supertest": "^6.0.1", "swagger-cli": "^4.0.2", - "ts-node": "^10.8.1", "tsc-watch": "^6.0.0", + "tsx": "^3.12.7", "typescript": "~5.0.4" }, "bundlewatch": { diff --git a/packages/core-utils/package.json b/packages/core-utils/package.json new file mode 100644 index 000000000..d3bf18335 --- /dev/null +++ b/packages/core-utils/package.json @@ -0,0 +1,19 @@ +{ + "name": "@peertube/peertube-core-utils", + "private": true, + "version": "0.0.0", + "main": "dist/index.js", + "files": [ "dist" ], + "exports": { + "types": "./dist/index.d.ts", + "peertube:tsx": "./src/index.ts", + "default": "./dist/index.js" + }, + "type": "module", + "devDependencies": {}, + "scripts": { + "build": "tsc", + "watch": "tsc -w" + }, + "dependencies": {} +} diff --git a/shared/core-utils/abuse/abuse-predefined-reasons.ts b/packages/core-utils/src/abuse/abuse-predefined-reasons.ts similarity index 69% rename from shared/core-utils/abuse/abuse-predefined-reasons.ts rename to packages/core-utils/src/abuse/abuse-predefined-reasons.ts index 9967e54dd..68534a1e0 100644 --- a/shared/core-utils/abuse/abuse-predefined-reasons.ts +++ b/packages/core-utils/src/abuse/abuse-predefined-reasons.ts @@ -1,7 +1,7 @@ -import { AbusePredefinedReasons, AbusePredefinedReasonsString } from '../../models/moderation/abuse/abuse-reason.model' +import { AbusePredefinedReasons, AbusePredefinedReasonsString, AbusePredefinedReasonsType } from '@peertube/peertube-models' export const abusePredefinedReasonsMap: { - [key in AbusePredefinedReasonsString]: AbusePredefinedReasons + [key in AbusePredefinedReasonsString]: AbusePredefinedReasonsType } = { violentOrRepulsive: AbusePredefinedReasons.VIOLENT_OR_REPULSIVE, hatefulOrAbusive: AbusePredefinedReasons.HATEFUL_OR_ABUSIVE, @@ -11,4 +11,4 @@ export const abusePredefinedReasonsMap: { serverRules: AbusePredefinedReasons.SERVER_RULES, thumbnails: AbusePredefinedReasons.THUMBNAILS, captions: AbusePredefinedReasons.CAPTIONS -} +} as const diff --git a/packages/core-utils/src/abuse/index.ts b/packages/core-utils/src/abuse/index.ts new file mode 100644 index 000000000..b79b86155 --- /dev/null +++ b/packages/core-utils/src/abuse/index.ts @@ -0,0 +1 @@ +export * from './abuse-predefined-reasons.js' diff --git a/shared/core-utils/common/array.ts b/packages/core-utils/src/common/array.ts similarity index 100% rename from shared/core-utils/common/array.ts rename to packages/core-utils/src/common/array.ts diff --git a/shared/core-utils/common/date.ts b/packages/core-utils/src/common/date.ts similarity index 100% rename from shared/core-utils/common/date.ts rename to packages/core-utils/src/common/date.ts diff --git a/packages/core-utils/src/common/index.ts b/packages/core-utils/src/common/index.ts new file mode 100644 index 000000000..d7d8599aa --- /dev/null +++ b/packages/core-utils/src/common/index.ts @@ -0,0 +1,10 @@ +export * from './array.js' +export * from './random.js' +export * from './date.js' +export * from './number.js' +export * from './object.js' +export * from './regexp.js' +export * from './time.js' +export * from './promises.js' +export * from './url.js' +export * from './version.js' diff --git a/shared/core-utils/common/number.ts b/packages/core-utils/src/common/number.ts similarity index 100% rename from shared/core-utils/common/number.ts rename to packages/core-utils/src/common/number.ts diff --git a/shared/core-utils/common/object.ts b/packages/core-utils/src/common/object.ts similarity index 100% rename from shared/core-utils/common/object.ts rename to packages/core-utils/src/common/object.ts diff --git a/shared/core-utils/common/promises.ts b/packages/core-utils/src/common/promises.ts similarity index 100% rename from shared/core-utils/common/promises.ts rename to packages/core-utils/src/common/promises.ts diff --git a/shared/core-utils/common/random.ts b/packages/core-utils/src/common/random.ts similarity index 100% rename from shared/core-utils/common/random.ts rename to packages/core-utils/src/common/random.ts diff --git a/shared/core-utils/common/regexp.ts b/packages/core-utils/src/common/regexp.ts similarity index 100% rename from shared/core-utils/common/regexp.ts rename to packages/core-utils/src/common/regexp.ts diff --git a/shared/core-utils/common/time.ts b/packages/core-utils/src/common/time.ts similarity index 100% rename from shared/core-utils/common/time.ts rename to packages/core-utils/src/common/time.ts diff --git a/shared/core-utils/common/url.ts b/packages/core-utils/src/common/url.ts similarity index 97% rename from shared/core-utils/common/url.ts rename to packages/core-utils/src/common/url.ts index 33fc5ee3a..449b6c9dc 100644 --- a/shared/core-utils/common/url.ts +++ b/packages/core-utils/src/common/url.ts @@ -1,5 +1,5 @@ -import { Video, VideoPlaylist } from '../../models' -import { secondsToTime } from './date' +import { Video, VideoPlaylist } from '@peertube/peertube-models' +import { secondsToTime } from './date.js' function addQueryParams (url: string, params: { [ id: string ]: string }) { const objUrl = new URL(url) diff --git a/shared/core-utils/common/version.ts b/packages/core-utils/src/common/version.ts similarity index 100% rename from shared/core-utils/common/version.ts rename to packages/core-utils/src/common/version.ts diff --git a/shared/core-utils/i18n/i18n.ts b/packages/core-utils/src/i18n/i18n.ts similarity index 100% rename from shared/core-utils/i18n/i18n.ts rename to packages/core-utils/src/i18n/i18n.ts diff --git a/packages/core-utils/src/i18n/index.ts b/packages/core-utils/src/i18n/index.ts new file mode 100644 index 000000000..758e54b73 --- /dev/null +++ b/packages/core-utils/src/i18n/index.ts @@ -0,0 +1 @@ +export * from './i18n.js' diff --git a/packages/core-utils/src/index.ts b/packages/core-utils/src/index.ts new file mode 100644 index 000000000..3ca5d9d47 --- /dev/null +++ b/packages/core-utils/src/index.ts @@ -0,0 +1,7 @@ +export * from './abuse/index.js' +export * from './common/index.js' +export * from './i18n/index.js' +export * from './plugins/index.js' +export * from './renderer/index.js' +export * from './users/index.js' +export * from './videos/index.js' diff --git a/shared/core-utils/plugins/hooks.ts b/packages/core-utils/src/plugins/hooks.ts similarity index 85% rename from shared/core-utils/plugins/hooks.ts rename to packages/core-utils/src/plugins/hooks.ts index 96bcc945e..fe7c4a74f 100644 --- a/shared/core-utils/plugins/hooks.ts +++ b/packages/core-utils/src/plugins/hooks.ts @@ -1,6 +1,5 @@ -import { RegisteredExternalAuthConfig } from '@shared/models' -import { HookType } from '../../models/plugins/hook-type.enum' -import { isCatchable, isPromise } from '../common/promises' +import { HookType, HookType_Type, RegisteredExternalAuthConfig } from '@peertube/peertube-models' +import { isCatchable, isPromise } from '../common/promises.js' function getHookType (hookName: string) { if (hookName.startsWith('filter:')) return HookType.FILTER @@ -11,7 +10,7 @@ function getHookType (hookName: string) { async function internalRunHook (options: { handler: Function - hookType: HookType + hookType: HookType_Type result: T params: any onError: (err: Error) => void diff --git a/packages/core-utils/src/plugins/index.ts b/packages/core-utils/src/plugins/index.ts new file mode 100644 index 000000000..3462bf41e --- /dev/null +++ b/packages/core-utils/src/plugins/index.ts @@ -0,0 +1 @@ +export * from './hooks.js' diff --git a/shared/core-utils/renderer/html.ts b/packages/core-utils/src/renderer/html.ts similarity index 100% rename from shared/core-utils/renderer/html.ts rename to packages/core-utils/src/renderer/html.ts diff --git a/packages/core-utils/src/renderer/index.ts b/packages/core-utils/src/renderer/index.ts new file mode 100644 index 000000000..0dd0a8808 --- /dev/null +++ b/packages/core-utils/src/renderer/index.ts @@ -0,0 +1,2 @@ +export * from './markdown.js' +export * from './html.js' diff --git a/shared/core-utils/renderer/markdown.ts b/packages/core-utils/src/renderer/markdown.ts similarity index 100% rename from shared/core-utils/renderer/markdown.ts rename to packages/core-utils/src/renderer/markdown.ts diff --git a/packages/core-utils/src/users/index.ts b/packages/core-utils/src/users/index.ts new file mode 100644 index 000000000..3fd9dc448 --- /dev/null +++ b/packages/core-utils/src/users/index.ts @@ -0,0 +1 @@ +export * from './user-role.js' diff --git a/shared/core-utils/users/user-role.ts b/packages/core-utils/src/users/user-role.ts similarity index 71% rename from shared/core-utils/users/user-role.ts rename to packages/core-utils/src/users/user-role.ts index 5f3b9a10f..0add3a0a8 100644 --- a/shared/core-utils/users/user-role.ts +++ b/packages/core-utils/src/users/user-role.ts @@ -1,12 +1,12 @@ -import { UserRight, UserRole } from '../../models/users' +import { UserRight, UserRightType, UserRole, UserRoleType } from '@peertube/peertube-models' -export const USER_ROLE_LABELS: { [ id in UserRole ]: string } = { +export const USER_ROLE_LABELS: { [ id in UserRoleType ]: string } = { [UserRole.USER]: 'User', [UserRole.MODERATOR]: 'Moderator', [UserRole.ADMINISTRATOR]: 'Administrator' } -const userRoleRights: { [ id in UserRole ]: UserRight[] } = { +const userRoleRights: { [ id in UserRoleType ]: UserRightType[] } = { [UserRole.ADMINISTRATOR]: [ UserRight.ALL ], @@ -30,7 +30,7 @@ const userRoleRights: { [ id in UserRole ]: UserRight[] } = { [UserRole.USER]: [] } -export function hasUserRight (userRole: UserRole, userRight: UserRight) { +export function hasUserRight (userRole: UserRoleType, userRight: UserRightType) { const userRights = userRoleRights[userRole] return userRights.includes(UserRight.ALL) || userRights.includes(userRight) diff --git a/shared/core-utils/videos/bitrate.ts b/packages/core-utils/src/videos/bitrate.ts similarity index 92% rename from shared/core-utils/videos/bitrate.ts rename to packages/core-utils/src/videos/bitrate.ts index 6be027826..b28eaf460 100644 --- a/shared/core-utils/videos/bitrate.ts +++ b/packages/core-utils/src/videos/bitrate.ts @@ -1,6 +1,6 @@ -import { VideoResolution } from '@shared/models' +import { VideoResolution, VideoResolutionType } from '@peertube/peertube-models' -type BitPerPixel = { [ id in VideoResolution ]: number } +type BitPerPixel = { [ id in VideoResolutionType ]: number } // https://bitmovin.com/video-bitrate-streaming-hls-dash/ @@ -41,7 +41,7 @@ const maxBitPerPixel: BitPerPixel = { } function getAverageTheoreticalBitrate (options: { - resolution: VideoResolution + resolution: number ratio: number fps: number }) { @@ -52,7 +52,7 @@ function getAverageTheoreticalBitrate (options: { } function getMaxTheoreticalBitrate (options: { - resolution: VideoResolution + resolution: number ratio: number fps: number }) { @@ -63,7 +63,7 @@ function getMaxTheoreticalBitrate (options: { } function getMinTheoreticalBitrate (options: { - resolution: VideoResolution + resolution: number ratio: number fps: number }) { @@ -85,7 +85,7 @@ export { function calculateBitrate (options: { bitPerPixel: BitPerPixel - resolution: VideoResolution + resolution: number ratio: number fps: number }) { diff --git a/shared/core-utils/videos/common.ts b/packages/core-utils/src/videos/common.ts similarity index 75% rename from shared/core-utils/videos/common.ts rename to packages/core-utils/src/videos/common.ts index 0431edaaf..47564fb2a 100644 --- a/shared/core-utils/videos/common.ts +++ b/packages/core-utils/src/videos/common.ts @@ -1,6 +1,4 @@ -import { VideoStreamingPlaylistType } from '@shared/models' -import { VideoPrivacy } from '../../models/videos/video-privacy.enum' -import { VideoDetails } from '../../models/videos/video.model' +import { VideoDetails, VideoPrivacy, VideoStreamingPlaylistType } from '@peertube/peertube-models' function getAllPrivacies () { return [ VideoPrivacy.PUBLIC, VideoPrivacy.INTERNAL, VideoPrivacy.PRIVATE, VideoPrivacy.UNLISTED, VideoPrivacy.PASSWORD_PROTECTED ] diff --git a/packages/core-utils/src/videos/index.ts b/packages/core-utils/src/videos/index.ts new file mode 100644 index 000000000..7d3dacdd4 --- /dev/null +++ b/packages/core-utils/src/videos/index.ts @@ -0,0 +1,2 @@ +export * from './bitrate.js' +export * from './common.js' diff --git a/packages/core-utils/tsconfig.json b/packages/core-utils/tsconfig.json new file mode 100644 index 000000000..56ebffbb3 --- /dev/null +++ b/packages/core-utils/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./dist", + "rootDir": "src", + "tsBuildInfoFile": "./dist/.tsbuildinfo" + }, + "references": [ + { "path": "../models" } + ] +} diff --git a/packages/ffmpeg/package.json b/packages/ffmpeg/package.json new file mode 100644 index 000000000..fca86df25 --- /dev/null +++ b/packages/ffmpeg/package.json @@ -0,0 +1,19 @@ +{ + "name": "@peertube/peertube-ffmpeg", + "private": true, + "version": "0.0.0", + "main": "dist/index.js", + "files": [ "dist" ], + "exports": { + "types": "./dist/index.d.ts", + "peertube:tsx": "./src/index.ts", + "default": "./dist/index.js" + }, + "type": "module", + "devDependencies": {}, + "scripts": { + "build": "tsc", + "watch": "tsc -w" + }, + "dependencies": {} +} diff --git a/shared/ffmpeg/ffmpeg-command-wrapper.ts b/packages/ffmpeg/src/ffmpeg-command-wrapper.ts similarity index 96% rename from shared/ffmpeg/ffmpeg-command-wrapper.ts rename to packages/ffmpeg/src/ffmpeg-command-wrapper.ts index efb75c198..647ee3996 100644 --- a/shared/ffmpeg/ffmpeg-command-wrapper.ts +++ b/packages/ffmpeg/src/ffmpeg-command-wrapper.ts @@ -1,6 +1,6 @@ -import ffmpeg, { FfmpegCommand, getAvailableEncoders } from 'fluent-ffmpeg' -import { pick, promisify0 } from '@shared/core-utils' -import { AvailableEncoders, EncoderOptionsBuilder, EncoderOptionsBuilderParams, EncoderProfile } from '@shared/models' +import ffmpeg, { FfmpegCommand } from 'fluent-ffmpeg' +import { pick, promisify0 } from '@peertube/peertube-core-utils' +import { AvailableEncoders, EncoderOptionsBuilder, EncoderOptionsBuilderParams, EncoderProfile } from '@peertube/peertube-models' type FFmpegLogger = { info: (msg: string, obj?: any) => void @@ -220,7 +220,7 @@ export class FFmpegCommandWrapper { return FFmpegCommandWrapper.supportedEncoders } - const getAvailableEncodersPromise = promisify0(getAvailableEncoders) + const getAvailableEncodersPromise = promisify0(ffmpeg.getAvailableEncoders) const availableFFmpegEncoders = await getAvailableEncodersPromise() const searchEncoders = new Set() diff --git a/shared/ffmpeg/ffmpeg-default-transcoding-profile.ts b/packages/ffmpeg/src/ffmpeg-default-transcoding-profile.ts similarity index 96% rename from shared/ffmpeg/ffmpeg-default-transcoding-profile.ts rename to packages/ffmpeg/src/ffmpeg-default-transcoding-profile.ts index 8a3f32011..0d3538512 100644 --- a/shared/ffmpeg/ffmpeg-default-transcoding-profile.ts +++ b/packages/ffmpeg/src/ffmpeg-default-transcoding-profile.ts @@ -1,5 +1,5 @@ import { FfprobeData } from 'fluent-ffmpeg' -import { getAverageTheoreticalBitrate, getMaxTheoreticalBitrate, getMinTheoreticalBitrate } from '@shared/core-utils' +import { getAverageTheoreticalBitrate, getMaxTheoreticalBitrate, getMinTheoreticalBitrate } from '@peertube/peertube-core-utils' import { buildStreamSuffix, ffprobePromise, @@ -9,8 +9,8 @@ import { getVideoStreamBitrate, getVideoStreamDimensionsInfo, getVideoStreamFPS -} from '@shared/ffmpeg' -import { EncoderOptionsBuilder, EncoderOptionsBuilderParams, VideoResolution } from '@shared/models' +} from '@peertube/peertube-ffmpeg' +import { EncoderOptionsBuilder, EncoderOptionsBuilderParams } from '@peertube/peertube-models' const defaultX264VODOptionsBuilder: EncoderOptionsBuilder = (options: EncoderOptionsBuilderParams) => { const { fps, inputRatio, inputBitrate, resolution } = options @@ -152,7 +152,7 @@ export async function canDoQuickVideoTranscode (path: string, probe?: FfprobeDat function getTargetBitrate (options: { inputBitrate: number - resolution: VideoResolution + resolution: number ratio: number fps: number }) { diff --git a/shared/ffmpeg/ffmpeg-edition.ts b/packages/ffmpeg/src/ffmpeg-edition.ts similarity index 98% rename from shared/ffmpeg/ffmpeg-edition.ts rename to packages/ffmpeg/src/ffmpeg-edition.ts index 724ca1ea9..021342930 100644 --- a/shared/ffmpeg/ffmpeg-edition.ts +++ b/packages/ffmpeg/src/ffmpeg-edition.ts @@ -1,7 +1,7 @@ import { FilterSpecification } from 'fluent-ffmpeg' -import { FFmpegCommandWrapper, FFmpegCommandWrapperOptions } from './ffmpeg-command-wrapper' -import { presetVOD } from './shared/presets' -import { ffprobePromise, getVideoStreamDimensionsInfo, getVideoStreamDuration, getVideoStreamFPS, hasAudioStream } from './ffprobe' +import { FFmpegCommandWrapper, FFmpegCommandWrapperOptions } from './ffmpeg-command-wrapper.js' +import { presetVOD } from './shared/presets.js' +import { ffprobePromise, getVideoStreamDimensionsInfo, getVideoStreamDuration, getVideoStreamFPS, hasAudioStream } from './ffprobe.js' export class FFmpegEdition { private readonly commandWrapper: FFmpegCommandWrapper diff --git a/shared/ffmpeg/ffmpeg-images.ts b/packages/ffmpeg/src/ffmpeg-images.ts similarity index 96% rename from shared/ffmpeg/ffmpeg-images.ts rename to packages/ffmpeg/src/ffmpeg-images.ts index 618fac7d1..4cd37aa80 100644 --- a/shared/ffmpeg/ffmpeg-images.ts +++ b/packages/ffmpeg/src/ffmpeg-images.ts @@ -1,5 +1,5 @@ -import { FFmpegCommandWrapper, FFmpegCommandWrapperOptions } from './ffmpeg-command-wrapper' -import { getVideoStreamDuration } from './ffprobe' +import { FFmpegCommandWrapper, FFmpegCommandWrapperOptions } from './ffmpeg-command-wrapper.js' +import { getVideoStreamDuration } from './ffprobe.js' export class FFmpegImage { private readonly commandWrapper: FFmpegCommandWrapper diff --git a/shared/ffmpeg/ffmpeg-live.ts b/packages/ffmpeg/src/ffmpeg-live.ts similarity index 97% rename from shared/ffmpeg/ffmpeg-live.ts rename to packages/ffmpeg/src/ffmpeg-live.ts index cca4c6474..20318f63c 100644 --- a/shared/ffmpeg/ffmpeg-live.ts +++ b/packages/ffmpeg/src/ffmpeg-live.ts @@ -1,9 +1,9 @@ import { FilterSpecification } from 'fluent-ffmpeg' import { join } from 'path' -import { pick } from '@shared/core-utils' -import { FFmpegCommandWrapper, FFmpegCommandWrapperOptions } from './ffmpeg-command-wrapper' -import { buildStreamSuffix, getScaleFilter, StreamType } from './ffmpeg-utils' -import { addDefaultEncoderGlobalParams, addDefaultEncoderParams, applyEncoderOptions } from './shared' +import { pick } from '@peertube/peertube-core-utils' +import { FFmpegCommandWrapper, FFmpegCommandWrapperOptions } from './ffmpeg-command-wrapper.js' +import { buildStreamSuffix, getScaleFilter, StreamType } from './ffmpeg-utils.js' +import { addDefaultEncoderGlobalParams, addDefaultEncoderParams, applyEncoderOptions } from './shared/index.js' export class FFmpegLive { private readonly commandWrapper: FFmpegCommandWrapper diff --git a/shared/ffmpeg/ffmpeg-utils.ts b/packages/ffmpeg/src/ffmpeg-utils.ts similarity index 85% rename from shared/ffmpeg/ffmpeg-utils.ts rename to packages/ffmpeg/src/ffmpeg-utils.ts index 7d09c32ca..56fd8c0b3 100644 --- a/shared/ffmpeg/ffmpeg-utils.ts +++ b/packages/ffmpeg/src/ffmpeg-utils.ts @@ -1,4 +1,4 @@ -import { EncoderOptions } from '@shared/models' +import { EncoderOptions } from '@peertube/peertube-models' export type StreamType = 'audio' | 'video' diff --git a/shared/ffmpeg/ffmpeg-version.ts b/packages/ffmpeg/src/ffmpeg-version.ts similarity index 100% rename from shared/ffmpeg/ffmpeg-version.ts rename to packages/ffmpeg/src/ffmpeg-version.ts diff --git a/shared/ffmpeg/ffmpeg-vod.ts b/packages/ffmpeg/src/ffmpeg-vod.ts similarity index 97% rename from shared/ffmpeg/ffmpeg-vod.ts rename to packages/ffmpeg/src/ffmpeg-vod.ts index e40ca0a1e..6dd272b8d 100644 --- a/shared/ffmpeg/ffmpeg-vod.ts +++ b/packages/ffmpeg/src/ffmpeg-vod.ts @@ -1,12 +1,12 @@ import { MutexInterface } from 'async-mutex' import { FfmpegCommand } from 'fluent-ffmpeg' -import { readFile, writeFile } from 'fs-extra' +import { readFile, writeFile } from 'fs/promises' import { dirname } from 'path' -import { pick } from '@shared/core-utils' -import { VideoResolution } from '@shared/models' -import { FFmpegCommandWrapper, FFmpegCommandWrapperOptions } from './ffmpeg-command-wrapper' -import { ffprobePromise, getVideoStreamDimensionsInfo } from './ffprobe' -import { presetCopy, presetOnlyAudio, presetVOD } from './shared/presets' +import { pick } from '@peertube/peertube-core-utils' +import { VideoResolution } from '@peertube/peertube-models' +import { FFmpegCommandWrapper, FFmpegCommandWrapperOptions } from './ffmpeg-command-wrapper.js' +import { ffprobePromise, getVideoStreamDimensionsInfo } from './ffprobe.js' +import { presetCopy, presetOnlyAudio, presetVOD } from './shared/presets.js' export type TranscodeVODOptionsType = 'hls' | 'hls-from-ts' | 'quick-transcode' | 'video' | 'merge-audio' | 'only-audio' diff --git a/shared/ffmpeg/ffprobe.ts b/packages/ffmpeg/src/ffprobe.ts similarity index 96% rename from shared/ffmpeg/ffprobe.ts rename to packages/ffmpeg/src/ffprobe.ts index fda08c28e..ed1742ab1 100644 --- a/shared/ffmpeg/ffprobe.ts +++ b/packages/ffmpeg/src/ffprobe.ts @@ -1,6 +1,6 @@ -import { ffprobe, FfprobeData } from 'fluent-ffmpeg' -import { forceNumber } from '@shared/core-utils' -import { VideoResolution } from '@shared/models/videos' +import ffmpeg, { FfprobeData } from 'fluent-ffmpeg' +import { forceNumber } from '@peertube/peertube-core-utils' +import { VideoResolution } from '@peertube/peertube-models' /** * @@ -10,7 +10,7 @@ import { VideoResolution } from '@shared/models/videos' function ffprobePromise (path: string) { return new Promise((res, rej) => { - ffprobe(path, (err, data) => { + ffmpeg.ffprobe(path, (err, data) => { if (err) return rej(err) return res(data) diff --git a/packages/ffmpeg/src/index.ts b/packages/ffmpeg/src/index.ts new file mode 100644 index 000000000..511409a50 --- /dev/null +++ b/packages/ffmpeg/src/index.ts @@ -0,0 +1,9 @@ +export * from './ffmpeg-command-wrapper.js' +export * from './ffmpeg-default-transcoding-profile.js' +export * from './ffmpeg-edition.js' +export * from './ffmpeg-images.js' +export * from './ffmpeg-live.js' +export * from './ffmpeg-utils.js' +export * from './ffmpeg-version.js' +export * from './ffmpeg-vod.js' +export * from './ffprobe.js' diff --git a/shared/ffmpeg/shared/encoder-options.ts b/packages/ffmpeg/src/shared/encoder-options.ts similarity index 92% rename from shared/ffmpeg/shared/encoder-options.ts rename to packages/ffmpeg/src/shared/encoder-options.ts index 9692a6b02..376a19186 100644 --- a/shared/ffmpeg/shared/encoder-options.ts +++ b/packages/ffmpeg/src/shared/encoder-options.ts @@ -1,6 +1,6 @@ import { FfmpegCommand } from 'fluent-ffmpeg' -import { EncoderOptions } from '@shared/models' -import { buildStreamSuffix } from '../ffmpeg-utils' +import { EncoderOptions } from '@peertube/peertube-models' +import { buildStreamSuffix } from '../ffmpeg-utils.js' export function addDefaultEncoderGlobalParams (command: FfmpegCommand) { // avoid issues when transcoding some files: https://trac.ffmpeg.org/ticket/6375 diff --git a/packages/ffmpeg/src/shared/index.ts b/packages/ffmpeg/src/shared/index.ts new file mode 100644 index 000000000..81e8ff0b5 --- /dev/null +++ b/packages/ffmpeg/src/shared/index.ts @@ -0,0 +1,2 @@ +export * from './encoder-options.js' +export * from './presets.js' diff --git a/shared/ffmpeg/shared/presets.ts b/packages/ffmpeg/src/shared/presets.ts similarity index 89% rename from shared/ffmpeg/shared/presets.ts rename to packages/ffmpeg/src/shared/presets.ts index dcebdc1cf..17bd7b031 100644 --- a/shared/ffmpeg/shared/presets.ts +++ b/packages/ffmpeg/src/shared/presets.ts @@ -1,8 +1,8 @@ -import { pick } from '@shared/core-utils' -import { FFmpegCommandWrapper } from '../ffmpeg-command-wrapper' -import { ffprobePromise, getVideoStreamBitrate, getVideoStreamDimensionsInfo, hasAudioStream } from '../ffprobe' -import { addDefaultEncoderGlobalParams, addDefaultEncoderParams, applyEncoderOptions } from './encoder-options' -import { getScaleFilter, StreamType } from '../ffmpeg-utils' +import { pick } from '@peertube/peertube-core-utils' +import { FFmpegCommandWrapper } from '../ffmpeg-command-wrapper.js' +import { getScaleFilter, StreamType } from '../ffmpeg-utils.js' +import { ffprobePromise, getVideoStreamBitrate, getVideoStreamDimensionsInfo, hasAudioStream } from '../ffprobe.js' +import { addDefaultEncoderGlobalParams, addDefaultEncoderParams, applyEncoderOptions } from './encoder-options.js' export async function presetVOD (options: { commandWrapper: FFmpegCommandWrapper diff --git a/packages/ffmpeg/tsconfig.json b/packages/ffmpeg/tsconfig.json new file mode 100644 index 000000000..c8aeb3c14 --- /dev/null +++ b/packages/ffmpeg/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./dist", + "rootDir": "src", + "tsBuildInfoFile": "./dist/.tsbuildinfo" + }, + "references": [ + { "path": "../models" }, + { "path": "../core-utils" } + ] +} diff --git a/packages/models/package.json b/packages/models/package.json new file mode 100644 index 000000000..58a993add --- /dev/null +++ b/packages/models/package.json @@ -0,0 +1,19 @@ +{ + "name": "@peertube/peertube-models", + "private": true, + "version": "0.0.0", + "main": "dist/index.js", + "type": "module", + "files": [ "dist" ], + "exports": { + "types": "./dist/index.d.ts", + "peertube:tsx": "./src/index.ts", + "default": "./dist/index.js" + }, + "devDependencies": {}, + "scripts": { + "build": "tsc", + "watch": "tsc -w" + }, + "dependencies": {} +} diff --git a/shared/models/activitypub/activity.ts b/packages/models/src/activitypub/activity.ts similarity index 94% rename from shared/models/activitypub/activity.ts rename to packages/models/src/activitypub/activity.ts index 10cf53ead..78a3ab33b 100644 --- a/shared/models/activitypub/activity.ts +++ b/packages/models/src/activitypub/activity.ts @@ -1,5 +1,5 @@ -import { ActivityPubActor } from './activitypub-actor' -import { ActivityPubSignature } from './activitypub-signature' +import { ActivityPubActor } from './activitypub-actor.js' +import { ActivityPubSignature } from './activitypub-signature.js' import { ActivityFlagReasonObject, ActivityObject, @@ -9,7 +9,7 @@ import { VideoCommentObject, VideoObject, WatchActionObject -} from './objects' +} from './objects/index.js' export type ActivityUpdateObject = Extract | ActivityPubActor diff --git a/shared/models/activitypub/activitypub-actor.ts b/packages/models/src/activitypub/activitypub-actor.ts similarity index 96% rename from shared/models/activitypub/activitypub-actor.ts rename to packages/models/src/activitypub/activitypub-actor.ts index b86bcb764..85b37c5ad 100644 --- a/shared/models/activitypub/activitypub-actor.ts +++ b/packages/models/src/activitypub/activitypub-actor.ts @@ -1,4 +1,4 @@ -import { ActivityIconObject, ActivityPubAttributedTo } from './objects/common-objects' +import { ActivityIconObject, ActivityPubAttributedTo } from './objects/common-objects.js' export type ActivityPubActorType = 'Person' | 'Application' | 'Group' | 'Service' | 'Organization' diff --git a/shared/models/activitypub/activitypub-collection.ts b/packages/models/src/activitypub/activitypub-collection.ts similarity index 80% rename from shared/models/activitypub/activitypub-collection.ts rename to packages/models/src/activitypub/activitypub-collection.ts index 60a6a6b04..b98ad37c2 100644 --- a/shared/models/activitypub/activitypub-collection.ts +++ b/packages/models/src/activitypub/activitypub-collection.ts @@ -1,4 +1,4 @@ -import { Activity } from './activity' +import { Activity } from './activity.js' export interface ActivityPubCollection { '@context': string[] diff --git a/shared/models/activitypub/activitypub-ordered-collection.ts b/packages/models/src/activitypub/activitypub-ordered-collection.ts similarity index 100% rename from shared/models/activitypub/activitypub-ordered-collection.ts rename to packages/models/src/activitypub/activitypub-ordered-collection.ts diff --git a/shared/models/activitypub/activitypub-root.ts b/packages/models/src/activitypub/activitypub-root.ts similarity index 56% rename from shared/models/activitypub/activitypub-root.ts rename to packages/models/src/activitypub/activitypub-root.ts index 22dff83a2..2fa1970c7 100644 --- a/shared/models/activitypub/activitypub-root.ts +++ b/packages/models/src/activitypub/activitypub-root.ts @@ -1,5 +1,5 @@ -import { Activity } from './activity' -import { ActivityPubCollection } from './activitypub-collection' -import { ActivityPubOrderedCollection } from './activitypub-ordered-collection' +import { Activity } from './activity.js' +import { ActivityPubCollection } from './activitypub-collection.js' +import { ActivityPubOrderedCollection } from './activitypub-ordered-collection.js' export type RootActivity = Activity | ActivityPubCollection | ActivityPubOrderedCollection diff --git a/shared/models/activitypub/activitypub-signature.ts b/packages/models/src/activitypub/activitypub-signature.ts similarity index 100% rename from shared/models/activitypub/activitypub-signature.ts rename to packages/models/src/activitypub/activitypub-signature.ts diff --git a/shared/models/activitypub/context.ts b/packages/models/src/activitypub/context.ts similarity index 100% rename from shared/models/activitypub/context.ts rename to packages/models/src/activitypub/context.ts diff --git a/packages/models/src/activitypub/index.ts b/packages/models/src/activitypub/index.ts new file mode 100644 index 000000000..f36aa1bc5 --- /dev/null +++ b/packages/models/src/activitypub/index.ts @@ -0,0 +1,9 @@ +export * from './objects/index.js' +export * from './activity.js' +export * from './activitypub-actor.js' +export * from './activitypub-collection.js' +export * from './activitypub-ordered-collection.js' +export * from './activitypub-root.js' +export * from './activitypub-signature.js' +export * from './context.js' +export * from './webfinger.js' diff --git a/shared/models/activitypub/objects/abuse-object.ts b/packages/models/src/activitypub/objects/abuse-object.ts similarity index 75% rename from shared/models/activitypub/objects/abuse-object.ts rename to packages/models/src/activitypub/objects/abuse-object.ts index d938b8693..2c0f2832b 100644 --- a/shared/models/activitypub/objects/abuse-object.ts +++ b/packages/models/src/activitypub/objects/abuse-object.ts @@ -1,4 +1,4 @@ -import { ActivityFlagReasonObject } from './common-objects' +import { ActivityFlagReasonObject } from './common-objects.js' export interface AbuseObject { type: 'Flag' diff --git a/packages/models/src/activitypub/objects/activitypub-object.ts b/packages/models/src/activitypub/objects/activitypub-object.ts new file mode 100644 index 000000000..93c925ae0 --- /dev/null +++ b/packages/models/src/activitypub/objects/activitypub-object.ts @@ -0,0 +1,17 @@ +import { AbuseObject } from './abuse-object.js' +import { CacheFileObject } from './cache-file-object.js' +import { PlaylistObject } from './playlist-object.js' +import { VideoCommentObject } from './video-comment-object.js' +import { VideoObject } from './video-object.js' +import { WatchActionObject } from './watch-action-object.js' + +export type ActivityObject = + VideoObject | + AbuseObject | + VideoCommentObject | + CacheFileObject | + PlaylistObject | + WatchActionObject | + string + +export type APObjectId = string | { id: string } diff --git a/shared/models/activitypub/objects/cache-file-object.ts b/packages/models/src/activitypub/objects/cache-file-object.ts similarity index 90% rename from shared/models/activitypub/objects/cache-file-object.ts rename to packages/models/src/activitypub/objects/cache-file-object.ts index 19a817582..a40ef339c 100644 --- a/shared/models/activitypub/objects/cache-file-object.ts +++ b/packages/models/src/activitypub/objects/cache-file-object.ts @@ -1,4 +1,4 @@ -import { ActivityVideoUrlObject, ActivityPlaylistUrlObject } from './common-objects' +import { ActivityVideoUrlObject, ActivityPlaylistUrlObject } from './common-objects.js' export interface CacheFileObject { id: string diff --git a/shared/models/activitypub/objects/common-objects.ts b/packages/models/src/activitypub/objects/common-objects.ts similarity index 98% rename from shared/models/activitypub/objects/common-objects.ts rename to packages/models/src/activitypub/objects/common-objects.ts index db9c73658..a332c26f3 100644 --- a/shared/models/activitypub/objects/common-objects.ts +++ b/packages/models/src/activitypub/objects/common-objects.ts @@ -1,4 +1,4 @@ -import { AbusePredefinedReasonsString } from '../../moderation/abuse/abuse-reason.model' +import { AbusePredefinedReasonsString } from '../../moderation/abuse/abuse-reason.model.js' export interface ActivityIdentifierObject { identifier: string diff --git a/packages/models/src/activitypub/objects/index.ts b/packages/models/src/activitypub/objects/index.ts new file mode 100644 index 000000000..510f621ea --- /dev/null +++ b/packages/models/src/activitypub/objects/index.ts @@ -0,0 +1,9 @@ +export * from './abuse-object.js' +export * from './activitypub-object.js' +export * from './cache-file-object.js' +export * from './common-objects.js' +export * from './playlist-element-object.js' +export * from './playlist-object.js' +export * from './video-comment-object.js' +export * from './video-object.js' +export * from './watch-action-object.js' diff --git a/shared/models/activitypub/objects/playlist-element-object.ts b/packages/models/src/activitypub/objects/playlist-element-object.ts similarity index 100% rename from shared/models/activitypub/objects/playlist-element-object.ts rename to packages/models/src/activitypub/objects/playlist-element-object.ts diff --git a/shared/models/activitypub/objects/playlist-object.ts b/packages/models/src/activitypub/objects/playlist-object.ts similarity index 96% rename from shared/models/activitypub/objects/playlist-object.ts rename to packages/models/src/activitypub/objects/playlist-object.ts index 0ccb71828..c68a28780 100644 --- a/shared/models/activitypub/objects/playlist-object.ts +++ b/packages/models/src/activitypub/objects/playlist-object.ts @@ -1,4 +1,4 @@ -import { ActivityIconObject, ActivityPubAttributedTo } from './common-objects' +import { ActivityIconObject, ActivityPubAttributedTo } from './common-objects.js' export interface PlaylistObject { id: string diff --git a/shared/models/activitypub/objects/video-comment-object.ts b/packages/models/src/activitypub/objects/video-comment-object.ts similarity index 94% rename from shared/models/activitypub/objects/video-comment-object.ts rename to packages/models/src/activitypub/objects/video-comment-object.ts index fb1e6f8db..880dd2ee2 100644 --- a/shared/models/activitypub/objects/video-comment-object.ts +++ b/packages/models/src/activitypub/objects/video-comment-object.ts @@ -1,4 +1,4 @@ -import { ActivityPubAttributedTo, ActivityTagObject } from './common-objects' +import { ActivityPubAttributedTo, ActivityTagObject } from './common-objects.js' export interface VideoCommentObject { type: 'Note' diff --git a/shared/models/activitypub/objects/video-object.ts b/packages/models/src/activitypub/objects/video-object.ts similarity index 87% rename from shared/models/activitypub/objects/video-object.ts rename to packages/models/src/activitypub/objects/video-object.ts index 409504f0f..14afd85a2 100644 --- a/shared/models/activitypub/objects/video-object.ts +++ b/packages/models/src/activitypub/objects/video-object.ts @@ -1,11 +1,11 @@ +import { LiveVideoLatencyModeType, VideoStateType } from '../../videos/index.js' import { ActivityIconObject, ActivityIdentifierObject, ActivityPubAttributedTo, ActivityTagObject, ActivityUrlObject -} from './common-objects' -import { LiveVideoLatencyMode, VideoState } from '../../videos' +} from './common-objects.js' export interface VideoObject { type: 'Video' @@ -25,12 +25,12 @@ export interface VideoObject { isLiveBroadcast: boolean liveSaveReplay: boolean permanentLive: boolean - latencyMode: LiveVideoLatencyMode + latencyMode: LiveVideoLatencyModeType commentsEnabled: boolean downloadEnabled: boolean waitTranscoding: boolean - state: VideoState + state: VideoStateType published: string originallyPublishedAt: string diff --git a/shared/models/activitypub/objects/watch-action-object.ts b/packages/models/src/activitypub/objects/watch-action-object.ts similarity index 100% rename from shared/models/activitypub/objects/watch-action-object.ts rename to packages/models/src/activitypub/objects/watch-action-object.ts diff --git a/shared/models/activitypub/webfinger.ts b/packages/models/src/activitypub/webfinger.ts similarity index 100% rename from shared/models/activitypub/webfinger.ts rename to packages/models/src/activitypub/webfinger.ts diff --git a/shared/models/actors/account.model.ts b/packages/models/src/actors/account.model.ts similarity index 76% rename from shared/models/actors/account.model.ts rename to packages/models/src/actors/account.model.ts index 9fbec60ba..370a273cf 100644 --- a/shared/models/actors/account.model.ts +++ b/packages/models/src/actors/account.model.ts @@ -1,5 +1,5 @@ -import { ActorImage } from './actor-image.model' -import { Actor } from './actor.model' +import { ActorImage } from './actor-image.model.js' +import { Actor } from './actor.model.js' export interface Account extends Actor { displayName: string diff --git a/shared/models/actors/actor-image.model.ts b/packages/models/src/actors/actor-image.model.ts similarity index 100% rename from shared/models/actors/actor-image.model.ts rename to packages/models/src/actors/actor-image.model.ts diff --git a/packages/models/src/actors/actor-image.type.ts b/packages/models/src/actors/actor-image.type.ts new file mode 100644 index 000000000..3a808b110 --- /dev/null +++ b/packages/models/src/actors/actor-image.type.ts @@ -0,0 +1,6 @@ +export const ActorImageType = { + AVATAR: 1, + BANNER: 2 +} as const + +export type ActorImageType_Type = typeof ActorImageType[keyof typeof ActorImageType] diff --git a/shared/models/actors/actor.model.ts b/packages/models/src/actors/actor.model.ts similarity index 78% rename from shared/models/actors/actor.model.ts rename to packages/models/src/actors/actor.model.ts index ab0760263..d18053b4b 100644 --- a/shared/models/actors/actor.model.ts +++ b/packages/models/src/actors/actor.model.ts @@ -1,4 +1,4 @@ -import { ActorImage } from './actor-image.model' +import { ActorImage } from './actor-image.model.js' export interface Actor { id: number diff --git a/shared/models/actors/custom-page.model.ts b/packages/models/src/actors/custom-page.model.ts similarity index 100% rename from shared/models/actors/custom-page.model.ts rename to packages/models/src/actors/custom-page.model.ts diff --git a/shared/models/actors/follow.model.ts b/packages/models/src/actors/follow.model.ts similarity index 87% rename from shared/models/actors/follow.model.ts rename to packages/models/src/actors/follow.model.ts index 244d6d97e..7f3f52ac5 100644 --- a/shared/models/actors/follow.model.ts +++ b/packages/models/src/actors/follow.model.ts @@ -1,4 +1,4 @@ -import { Actor } from './actor.model' +import { Actor } from './actor.model.js' export type FollowState = 'pending' | 'accepted' | 'rejected' diff --git a/packages/models/src/actors/index.ts b/packages/models/src/actors/index.ts new file mode 100644 index 000000000..c44063c81 --- /dev/null +++ b/packages/models/src/actors/index.ts @@ -0,0 +1,6 @@ +export * from './account.model.js' +export * from './actor-image.model.js' +export * from './actor-image.type.js' +export * from './actor.model.js' +export * from './custom-page.model.js' +export * from './follow.model.js' diff --git a/shared/models/bulk/bulk-remove-comments-of-body.model.ts b/packages/models/src/bulk/bulk-remove-comments-of-body.model.ts similarity index 100% rename from shared/models/bulk/bulk-remove-comments-of-body.model.ts rename to packages/models/src/bulk/bulk-remove-comments-of-body.model.ts diff --git a/packages/models/src/bulk/index.ts b/packages/models/src/bulk/index.ts new file mode 100644 index 000000000..3597fda36 --- /dev/null +++ b/packages/models/src/bulk/index.ts @@ -0,0 +1 @@ +export * from './bulk-remove-comments-of-body.model.js' diff --git a/packages/models/src/common/index.ts b/packages/models/src/common/index.ts new file mode 100644 index 000000000..957851ae4 --- /dev/null +++ b/packages/models/src/common/index.ts @@ -0,0 +1 @@ +export * from './result-list.model.js' diff --git a/shared/models/common/result-list.model.ts b/packages/models/src/common/result-list.model.ts similarity index 100% rename from shared/models/common/result-list.model.ts rename to packages/models/src/common/result-list.model.ts diff --git a/shared/models/custom-markup/custom-markup-data.model.ts b/packages/models/src/custom-markup/custom-markup-data.model.ts similarity index 100% rename from shared/models/custom-markup/custom-markup-data.model.ts rename to packages/models/src/custom-markup/custom-markup-data.model.ts diff --git a/packages/models/src/custom-markup/index.ts b/packages/models/src/custom-markup/index.ts new file mode 100644 index 000000000..1ce10d8e2 --- /dev/null +++ b/packages/models/src/custom-markup/index.ts @@ -0,0 +1 @@ +export * from './custom-markup-data.model.js' diff --git a/packages/models/src/feeds/feed-format.enum.ts b/packages/models/src/feeds/feed-format.enum.ts new file mode 100644 index 000000000..71f2f6c15 --- /dev/null +++ b/packages/models/src/feeds/feed-format.enum.ts @@ -0,0 +1,7 @@ +export const FeedFormat = { + RSS: 'xml', + ATOM: 'atom', + JSON: 'json' +} as const + +export type FeedFormatType = typeof FeedFormat[keyof typeof FeedFormat] diff --git a/packages/models/src/feeds/index.ts b/packages/models/src/feeds/index.ts new file mode 100644 index 000000000..1eda1d6c3 --- /dev/null +++ b/packages/models/src/feeds/index.ts @@ -0,0 +1 @@ +export * from './feed-format.enum.js' diff --git a/shared/models/http/http-methods.ts b/packages/models/src/http/http-methods.ts similarity index 77% rename from shared/models/http/http-methods.ts rename to packages/models/src/http/http-methods.ts index 3f4adafe2..ec3c855d8 100644 --- a/shared/models/http/http-methods.ts +++ b/packages/models/src/http/http-methods.ts @@ -1,21 +1,23 @@ /** HTTP request method to indicate the desired action to be performed for a given resource. */ -export const enum HttpMethod { +export const HttpMethod = { /** The CONNECT method establishes a tunnel to the server identified by the target resource. */ - CONNECT = 'CONNECT', + CONNECT: 'CONNECT', /** The DELETE method deletes the specified resource. */ - DELETE = 'DELETE', + DELETE: 'DELETE', /** The GET method requests a representation of the specified resource. Requests using GET should only retrieve data. */ - GET = 'GET', + GET: 'GET', /** The HEAD method asks for a response identical to that of a GET request, but without the response body. */ - HEAD = 'HEAD', + HEAD: 'HEAD', /** The OPTIONS method is used to describe the communication options for the target resource. */ - OPTIONS = 'OPTIONS', + OPTIONS: 'OPTIONS', /** The PATCH method is used to apply partial modifications to a resource. */ - PATCH = 'PATCH', + PATCH: 'PATCH', /** The POST method is used to submit an entity to the specified resource */ - POST = 'POST', + POST: 'POST', /** The PUT method replaces all current representations of the target resource with the request payload. */ - PUT = 'PUT', + PUT: 'PUT', /** The TRACE method performs a message loop-back test along the path to the target resource. */ - TRACE = 'TRACE' -} + TRACE: 'TRACE' +} as const + +export type HttpMethodType = typeof HttpMethod[keyof typeof HttpMethod] diff --git a/shared/models/http/http-error-codes.ts b/packages/models/src/http/http-status-codes.ts similarity index 91% rename from shared/models/http/http-error-codes.ts rename to packages/models/src/http/http-status-codes.ts index 5ebff1cb5..920b9a2e9 100644 --- a/shared/models/http/http-error-codes.ts +++ b/packages/models/src/http/http-status-codes.ts @@ -4,7 +4,7 @@ * * WebDAV and other codes useless with regards to PeerTube are not listed. */ -export const enum HttpStatusCode { +export const HttpStatusCode = { /** * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.2.1 @@ -16,14 +16,14 @@ export const enum HttpStatusCode { * and receive a 100 Continue status code in response before sending the body. The response 417 Expectation Failed indicates * the request should not be continued. */ - CONTINUE_100 = 100, + CONTINUE_100: 100, /** * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.2.2 * * This code is sent in response to an Upgrade request header by the client, and indicates the protocol the server is switching too. */ - SWITCHING_PROTOCOLS_101 = 101, + SWITCHING_PROTOCOLS_101: 101, /** * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.3.1 @@ -34,20 +34,20 @@ export const enum HttpStatusCode { * POST: The resource describing the result of the action is transmitted in the message body. * TRACE: The message body contains the request message as received by the server */ - OK_200 = 200, + OK_200: 200, /** * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.3.2 * * The request has been fulfilled, resulting in the creation of a new resource, typically after a PUT. */ - CREATED_201 = 201, + CREATED_201: 201, /** * The request has been accepted for processing, but the processing has not been completed. * The request might or might not be eventually acted upon, and may be disallowed when processing occurs. */ - ACCEPTED_202 = 202, + ACCEPTED_202: 202, /** * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.3.5 @@ -55,32 +55,32 @@ export const enum HttpStatusCode { * There is no content to send for this request, but the headers may be useful. * The user-agent may update its cached headers for this resource with the new ones. */ - NO_CONTENT_204 = 204, + NO_CONTENT_204: 204, /** * The server successfully processed the request, but is not returning any content. * Unlike a 204 response, this response requires that the requester reset the document view. */ - RESET_CONTENT_205 = 205, + RESET_CONTENT_205: 205, /** * The server is delivering only part of the resource (byte serving) due to a range header sent by the client. * The range header is used by HTTP clients to enable resuming of interrupted downloads, * or split a download into multiple simultaneous streams. */ - PARTIAL_CONTENT_206 = 206, + PARTIAL_CONTENT_206: 206, /** * Indicates multiple options for the resource from which the client may choose (via agent-driven content negotiation). * For example, this code could be used to present multiple video format options, * to list files with different filename extensions, or to suggest word-sense disambiguation. */ - MULTIPLE_CHOICES_300 = 300, + MULTIPLE_CHOICES_300: 300, /** * This and all future requests should be directed to the given URI. */ - MOVED_PERMANENTLY_301 = 301, + MOVED_PERMANENTLY_301: 301, /** * This is an example of industry practice contradicting the standard. @@ -90,7 +90,7 @@ export const enum HttpStatusCode { * to distinguish between the two behaviours. However, some Web applications and frameworks * use the 302 status code as if it were the 303. */ - FOUND_302 = 302, + FOUND_302: 302, /** * SINCE HTTP/1.1 @@ -98,7 +98,7 @@ export const enum HttpStatusCode { * When received in response to a POST (or PUT/DELETE), the client should presume that * the server has received the data and should issue a redirect with a separate GET message. */ - SEE_OTHER_303 = 303, + SEE_OTHER_303: 303, /** * Official Documentation @ https://tools.ietf.org/html/rfc7232#section-4.1 @@ -107,7 +107,7 @@ export const enum HttpStatusCode { * `If-Modified-Since` or `If-None-Match`. * In such case, there is no need to retransmit the resource since the client still has a previously-downloaded copy. */ - NOT_MODIFIED_304 = 304, + NOT_MODIFIED_304: 304, /** * SINCE HTTP/1.1 @@ -116,20 +116,20 @@ export const enum HttpStatusCode { * original request. * For example, a POST request should be repeated using another POST request. */ - TEMPORARY_REDIRECT_307 = 307, + TEMPORARY_REDIRECT_307: 307, /** * The request and all future requests should be repeated using another URI. * 307 and 308 parallel the behaviors of 302 and 301, but do not allow the HTTP method to change. * So, for example, submitting a form to a permanently redirected resource may continue smoothly. */ - PERMANENT_REDIRECT_308 = 308, + PERMANENT_REDIRECT_308: 308, /** * The server cannot or will not process the request due to an apparent client error * (e.g., malformed request syntax, too large size, invalid request message framing, or deceptive request routing). */ - BAD_REQUEST_400 = 400, + BAD_REQUEST_400: 400, /** * Official Documentation @ https://tools.ietf.org/html/rfc7235#section-3.1 @@ -139,7 +139,7 @@ export const enum HttpStatusCode { * requested resource. See Basic access authentication and Digest access authentication. 401 semantically means * "unauthenticated",i.e. the user does not have the necessary credentials. */ - UNAUTHORIZED_401 = 401, + UNAUTHORIZED_401: 401, /** * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.2 @@ -148,7 +148,7 @@ export const enum HttpStatusCode { * cash or micro payment scheme, but that has not happened, and this code is not usually used. * Google Developers API uses this status if a particular developer has exceeded the daily limit on requests. */ - PAYMENT_REQUIRED_402 = 402, + PAYMENT_REQUIRED_402: 402, /** * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.3 @@ -156,7 +156,7 @@ export const enum HttpStatusCode { * The client does not have access rights to the content, i.e. they are unauthorized, so server is rejecting to * give proper response. Unlike 401, the client's identity is known to the server. */ - FORBIDDEN_403 = 403, + FORBIDDEN_403: 403, /** * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.6.2 @@ -164,7 +164,7 @@ export const enum HttpStatusCode { * The requested resource could not be found but may be available in the future. * Subsequent requests by the client are permissible. */ - NOT_FOUND_404 = 404, + NOT_FOUND_404: 404, /** * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.5 @@ -172,12 +172,12 @@ export const enum HttpStatusCode { * A request method is not supported for the requested resource; * for example, a GET request on a form that requires data to be presented via POST, or a PUT request on a read-only resource. */ - METHOD_NOT_ALLOWED_405 = 405, + METHOD_NOT_ALLOWED_405: 405, /** * The requested resource is capable of generating only content not acceptable according to the Accept headers sent in the request. */ - NOT_ACCEPTABLE_406 = 406, + NOT_ACCEPTABLE_406: 406, /** * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.7 @@ -189,7 +189,7 @@ export const enum HttpStatusCode { * * @ */ - REQUEST_TIMEOUT_408 = 408, + REQUEST_TIMEOUT_408: 408, /** * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.8 @@ -199,7 +199,7 @@ export const enum HttpStatusCode { * * @see HttpStatusCode.UNPROCESSABLE_ENTITY_422 to denote a disabled feature */ - CONFLICT_409 = 409, + CONFLICT_409: 409, /** * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.9 @@ -210,17 +210,17 @@ export const enum HttpStatusCode { * Clients such as search engines should remove the resource from their indices. * Most use cases do not require clients and search engines to purge the resource, and a "404 Not Found" may be used instead. */ - GONE_410 = 410, + GONE_410: 410, /** * The request did not specify the length of its content, which is required by the requested resource. */ - LENGTH_REQUIRED_411 = 411, + LENGTH_REQUIRED_411: 411, /** * The server does not meet one of the preconditions that the requester put on the request. */ - PRECONDITION_FAILED_412 = 412, + PRECONDITION_FAILED_412: 412, /** * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.11 @@ -229,14 +229,14 @@ export const enum HttpStatusCode { * or return an Retry-After header field. * Previously called "Request Entity Too Large". */ - PAYLOAD_TOO_LARGE_413 = 413, + PAYLOAD_TOO_LARGE_413: 413, /** * The URI provided was too long for the server to process. Often the result of too much data being encoded as a * query-string of a GET request, in which case it should be converted to a POST request. * Called "Request-URI Too Long" previously. */ - URI_TOO_LONG_414 = 414, + URI_TOO_LONG_414: 414, /** * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.13 @@ -244,19 +244,19 @@ export const enum HttpStatusCode { * The request entity has a media type which the server or resource does not support. * For example, the client uploads an image as image/svg+xml, but the server requires that images use a different format. */ - UNSUPPORTED_MEDIA_TYPE_415 = 415, + UNSUPPORTED_MEDIA_TYPE_415: 415, /** * The client has asked for a portion of the file (byte serving), but the server cannot supply that portion. * For example, if the client asked for a part of the file that lies beyond the end of the file. * Called "Requested Range Not Satisfiable" previously. */ - RANGE_NOT_SATISFIABLE_416 = 416, + RANGE_NOT_SATISFIABLE_416: 416, /** * The server cannot meet the requirements of the `Expect` request-header field. */ - EXPECTATION_FAILED_417 = 417, + EXPECTATION_FAILED_417: 417, /** * Official Documentation @ https://tools.ietf.org/html/rfc2324 @@ -265,7 +265,7 @@ export const enum HttpStatusCode { * and is not expected to be implemented by actual HTTP servers. The RFC specifies this code should be returned by * teapots requested to brew coffee. This HTTP status is used as an Easter egg in some websites, including PeerTube instances ;-). */ - I_AM_A_TEAPOT_418 = 418, + I_AM_A_TEAPOT_418: 418, /** * Official Documentation @ https://tools.ietf.org/html/rfc2518#section-10.3 @@ -281,7 +281,7 @@ export const enum HttpStatusCode { * @see HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415 if the `Content-Type` was not supported. * @see HttpStatusCode.BAD_REQUEST_400 if the request was not parsable (broken JSON, XML) */ - UNPROCESSABLE_ENTITY_422 = 422, + UNPROCESSABLE_ENTITY_422: 422, /** * Official Documentation @ https://tools.ietf.org/html/rfc4918#section-11.3 @@ -291,14 +291,14 @@ export const enum HttpStatusCode { * @deprecated use `If-Match` / `If-None-Match` instead * @see {@link https://evertpot.com/http/423-locked} */ - LOCKED_423 = 423, + LOCKED_423: 423, /** * Official Documentation @ https://tools.ietf.org/html/rfc6585#section-4 * * The user has sent too many requests in a given amount of time. Intended for use with rate-limiting schemes. */ - TOO_MANY_REQUESTS_429 = 429, + TOO_MANY_REQUESTS_429: 429, /** * Official Documentation @ https://tools.ietf.org/html/rfc6585#section-5 @@ -306,7 +306,7 @@ export const enum HttpStatusCode { * The server is unwilling to process the request because either an individual header field, * or all the header fields collectively, are too large. */ - REQUEST_HEADER_FIELDS_TOO_LARGE_431 = 431, + REQUEST_HEADER_FIELDS_TOO_LARGE_431: 431, /** * Official Documentation @ https://tools.ietf.org/html/rfc7725 @@ -314,12 +314,12 @@ export const enum HttpStatusCode { * A server operator has received a legal demand to deny access to a resource or to a set of resources * that includes the requested resource. The code 451 was chosen as a reference to the novel Fahrenheit 451. */ - UNAVAILABLE_FOR_LEGAL_REASONS_451 = 451, + UNAVAILABLE_FOR_LEGAL_REASONS_451: 451, /** * A generic error message, given when an unexpected condition was encountered and no more specific message is suitable. */ - INTERNAL_SERVER_ERROR_500 = 500, + INTERNAL_SERVER_ERROR_500: 500, /** * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.6.2 @@ -327,28 +327,28 @@ export const enum HttpStatusCode { * The server either does not recognize the request method, or it lacks the ability to fulfill the request. * Usually this implies future availability (e.g., a new feature of a web-service API). */ - NOT_IMPLEMENTED_501 = 501, + NOT_IMPLEMENTED_501: 501, /** * The server was acting as a gateway or proxy and received an invalid response from the upstream server. */ - BAD_GATEWAY_502 = 502, + BAD_GATEWAY_502: 502, /** * The server is currently unavailable (because it is overloaded or down for maintenance). * Generally, this is a temporary state. */ - SERVICE_UNAVAILABLE_503 = 503, + SERVICE_UNAVAILABLE_503: 503, /** * The server was acting as a gateway or proxy and did not receive a timely response from the upstream server. */ - GATEWAY_TIMEOUT_504 = 504, + GATEWAY_TIMEOUT_504: 504, /** * The server does not support the HTTP protocol version used in the request */ - HTTP_VERSION_NOT_SUPPORTED_505 = 505, + HTTP_VERSION_NOT_SUPPORTED_505: 505, /** * Official Documentation @ https://tools.ietf.org/html/rfc2518#section-10.6 @@ -360,5 +360,7 @@ export const enum HttpStatusCode { * * @see HttpStatusCode.PAYLOAD_TOO_LARGE_413 for quota errors */ - INSUFFICIENT_STORAGE_507 = 507, -} + INSUFFICIENT_STORAGE_507: 507 +} as const + +export type HttpStatusCodeType = typeof HttpStatusCode[keyof typeof HttpStatusCode] diff --git a/packages/models/src/http/index.ts b/packages/models/src/http/index.ts new file mode 100644 index 000000000..f0ad040ed --- /dev/null +++ b/packages/models/src/http/index.ts @@ -0,0 +1,2 @@ +export * from './http-status-codes.js' +export * from './http-methods.js' diff --git a/packages/models/src/index.ts b/packages/models/src/index.ts new file mode 100644 index 000000000..b76703dff --- /dev/null +++ b/packages/models/src/index.ts @@ -0,0 +1,20 @@ +export * from './activitypub/index.js' +export * from './actors/index.js' +export * from './bulk/index.js' +export * from './common/index.js' +export * from './custom-markup/index.js' +export * from './feeds/index.js' +export * from './http/index.js' +export * from './joinpeertube/index.js' +export * from './metrics/index.js' +export * from './moderation/index.js' +export * from './nodeinfo/index.js' +export * from './overviews/index.js' +export * from './plugins/index.js' +export * from './redundancy/index.js' +export * from './runners/index.js' +export * from './search/index.js' +export * from './server/index.js' +export * from './tokens/index.js' +export * from './users/index.js' +export * from './videos/index.js' diff --git a/packages/models/src/joinpeertube/index.ts b/packages/models/src/joinpeertube/index.ts new file mode 100644 index 000000000..a51d34190 --- /dev/null +++ b/packages/models/src/joinpeertube/index.ts @@ -0,0 +1 @@ +export * from './versions.model.js' diff --git a/shared/models/joinpeertube/versions.model.ts b/packages/models/src/joinpeertube/versions.model.ts similarity index 100% rename from shared/models/joinpeertube/versions.model.ts rename to packages/models/src/joinpeertube/versions.model.ts diff --git a/packages/models/src/metrics/index.ts b/packages/models/src/metrics/index.ts new file mode 100644 index 000000000..def6f8095 --- /dev/null +++ b/packages/models/src/metrics/index.ts @@ -0,0 +1 @@ +export * from './playback-metric-create.model.js' diff --git a/shared/models/metrics/playback-metric-create.model.ts b/packages/models/src/metrics/playback-metric-create.model.ts similarity index 81% rename from shared/models/metrics/playback-metric-create.model.ts rename to packages/models/src/metrics/playback-metric-create.model.ts index 1d47421c3..3ae91b295 100644 --- a/shared/models/metrics/playback-metric-create.model.ts +++ b/packages/models/src/metrics/playback-metric-create.model.ts @@ -1,9 +1,9 @@ -import { VideoResolution } from '../videos' +import { VideoResolutionType } from '../videos/index.js' export interface PlaybackMetricCreate { playerMode: 'p2p-media-loader' | 'webtorrent' | 'web-video' // FIXME: remove webtorrent player mode not used anymore in PeerTube v6 - resolution?: VideoResolution + resolution?: VideoResolutionType fps?: number p2pEnabled: boolean diff --git a/shared/models/moderation/abuse/abuse-create.model.ts b/packages/models/src/moderation/abuse/abuse-create.model.ts similarity index 97% rename from shared/models/moderation/abuse/abuse-create.model.ts rename to packages/models/src/moderation/abuse/abuse-create.model.ts index 7d35555c3..1c2723b1c 100644 --- a/shared/models/moderation/abuse/abuse-create.model.ts +++ b/packages/models/src/moderation/abuse/abuse-create.model.ts @@ -1,4 +1,4 @@ -import { AbusePredefinedReasonsString } from './abuse-reason.model' +import { AbusePredefinedReasonsString } from './abuse-reason.model.js' export interface AbuseCreate { reason: string diff --git a/shared/models/moderation/abuse/abuse-filter.type.ts b/packages/models/src/moderation/abuse/abuse-filter.type.ts similarity index 100% rename from shared/models/moderation/abuse/abuse-filter.type.ts rename to packages/models/src/moderation/abuse/abuse-filter.type.ts diff --git a/shared/models/moderation/abuse/abuse-message.model.ts b/packages/models/src/moderation/abuse/abuse-message.model.ts similarity index 69% rename from shared/models/moderation/abuse/abuse-message.model.ts rename to packages/models/src/moderation/abuse/abuse-message.model.ts index 9edd9daff..9ba95e724 100644 --- a/shared/models/moderation/abuse/abuse-message.model.ts +++ b/packages/models/src/moderation/abuse/abuse-message.model.ts @@ -1,4 +1,4 @@ -import { AccountSummary } from '../../actors/account.model' +import { AccountSummary } from '../../actors/account.model.js' export interface AbuseMessage { id: number diff --git a/packages/models/src/moderation/abuse/abuse-reason.model.ts b/packages/models/src/moderation/abuse/abuse-reason.model.ts new file mode 100644 index 000000000..770b9d47a --- /dev/null +++ b/packages/models/src/moderation/abuse/abuse-reason.model.ts @@ -0,0 +1,22 @@ +export const AbusePredefinedReasons = { + VIOLENT_OR_REPULSIVE: 1, + HATEFUL_OR_ABUSIVE: 2, + SPAM_OR_MISLEADING: 3, + PRIVACY: 4, + RIGHTS: 5, + SERVER_RULES: 6, + THUMBNAILS: 7, + CAPTIONS: 8 +} as const + +export type AbusePredefinedReasonsType = typeof AbusePredefinedReasons[keyof typeof AbusePredefinedReasons] + +export type AbusePredefinedReasonsString = + 'violentOrRepulsive' | + 'hatefulOrAbusive' | + 'spamOrMisleading' | + 'privacy' | + 'rights' | + 'serverRules' | + 'thumbnails' | + 'captions' diff --git a/packages/models/src/moderation/abuse/abuse-state.model.ts b/packages/models/src/moderation/abuse/abuse-state.model.ts new file mode 100644 index 000000000..5582d73c4 --- /dev/null +++ b/packages/models/src/moderation/abuse/abuse-state.model.ts @@ -0,0 +1,7 @@ +export const AbuseState = { + PENDING: 1, + REJECTED: 2, + ACCEPTED: 3 +} as const + +export type AbuseStateType = typeof AbuseState[keyof typeof AbuseState] diff --git a/packages/models/src/moderation/abuse/abuse-update.model.ts b/packages/models/src/moderation/abuse/abuse-update.model.ts new file mode 100644 index 000000000..22a01be89 --- /dev/null +++ b/packages/models/src/moderation/abuse/abuse-update.model.ts @@ -0,0 +1,7 @@ +import { AbuseStateType } from './abuse-state.model.js' + +export interface AbuseUpdate { + moderationComment?: string + + state?: AbuseStateType +} diff --git a/shared/models/moderation/abuse/abuse-video-is.type.ts b/packages/models/src/moderation/abuse/abuse-video-is.type.ts similarity index 100% rename from shared/models/moderation/abuse/abuse-video-is.type.ts rename to packages/models/src/moderation/abuse/abuse-video-is.type.ts diff --git a/shared/models/moderation/abuse/abuse.model.ts b/packages/models/src/moderation/abuse/abuse.model.ts similarity index 88% rename from shared/models/moderation/abuse/abuse.model.ts rename to packages/models/src/moderation/abuse/abuse.model.ts index 6048777ff..253a3f44c 100644 --- a/shared/models/moderation/abuse/abuse.model.ts +++ b/packages/models/src/moderation/abuse/abuse.model.ts @@ -1,8 +1,8 @@ -import { Account } from '../../actors/account.model' -import { AbuseState } from './abuse-state.model' -import { AbusePredefinedReasonsString } from './abuse-reason.model' -import { VideoConstant } from '../../videos/video-constant.model' -import { VideoChannel } from '../../videos/channel/video-channel.model' +import { Account } from '../../actors/account.model.js' +import { AbuseStateType } from './abuse-state.model.js' +import { AbusePredefinedReasonsString } from './abuse-reason.model.js' +import { VideoConstant } from '../../videos/video-constant.model.js' +import { VideoChannel } from '../../videos/channel/video-channel.model.js' export interface AdminVideoAbuse { id: number @@ -47,7 +47,7 @@ export interface AdminAbuse { reporterAccount: Account flaggedAccount: Account - state: VideoConstant + state: VideoConstant moderationComment?: string video?: AdminVideoAbuse diff --git a/packages/models/src/moderation/abuse/index.ts b/packages/models/src/moderation/abuse/index.ts new file mode 100644 index 000000000..27fca7076 --- /dev/null +++ b/packages/models/src/moderation/abuse/index.ts @@ -0,0 +1,8 @@ +export * from './abuse-create.model.js' +export * from './abuse-filter.type.js' +export * from './abuse-message.model.js' +export * from './abuse-reason.model.js' +export * from './abuse-state.model.js' +export * from './abuse-update.model.js' +export * from './abuse-video-is.type.js' +export * from './abuse.model.js' diff --git a/shared/models/moderation/account-block.model.ts b/packages/models/src/moderation/account-block.model.ts similarity index 70% rename from shared/models/moderation/account-block.model.ts rename to packages/models/src/moderation/account-block.model.ts index a942ed614..2d070da62 100644 --- a/shared/models/moderation/account-block.model.ts +++ b/packages/models/src/moderation/account-block.model.ts @@ -1,4 +1,4 @@ -import { Account } from '../actors' +import { Account } from '../actors/index.js' export interface AccountBlock { byAccount: Account diff --git a/shared/models/moderation/block-status.model.ts b/packages/models/src/moderation/block-status.model.ts similarity index 100% rename from shared/models/moderation/block-status.model.ts rename to packages/models/src/moderation/block-status.model.ts diff --git a/packages/models/src/moderation/index.ts b/packages/models/src/moderation/index.ts new file mode 100644 index 000000000..52e21e7b3 --- /dev/null +++ b/packages/models/src/moderation/index.ts @@ -0,0 +1,4 @@ +export * from './abuse/index.js' +export * from './block-status.model.js' +export * from './account-block.model.js' +export * from './server-block.model.js' diff --git a/shared/models/moderation/server-block.model.ts b/packages/models/src/moderation/server-block.model.ts similarity index 73% rename from shared/models/moderation/server-block.model.ts rename to packages/models/src/moderation/server-block.model.ts index a8b8af0b7..b85646fc6 100644 --- a/shared/models/moderation/server-block.model.ts +++ b/packages/models/src/moderation/server-block.model.ts @@ -1,4 +1,4 @@ -import { Account } from '../actors' +import { Account } from '../actors/index.js' export interface ServerBlock { byAccount: Account diff --git a/packages/models/src/nodeinfo/index.ts b/packages/models/src/nodeinfo/index.ts new file mode 100644 index 000000000..932288795 --- /dev/null +++ b/packages/models/src/nodeinfo/index.ts @@ -0,0 +1 @@ +export * from './nodeinfo.model.js' diff --git a/shared/models/nodeinfo/nodeinfo.model.ts b/packages/models/src/nodeinfo/nodeinfo.model.ts similarity index 100% rename from shared/models/nodeinfo/nodeinfo.model.ts rename to packages/models/src/nodeinfo/nodeinfo.model.ts diff --git a/packages/models/src/overviews/index.ts b/packages/models/src/overviews/index.ts new file mode 100644 index 000000000..20dc105e2 --- /dev/null +++ b/packages/models/src/overviews/index.ts @@ -0,0 +1 @@ +export * from './videos-overview.model.js' diff --git a/shared/models/overviews/videos-overview.model.ts b/packages/models/src/overviews/videos-overview.model.ts similarity index 96% rename from shared/models/overviews/videos-overview.model.ts rename to packages/models/src/overviews/videos-overview.model.ts index 0f3cb4a52..3a1ba1760 100644 --- a/shared/models/overviews/videos-overview.model.ts +++ b/packages/models/src/overviews/videos-overview.model.ts @@ -1,4 +1,4 @@ -import { Video, VideoChannelSummary, VideoConstant } from '../videos' +import { Video, VideoChannelSummary, VideoConstant } from '../videos/index.js' export interface ChannelOverview { channel: VideoChannelSummary diff --git a/shared/models/plugins/client/client-hook.model.ts b/packages/models/src/plugins/client/client-hook.model.ts similarity index 100% rename from shared/models/plugins/client/client-hook.model.ts rename to packages/models/src/plugins/client/client-hook.model.ts diff --git a/packages/models/src/plugins/client/index.ts b/packages/models/src/plugins/client/index.ts new file mode 100644 index 000000000..04fa32d6d --- /dev/null +++ b/packages/models/src/plugins/client/index.ts @@ -0,0 +1,8 @@ +export * from './client-hook.model.js' +export * from './plugin-client-scope.type.js' +export * from './plugin-element-placeholder.type.js' +export * from './plugin-selector-id.type.js' +export * from './register-client-form-field.model.js' +export * from './register-client-hook.model.js' +export * from './register-client-route.model.js' +export * from './register-client-settings-script.model.js' diff --git a/shared/models/plugins/client/plugin-client-scope.type.ts b/packages/models/src/plugins/client/plugin-client-scope.type.ts similarity index 100% rename from shared/models/plugins/client/plugin-client-scope.type.ts rename to packages/models/src/plugins/client/plugin-client-scope.type.ts diff --git a/shared/models/plugins/client/plugin-element-placeholder.type.ts b/packages/models/src/plugins/client/plugin-element-placeholder.type.ts similarity index 100% rename from shared/models/plugins/client/plugin-element-placeholder.type.ts rename to packages/models/src/plugins/client/plugin-element-placeholder.type.ts diff --git a/shared/models/plugins/client/plugin-selector-id.type.ts b/packages/models/src/plugins/client/plugin-selector-id.type.ts similarity index 100% rename from shared/models/plugins/client/plugin-selector-id.type.ts rename to packages/models/src/plugins/client/plugin-selector-id.type.ts diff --git a/shared/models/plugins/client/register-client-form-field.model.ts b/packages/models/src/plugins/client/register-client-form-field.model.ts similarity index 100% rename from shared/models/plugins/client/register-client-form-field.model.ts rename to packages/models/src/plugins/client/register-client-form-field.model.ts diff --git a/shared/models/plugins/client/register-client-hook.model.ts b/packages/models/src/plugins/client/register-client-hook.model.ts similarity index 66% rename from shared/models/plugins/client/register-client-hook.model.ts rename to packages/models/src/plugins/client/register-client-hook.model.ts index 81047b21d..19159ed1e 100644 --- a/shared/models/plugins/client/register-client-hook.model.ts +++ b/packages/models/src/plugins/client/register-client-hook.model.ts @@ -1,4 +1,4 @@ -import { ClientHookName } from './client-hook.model' +import { ClientHookName } from './client-hook.model.js' export interface RegisterClientHookOptions { target: ClientHookName diff --git a/shared/models/plugins/client/register-client-route.model.ts b/packages/models/src/plugins/client/register-client-route.model.ts similarity index 100% rename from shared/models/plugins/client/register-client-route.model.ts rename to packages/models/src/plugins/client/register-client-route.model.ts diff --git a/shared/models/plugins/client/register-client-settings-script.model.ts b/packages/models/src/plugins/client/register-client-settings-script.model.ts similarity index 73% rename from shared/models/plugins/client/register-client-settings-script.model.ts rename to packages/models/src/plugins/client/register-client-settings-script.model.ts index 117ca4739..7de3c1c28 100644 --- a/shared/models/plugins/client/register-client-settings-script.model.ts +++ b/packages/models/src/plugins/client/register-client-settings-script.model.ts @@ -1,4 +1,4 @@ -import { RegisterServerSettingOptions } from '../server' +import { RegisterServerSettingOptions } from '../server/index.js' export interface RegisterClientSettingsScriptOptions { isSettingHidden (options: { diff --git a/packages/models/src/plugins/hook-type.enum.ts b/packages/models/src/plugins/hook-type.enum.ts new file mode 100644 index 000000000..7acc5f48a --- /dev/null +++ b/packages/models/src/plugins/hook-type.enum.ts @@ -0,0 +1,7 @@ +export const HookType = { + STATIC: 1, + ACTION: 2, + FILTER: 3 +} as const + +export type HookType_Type = typeof HookType[keyof typeof HookType] diff --git a/packages/models/src/plugins/index.ts b/packages/models/src/plugins/index.ts new file mode 100644 index 000000000..1117a946e --- /dev/null +++ b/packages/models/src/plugins/index.ts @@ -0,0 +1,6 @@ +export * from './client/index.js' +export * from './plugin-index/index.js' +export * from './server/index.js' +export * from './hook-type.enum.js' +export * from './plugin-package-json.model.js' +export * from './plugin.type.js' diff --git a/packages/models/src/plugins/plugin-index/index.ts b/packages/models/src/plugins/plugin-index/index.ts new file mode 100644 index 000000000..f53b88084 --- /dev/null +++ b/packages/models/src/plugins/plugin-index/index.ts @@ -0,0 +1,3 @@ +export * from './peertube-plugin-index-list.model.js' +export * from './peertube-plugin-index.model.js' +export * from './peertube-plugin-latest-version.model.js' diff --git a/shared/models/plugins/plugin-index/peertube-plugin-index-list.model.ts b/packages/models/src/plugins/plugin-index/peertube-plugin-index-list.model.ts similarity index 63% rename from shared/models/plugins/plugin-index/peertube-plugin-index-list.model.ts rename to packages/models/src/plugins/plugin-index/peertube-plugin-index-list.model.ts index ecb46482e..98301bbc1 100644 --- a/shared/models/plugins/plugin-index/peertube-plugin-index-list.model.ts +++ b/packages/models/src/plugins/plugin-index/peertube-plugin-index-list.model.ts @@ -1,10 +1,10 @@ -import { PluginType } from '../plugin.type' +import { PluginType_Type } from '../plugin.type.js' export interface PeertubePluginIndexList { start: number count: number sort: string - pluginType?: PluginType + pluginType?: PluginType_Type currentPeerTubeEngine?: string search?: string } diff --git a/shared/models/plugins/plugin-index/peertube-plugin-index.model.ts b/packages/models/src/plugins/plugin-index/peertube-plugin-index.model.ts similarity index 100% rename from shared/models/plugins/plugin-index/peertube-plugin-index.model.ts rename to packages/models/src/plugins/plugin-index/peertube-plugin-index.model.ts diff --git a/shared/models/plugins/plugin-index/peertube-plugin-latest-version.model.ts b/packages/models/src/plugins/plugin-index/peertube-plugin-latest-version.model.ts similarity index 100% rename from shared/models/plugins/plugin-index/peertube-plugin-latest-version.model.ts rename to packages/models/src/plugins/plugin-index/peertube-plugin-latest-version.model.ts diff --git a/shared/models/plugins/plugin-package-json.model.ts b/packages/models/src/plugins/plugin-package-json.model.ts similarity index 98% rename from shared/models/plugins/plugin-package-json.model.ts rename to packages/models/src/plugins/plugin-package-json.model.ts index 7ce968ff2..5b9ccec56 100644 --- a/shared/models/plugins/plugin-package-json.model.ts +++ b/packages/models/src/plugins/plugin-package-json.model.ts @@ -1,4 +1,4 @@ -import { PluginClientScope } from './client/plugin-client-scope.type' +import { PluginClientScope } from './client/plugin-client-scope.type.js' export type PluginTranslationPathsJSON = { [ locale: string ]: string diff --git a/packages/models/src/plugins/plugin.type.ts b/packages/models/src/plugins/plugin.type.ts new file mode 100644 index 000000000..7d03012e6 --- /dev/null +++ b/packages/models/src/plugins/plugin.type.ts @@ -0,0 +1,6 @@ +export const PluginType = { + PLUGIN: 1, + THEME: 2 +} as const + +export type PluginType_Type = typeof PluginType[keyof typeof PluginType] diff --git a/packages/models/src/plugins/server/api/index.ts b/packages/models/src/plugins/server/api/index.ts new file mode 100644 index 000000000..1e3842c46 --- /dev/null +++ b/packages/models/src/plugins/server/api/index.ts @@ -0,0 +1,3 @@ +export * from './install-plugin.model.js' +export * from './manage-plugin.model.js' +export * from './peertube-plugin.model.js' diff --git a/shared/models/plugins/server/api/install-plugin.model.ts b/packages/models/src/plugins/server/api/install-plugin.model.ts similarity index 100% rename from shared/models/plugins/server/api/install-plugin.model.ts rename to packages/models/src/plugins/server/api/install-plugin.model.ts diff --git a/shared/models/plugins/server/api/manage-plugin.model.ts b/packages/models/src/plugins/server/api/manage-plugin.model.ts similarity index 100% rename from shared/models/plugins/server/api/manage-plugin.model.ts rename to packages/models/src/plugins/server/api/manage-plugin.model.ts diff --git a/shared/models/plugins/server/api/peertube-plugin.model.ts b/packages/models/src/plugins/server/api/peertube-plugin.model.ts similarity index 77% rename from shared/models/plugins/server/api/peertube-plugin.model.ts rename to packages/models/src/plugins/server/api/peertube-plugin.model.ts index 54c383f57..0bc1b095b 100644 --- a/shared/models/plugins/server/api/peertube-plugin.model.ts +++ b/packages/models/src/plugins/server/api/peertube-plugin.model.ts @@ -1,8 +1,8 @@ -import { PluginType } from '../../plugin.type' +import { PluginType_Type } from '../../plugin.type.js' export interface PeerTubePlugin { name: string - type: PluginType + type: PluginType_Type latestVersion: string version: string enabled: boolean diff --git a/packages/models/src/plugins/server/index.ts b/packages/models/src/plugins/server/index.ts new file mode 100644 index 000000000..04412318b --- /dev/null +++ b/packages/models/src/plugins/server/index.ts @@ -0,0 +1,7 @@ +export * from './api/index.js' +export * from './managers/index.js' +export * from './settings/index.js' +export * from './plugin-constant-manager.model.js' +export * from './plugin-translation.model.js' +export * from './register-server-hook.model.js' +export * from './server-hook.model.js' diff --git a/packages/models/src/plugins/server/managers/index.ts b/packages/models/src/plugins/server/managers/index.ts new file mode 100644 index 000000000..2433dd9bf --- /dev/null +++ b/packages/models/src/plugins/server/managers/index.ts @@ -0,0 +1,9 @@ + +export * from './plugin-playlist-privacy-manager.model.js' +export * from './plugin-settings-manager.model.js' +export * from './plugin-storage-manager.model.js' +export * from './plugin-transcoding-manager.model.js' +export * from './plugin-video-category-manager.model.js' +export * from './plugin-video-language-manager.model.js' +export * from './plugin-video-licence-manager.model.js' +export * from './plugin-video-privacy-manager.model.js' diff --git a/shared/models/plugins/server/managers/plugin-playlist-privacy-manager.model.ts b/packages/models/src/plugins/server/managers/plugin-playlist-privacy-manager.model.ts similarity index 52% rename from shared/models/plugins/server/managers/plugin-playlist-privacy-manager.model.ts rename to packages/models/src/plugins/server/managers/plugin-playlist-privacy-manager.model.ts index 35247c1e3..212c910c5 100644 --- a/shared/models/plugins/server/managers/plugin-playlist-privacy-manager.model.ts +++ b/packages/models/src/plugins/server/managers/plugin-playlist-privacy-manager.model.ts @@ -1,12 +1,12 @@ -import { VideoPlaylistPrivacy } from '../../../videos/playlist/video-playlist-privacy.model' -import { ConstantManager } from '../plugin-constant-manager.model' +import { VideoPlaylistPrivacyType } from '../../../videos/playlist/video-playlist-privacy.model.js' +import { ConstantManager } from '../plugin-constant-manager.model.js' -export interface PluginPlaylistPrivacyManager extends ConstantManager { +export interface PluginPlaylistPrivacyManager extends ConstantManager { /** * PUBLIC = 1, * UNLISTED = 2, * PRIVATE = 3 * @deprecated use `deleteConstant` instead */ - deletePlaylistPrivacy: (privacyKey: VideoPlaylistPrivacy) => boolean + deletePlaylistPrivacy: (privacyKey: VideoPlaylistPrivacyType) => boolean } diff --git a/shared/models/plugins/server/managers/plugin-settings-manager.model.ts b/packages/models/src/plugins/server/managers/plugin-settings-manager.model.ts similarity index 100% rename from shared/models/plugins/server/managers/plugin-settings-manager.model.ts rename to packages/models/src/plugins/server/managers/plugin-settings-manager.model.ts diff --git a/shared/models/plugins/server/managers/plugin-storage-manager.model.ts b/packages/models/src/plugins/server/managers/plugin-storage-manager.model.ts similarity index 100% rename from shared/models/plugins/server/managers/plugin-storage-manager.model.ts rename to packages/models/src/plugins/server/managers/plugin-storage-manager.model.ts diff --git a/shared/models/plugins/server/managers/plugin-transcoding-manager.model.ts b/packages/models/src/plugins/server/managers/plugin-transcoding-manager.model.ts similarity index 97% rename from shared/models/plugins/server/managers/plugin-transcoding-manager.model.ts rename to packages/models/src/plugins/server/managers/plugin-transcoding-manager.model.ts index b6fb46ba0..235f5c65d 100644 --- a/shared/models/plugins/server/managers/plugin-transcoding-manager.model.ts +++ b/packages/models/src/plugins/server/managers/plugin-transcoding-manager.model.ts @@ -1,4 +1,4 @@ -import { EncoderOptionsBuilder } from '../../../videos/transcoding' +import { EncoderOptionsBuilder } from '../../../videos/transcoding/index.js' export interface PluginTranscodingManager { addLiveProfile (encoder: string, profile: string, builder: EncoderOptionsBuilder): boolean diff --git a/shared/models/plugins/server/managers/plugin-video-category-manager.model.ts b/packages/models/src/plugins/server/managers/plugin-video-category-manager.model.ts similarity index 98% rename from shared/models/plugins/server/managers/plugin-video-category-manager.model.ts rename to packages/models/src/plugins/server/managers/plugin-video-category-manager.model.ts index cf3d828fe..9da691e11 100644 --- a/shared/models/plugins/server/managers/plugin-video-category-manager.model.ts +++ b/packages/models/src/plugins/server/managers/plugin-video-category-manager.model.ts @@ -1,4 +1,4 @@ -import { ConstantManager } from '../plugin-constant-manager.model' +import { ConstantManager } from '../plugin-constant-manager.model.js' export interface PluginVideoCategoryManager extends ConstantManager { /** diff --git a/shared/models/plugins/server/managers/plugin-video-language-manager.model.ts b/packages/models/src/plugins/server/managers/plugin-video-language-manager.model.ts similarity index 98% rename from shared/models/plugins/server/managers/plugin-video-language-manager.model.ts rename to packages/models/src/plugins/server/managers/plugin-video-language-manager.model.ts index 69fc8e503..712486075 100644 --- a/shared/models/plugins/server/managers/plugin-video-language-manager.model.ts +++ b/packages/models/src/plugins/server/managers/plugin-video-language-manager.model.ts @@ -1,4 +1,4 @@ -import { ConstantManager } from '../plugin-constant-manager.model' +import { ConstantManager } from '../plugin-constant-manager.model.js' export interface PluginVideoLanguageManager extends ConstantManager { /** diff --git a/shared/models/plugins/server/managers/plugin-video-licence-manager.model.ts b/packages/models/src/plugins/server/managers/plugin-video-licence-manager.model.ts similarity index 98% rename from shared/models/plugins/server/managers/plugin-video-licence-manager.model.ts rename to packages/models/src/plugins/server/managers/plugin-video-licence-manager.model.ts index 21b422270..cebae8d95 100644 --- a/shared/models/plugins/server/managers/plugin-video-licence-manager.model.ts +++ b/packages/models/src/plugins/server/managers/plugin-video-licence-manager.model.ts @@ -1,4 +1,4 @@ -import { ConstantManager } from '../plugin-constant-manager.model' +import { ConstantManager } from '../plugin-constant-manager.model.js' export interface PluginVideoLicenceManager extends ConstantManager { /** diff --git a/shared/models/plugins/server/managers/plugin-video-privacy-manager.model.ts b/packages/models/src/plugins/server/managers/plugin-video-privacy-manager.model.ts similarity index 61% rename from shared/models/plugins/server/managers/plugin-video-privacy-manager.model.ts rename to packages/models/src/plugins/server/managers/plugin-video-privacy-manager.model.ts index a237037db..260cee683 100644 --- a/shared/models/plugins/server/managers/plugin-video-privacy-manager.model.ts +++ b/packages/models/src/plugins/server/managers/plugin-video-privacy-manager.model.ts @@ -1,7 +1,7 @@ -import { VideoPrivacy } from '../../../videos/video-privacy.enum' -import { ConstantManager } from '../plugin-constant-manager.model' +import { VideoPrivacyType } from '../../../videos/video-privacy.enum.js' +import { ConstantManager } from '../plugin-constant-manager.model.js' -export interface PluginVideoPrivacyManager extends ConstantManager { +export interface PluginVideoPrivacyManager extends ConstantManager { /** * PUBLIC = 1, * UNLISTED = 2, @@ -9,5 +9,5 @@ export interface PluginVideoPrivacyManager extends ConstantManager * INTERNAL = 4 * @deprecated use `deleteConstant` instead */ - deletePrivacy: (privacyKey: VideoPrivacy) => boolean + deletePrivacy: (privacyKey: VideoPrivacyType) => boolean } diff --git a/shared/models/plugins/server/plugin-constant-manager.model.ts b/packages/models/src/plugins/server/plugin-constant-manager.model.ts similarity index 100% rename from shared/models/plugins/server/plugin-constant-manager.model.ts rename to packages/models/src/plugins/server/plugin-constant-manager.model.ts diff --git a/shared/models/plugins/server/plugin-translation.model.ts b/packages/models/src/plugins/server/plugin-translation.model.ts similarity index 100% rename from shared/models/plugins/server/plugin-translation.model.ts rename to packages/models/src/plugins/server/plugin-translation.model.ts diff --git a/shared/models/plugins/server/register-server-hook.model.ts b/packages/models/src/plugins/server/register-server-hook.model.ts similarity index 66% rename from shared/models/plugins/server/register-server-hook.model.ts rename to packages/models/src/plugins/server/register-server-hook.model.ts index 746fdc329..05c883f1f 100644 --- a/shared/models/plugins/server/register-server-hook.model.ts +++ b/packages/models/src/plugins/server/register-server-hook.model.ts @@ -1,4 +1,4 @@ -import { ServerHookName } from './server-hook.model' +import { ServerHookName } from './server-hook.model.js' export interface RegisterServerHookOptions { target: ServerHookName diff --git a/shared/models/plugins/server/server-hook.model.ts b/packages/models/src/plugins/server/server-hook.model.ts similarity index 100% rename from shared/models/plugins/server/server-hook.model.ts rename to packages/models/src/plugins/server/server-hook.model.ts diff --git a/packages/models/src/plugins/server/settings/index.ts b/packages/models/src/plugins/server/settings/index.ts new file mode 100644 index 000000000..4bdccaa4a --- /dev/null +++ b/packages/models/src/plugins/server/settings/index.ts @@ -0,0 +1,2 @@ +export * from './public-server.setting.js' +export * from './register-server-setting.model.js' diff --git a/shared/models/plugins/server/settings/public-server.setting.ts b/packages/models/src/plugins/server/settings/public-server.setting.ts similarity index 90% rename from shared/models/plugins/server/settings/public-server.setting.ts rename to packages/models/src/plugins/server/settings/public-server.setting.ts index d38e5424a..0b6251aa3 100644 --- a/shared/models/plugins/server/settings/public-server.setting.ts +++ b/packages/models/src/plugins/server/settings/public-server.setting.ts @@ -1,4 +1,4 @@ -import { SettingEntries } from '../managers/plugin-settings-manager.model' +import { SettingEntries } from '../managers/plugin-settings-manager.model.js' export interface PublicServerSetting { publicSettings: SettingEntries diff --git a/shared/models/plugins/server/settings/register-server-setting.model.ts b/packages/models/src/plugins/server/settings/register-server-setting.model.ts similarity index 85% rename from shared/models/plugins/server/settings/register-server-setting.model.ts rename to packages/models/src/plugins/server/settings/register-server-setting.model.ts index d9a798cac..8cde8eaaa 100644 --- a/shared/models/plugins/server/settings/register-server-setting.model.ts +++ b/packages/models/src/plugins/server/settings/register-server-setting.model.ts @@ -1,4 +1,4 @@ -import { RegisterClientFormFieldOptions } from '../../client' +import { RegisterClientFormFieldOptions } from '../../client/index.js' export type RegisterServerSettingOptions = RegisterClientFormFieldOptions & { // If the setting is not private, anyone can view its value (client code included) diff --git a/packages/models/src/redundancy/index.ts b/packages/models/src/redundancy/index.ts new file mode 100644 index 000000000..89e8fe464 --- /dev/null +++ b/packages/models/src/redundancy/index.ts @@ -0,0 +1,4 @@ +export * from './video-redundancies-filters.model.js' +export * from './video-redundancy-config-filter.type.js' +export * from './video-redundancy.model.js' +export * from './videos-redundancy-strategy.model.js' diff --git a/shared/models/redundancy/video-redundancies-filters.model.ts b/packages/models/src/redundancy/video-redundancies-filters.model.ts similarity index 100% rename from shared/models/redundancy/video-redundancies-filters.model.ts rename to packages/models/src/redundancy/video-redundancies-filters.model.ts diff --git a/shared/models/redundancy/video-redundancy-config-filter.type.ts b/packages/models/src/redundancy/video-redundancy-config-filter.type.ts similarity index 100% rename from shared/models/redundancy/video-redundancy-config-filter.type.ts rename to packages/models/src/redundancy/video-redundancy-config-filter.type.ts diff --git a/shared/models/redundancy/video-redundancy.model.ts b/packages/models/src/redundancy/video-redundancy.model.ts similarity index 100% rename from shared/models/redundancy/video-redundancy.model.ts rename to packages/models/src/redundancy/video-redundancy.model.ts diff --git a/shared/models/redundancy/videos-redundancy-strategy.model.ts b/packages/models/src/redundancy/videos-redundancy-strategy.model.ts similarity index 100% rename from shared/models/redundancy/videos-redundancy-strategy.model.ts rename to packages/models/src/redundancy/videos-redundancy-strategy.model.ts diff --git a/shared/models/runners/abort-runner-job-body.model.ts b/packages/models/src/runners/abort-runner-job-body.model.ts similarity index 100% rename from shared/models/runners/abort-runner-job-body.model.ts rename to packages/models/src/runners/abort-runner-job-body.model.ts diff --git a/shared/models/runners/accept-runner-job-body.model.ts b/packages/models/src/runners/accept-runner-job-body.model.ts similarity index 100% rename from shared/models/runners/accept-runner-job-body.model.ts rename to packages/models/src/runners/accept-runner-job-body.model.ts diff --git a/shared/models/runners/accept-runner-job-result.model.ts b/packages/models/src/runners/accept-runner-job-result.model.ts similarity index 54% rename from shared/models/runners/accept-runner-job-result.model.ts rename to packages/models/src/runners/accept-runner-job-result.model.ts index f2094b945..ebb605930 100644 --- a/shared/models/runners/accept-runner-job-result.model.ts +++ b/packages/models/src/runners/accept-runner-job-result.model.ts @@ -1,5 +1,5 @@ -import { RunnerJobPayload } from './runner-job-payload.model' -import { RunnerJob } from './runner-job.model' +import { RunnerJobPayload } from './runner-job-payload.model.js' +import { RunnerJob } from './runner-job.model.js' export interface AcceptRunnerJobResult { job: RunnerJob & { jobToken: string } diff --git a/shared/models/runners/error-runner-job-body.model.ts b/packages/models/src/runners/error-runner-job-body.model.ts similarity index 100% rename from shared/models/runners/error-runner-job-body.model.ts rename to packages/models/src/runners/error-runner-job-body.model.ts diff --git a/packages/models/src/runners/index.ts b/packages/models/src/runners/index.ts new file mode 100644 index 000000000..cfe997b64 --- /dev/null +++ b/packages/models/src/runners/index.ts @@ -0,0 +1,21 @@ +export * from './abort-runner-job-body.model.js' +export * from './accept-runner-job-body.model.js' +export * from './accept-runner-job-result.model.js' +export * from './error-runner-job-body.model.js' +export * from './list-runner-jobs-query.model.js' +export * from './list-runner-registration-tokens.model.js' +export * from './list-runners-query.model.js' +export * from './register-runner-body.model.js' +export * from './register-runner-result.model.js' +export * from './request-runner-job-body.model.js' +export * from './request-runner-job-result.model.js' +export * from './runner-job-payload.model.js' +export * from './runner-job-private-payload.model.js' +export * from './runner-job-state.model.js' +export * from './runner-job-success-body.model.js' +export * from './runner-job-type.type.js' +export * from './runner-job-update-body.model.js' +export * from './runner-job.model.js' +export * from './runner-registration-token.js' +export * from './runner.model.js' +export * from './unregister-runner-body.model.js' diff --git a/shared/models/runners/list-runner-jobs-query.model.ts b/packages/models/src/runners/list-runner-jobs-query.model.ts similarity index 52% rename from shared/models/runners/list-runner-jobs-query.model.ts rename to packages/models/src/runners/list-runner-jobs-query.model.ts index ef19b31fa..395fe4b92 100644 --- a/shared/models/runners/list-runner-jobs-query.model.ts +++ b/packages/models/src/runners/list-runner-jobs-query.model.ts @@ -1,9 +1,9 @@ -import { RunnerJobState } from './runner-job-state.model' +import { RunnerJobStateType } from './runner-job-state.model.js' export interface ListRunnerJobsQuery { start?: number count?: number sort?: string search?: string - stateOneOf?: RunnerJobState[] + stateOneOf?: RunnerJobStateType[] } diff --git a/shared/models/runners/list-runner-registration-tokens.model.ts b/packages/models/src/runners/list-runner-registration-tokens.model.ts similarity index 100% rename from shared/models/runners/list-runner-registration-tokens.model.ts rename to packages/models/src/runners/list-runner-registration-tokens.model.ts diff --git a/shared/models/runners/list-runners-query.model.ts b/packages/models/src/runners/list-runners-query.model.ts similarity index 100% rename from shared/models/runners/list-runners-query.model.ts rename to packages/models/src/runners/list-runners-query.model.ts diff --git a/shared/models/runners/register-runner-body.model.ts b/packages/models/src/runners/register-runner-body.model.ts similarity index 100% rename from shared/models/runners/register-runner-body.model.ts rename to packages/models/src/runners/register-runner-body.model.ts diff --git a/shared/models/runners/register-runner-result.model.ts b/packages/models/src/runners/register-runner-result.model.ts similarity index 100% rename from shared/models/runners/register-runner-result.model.ts rename to packages/models/src/runners/register-runner-result.model.ts diff --git a/shared/models/runners/request-runner-job-body.model.ts b/packages/models/src/runners/request-runner-job-body.model.ts similarity index 100% rename from shared/models/runners/request-runner-job-body.model.ts rename to packages/models/src/runners/request-runner-job-body.model.ts diff --git a/shared/models/runners/request-runner-job-result.model.ts b/packages/models/src/runners/request-runner-job-result.model.ts similarity index 58% rename from shared/models/runners/request-runner-job-result.model.ts rename to packages/models/src/runners/request-runner-job-result.model.ts index 98601c42c..30c8c640c 100644 --- a/shared/models/runners/request-runner-job-result.model.ts +++ b/packages/models/src/runners/request-runner-job-result.model.ts @@ -1,5 +1,5 @@ -import { RunnerJobPayload } from './runner-job-payload.model' -import { RunnerJobType } from './runner-job-type.type' +import { RunnerJobPayload } from './runner-job-payload.model.js' +import { RunnerJobType } from './runner-job-type.type.js' export interface RequestRunnerJobResult

{ availableJobs: { diff --git a/shared/models/runners/runner-job-payload.model.ts b/packages/models/src/runners/runner-job-payload.model.ts similarity index 96% rename from shared/models/runners/runner-job-payload.model.ts rename to packages/models/src/runners/runner-job-payload.model.ts index 3dda6c51f..19b9d649b 100644 --- a/shared/models/runners/runner-job-payload.model.ts +++ b/packages/models/src/runners/runner-job-payload.model.ts @@ -1,4 +1,4 @@ -import { VideoStudioTaskPayload } from '../server' +import { VideoStudioTaskPayload } from '../server/index.js' export type RunnerJobVODPayload = RunnerJobVODWebVideoTranscodingPayload | diff --git a/shared/models/runners/runner-job-private-payload.model.ts b/packages/models/src/runners/runner-job-private-payload.model.ts similarity index 95% rename from shared/models/runners/runner-job-private-payload.model.ts rename to packages/models/src/runners/runner-job-private-payload.model.ts index 529034db8..c1205984e 100644 --- a/shared/models/runners/runner-job-private-payload.model.ts +++ b/packages/models/src/runners/runner-job-private-payload.model.ts @@ -1,4 +1,4 @@ -import { VideoStudioTaskPayload } from '../server' +import { VideoStudioTaskPayload } from '../server/index.js' export type RunnerJobVODPrivatePayload = RunnerJobVODWebVideoTranscodingPrivatePayload | diff --git a/packages/models/src/runners/runner-job-state.model.ts b/packages/models/src/runners/runner-job-state.model.ts new file mode 100644 index 000000000..07e135121 --- /dev/null +++ b/packages/models/src/runners/runner-job-state.model.ts @@ -0,0 +1,13 @@ +export const RunnerJobState = { + PENDING: 1, + PROCESSING: 2, + COMPLETED: 3, + ERRORED: 4, + WAITING_FOR_PARENT_JOB: 5, + CANCELLED: 6, + PARENT_ERRORED: 7, + PARENT_CANCELLED: 8, + COMPLETING: 9 +} as const + +export type RunnerJobStateType = typeof RunnerJobState[keyof typeof RunnerJobState] diff --git a/shared/models/runners/runner-job-success-body.model.ts b/packages/models/src/runners/runner-job-success-body.model.ts similarity index 100% rename from shared/models/runners/runner-job-success-body.model.ts rename to packages/models/src/runners/runner-job-success-body.model.ts diff --git a/shared/models/runners/runner-job-type.type.ts b/packages/models/src/runners/runner-job-type.type.ts similarity index 100% rename from shared/models/runners/runner-job-type.type.ts rename to packages/models/src/runners/runner-job-type.type.ts diff --git a/shared/models/runners/runner-job-update-body.model.ts b/packages/models/src/runners/runner-job-update-body.model.ts similarity index 100% rename from shared/models/runners/runner-job-update-body.model.ts rename to packages/models/src/runners/runner-job-update-body.model.ts diff --git a/shared/models/runners/runner-job.model.ts b/packages/models/src/runners/runner-job.model.ts similarity index 69% rename from shared/models/runners/runner-job.model.ts rename to packages/models/src/runners/runner-job.model.ts index 080093563..6d6427396 100644 --- a/shared/models/runners/runner-job.model.ts +++ b/packages/models/src/runners/runner-job.model.ts @@ -1,15 +1,15 @@ -import { VideoConstant } from '../videos' -import { RunnerJobPayload } from './runner-job-payload.model' -import { RunnerJobPrivatePayload } from './runner-job-private-payload.model' -import { RunnerJobState } from './runner-job-state.model' -import { RunnerJobType } from './runner-job-type.type' +import { VideoConstant } from '../videos/index.js' +import { RunnerJobPayload } from './runner-job-payload.model.js' +import { RunnerJobPrivatePayload } from './runner-job-private-payload.model.js' +import { RunnerJobStateType } from './runner-job-state.model.js' +import { RunnerJobType } from './runner-job-type.type.js' export interface RunnerJob { uuid: string type: RunnerJobType - state: VideoConstant + state: VideoConstant payload: T @@ -26,7 +26,7 @@ export interface RunnerJob { parent?: { type: RunnerJobType - state: VideoConstant + state: VideoConstant uuid: string } diff --git a/shared/models/runners/runner-registration-token.ts b/packages/models/src/runners/runner-registration-token.ts similarity index 100% rename from shared/models/runners/runner-registration-token.ts rename to packages/models/src/runners/runner-registration-token.ts diff --git a/shared/models/runners/runner.model.ts b/packages/models/src/runners/runner.model.ts similarity index 100% rename from shared/models/runners/runner.model.ts rename to packages/models/src/runners/runner.model.ts diff --git a/shared/models/runners/unregister-runner-body.model.ts b/packages/models/src/runners/unregister-runner-body.model.ts similarity index 100% rename from shared/models/runners/unregister-runner-body.model.ts rename to packages/models/src/runners/unregister-runner-body.model.ts diff --git a/shared/models/search/boolean-both-query.model.ts b/packages/models/src/search/boolean-both-query.model.ts similarity index 100% rename from shared/models/search/boolean-both-query.model.ts rename to packages/models/src/search/boolean-both-query.model.ts diff --git a/packages/models/src/search/index.ts b/packages/models/src/search/index.ts new file mode 100644 index 000000000..5c4de1eea --- /dev/null +++ b/packages/models/src/search/index.ts @@ -0,0 +1,6 @@ +export * from './boolean-both-query.model.js' +export * from './search-target-query.model.js' +export * from './videos-common-query.model.js' +export * from './video-channels-search-query.model.js' +export * from './video-playlists-search-query.model.js' +export * from './videos-search-query.model.js' diff --git a/shared/models/search/search-target-query.model.ts b/packages/models/src/search/search-target-query.model.ts similarity index 100% rename from shared/models/search/search-target-query.model.ts rename to packages/models/src/search/search-target-query.model.ts diff --git a/shared/models/search/video-channels-search-query.model.ts b/packages/models/src/search/video-channels-search-query.model.ts similarity index 82% rename from shared/models/search/video-channels-search-query.model.ts rename to packages/models/src/search/video-channels-search-query.model.ts index b68a1e80b..7e84359cf 100644 --- a/shared/models/search/video-channels-search-query.model.ts +++ b/packages/models/src/search/video-channels-search-query.model.ts @@ -1,4 +1,4 @@ -import { SearchTargetQuery } from './search-target-query.model' +import { SearchTargetQuery } from './search-target-query.model.js' export interface VideoChannelsSearchQuery extends SearchTargetQuery { search?: string diff --git a/shared/models/search/video-playlists-search-query.model.ts b/packages/models/src/search/video-playlists-search-query.model.ts similarity index 83% rename from shared/models/search/video-playlists-search-query.model.ts rename to packages/models/src/search/video-playlists-search-query.model.ts index d9027eb5b..65ac7b4d7 100644 --- a/shared/models/search/video-playlists-search-query.model.ts +++ b/packages/models/src/search/video-playlists-search-query.model.ts @@ -1,4 +1,4 @@ -import { SearchTargetQuery } from './search-target-query.model' +import { SearchTargetQuery } from './search-target-query.model.js' export interface VideoPlaylistsSearchQuery extends SearchTargetQuery { search?: string diff --git a/shared/models/search/videos-common-query.model.ts b/packages/models/src/search/videos-common-query.model.ts similarity index 71% rename from shared/models/search/videos-common-query.model.ts rename to packages/models/src/search/videos-common-query.model.ts index f783d7534..45181a739 100644 --- a/shared/models/search/videos-common-query.model.ts +++ b/packages/models/src/search/videos-common-query.model.ts @@ -1,6 +1,6 @@ -import { VideoPrivacy } from '@shared/models' -import { VideoInclude } from '../videos/video-include.enum' -import { BooleanBothQuery } from './boolean-both-query.model' +import { VideoIncludeType } from '../videos/video-include.enum.js' +import { VideoPrivacyType } from '../videos/video-privacy.enum.js' +import { BooleanBothQuery } from './boolean-both-query.model.js' // These query parameters can be used with any endpoint that list videos export interface VideosCommonQuery { @@ -13,7 +13,7 @@ export interface VideosCommonQuery { isLive?: boolean isLocal?: boolean - include?: VideoInclude + include?: VideoIncludeType categoryOneOf?: number[] @@ -21,7 +21,7 @@ export interface VideosCommonQuery { languageOneOf?: string[] - privacyOneOf?: VideoPrivacy[] + privacyOneOf?: VideoPrivacyType[] tagsOneOf?: string[] tagsAllOf?: string[] diff --git a/shared/models/search/videos-search-query.model.ts b/packages/models/src/search/videos-search-query.model.ts similarity index 79% rename from shared/models/search/videos-search-query.model.ts rename to packages/models/src/search/videos-search-query.model.ts index a5436879d..bbaa8d23f 100644 --- a/shared/models/search/videos-search-query.model.ts +++ b/packages/models/src/search/videos-search-query.model.ts @@ -1,5 +1,5 @@ -import { SearchTargetQuery } from './search-target-query.model' -import { VideosCommonQuery } from './videos-common-query.model' +import { SearchTargetQuery } from './search-target-query.model.js' +import { VideosCommonQuery } from './videos-common-query.model.js' export interface VideosSearchQuery extends SearchTargetQuery, VideosCommonQuery { search?: string diff --git a/shared/models/server/about.model.ts b/packages/models/src/server/about.model.ts similarity index 100% rename from shared/models/server/about.model.ts rename to packages/models/src/server/about.model.ts diff --git a/shared/models/server/broadcast-message-level.type.ts b/packages/models/src/server/broadcast-message-level.type.ts similarity index 100% rename from shared/models/server/broadcast-message-level.type.ts rename to packages/models/src/server/broadcast-message-level.type.ts diff --git a/shared/models/server/client-log-create.model.ts b/packages/models/src/server/client-log-create.model.ts similarity index 71% rename from shared/models/server/client-log-create.model.ts rename to packages/models/src/server/client-log-create.model.ts index c9dc65568..543af0d3d 100644 --- a/shared/models/server/client-log-create.model.ts +++ b/packages/models/src/server/client-log-create.model.ts @@ -1,4 +1,4 @@ -import { ClientLogLevel } from './client-log-level.type' +import { ClientLogLevel } from './client-log-level.type.js' export interface ClientLogCreate { message: string diff --git a/shared/models/server/client-log-level.type.ts b/packages/models/src/server/client-log-level.type.ts similarity index 100% rename from shared/models/server/client-log-level.type.ts rename to packages/models/src/server/client-log-level.type.ts diff --git a/shared/models/server/contact-form.model.ts b/packages/models/src/server/contact-form.model.ts similarity index 100% rename from shared/models/server/contact-form.model.ts rename to packages/models/src/server/contact-form.model.ts diff --git a/shared/models/server/custom-config.model.ts b/packages/models/src/server/custom-config.model.ts similarity index 98% rename from shared/models/server/custom-config.model.ts rename to packages/models/src/server/custom-config.model.ts index 0dbb46fa8..df4176ba7 100644 --- a/shared/models/server/custom-config.model.ts +++ b/packages/models/src/server/custom-config.model.ts @@ -1,5 +1,5 @@ -import { NSFWPolicyType } from '../videos/nsfw-policy.type' -import { BroadcastMessageLevel } from './broadcast-message-level.type' +import { NSFWPolicyType } from '../videos/nsfw-policy.type.js' +import { BroadcastMessageLevel } from './broadcast-message-level.type.js' export type ConfigResolutions = { '144p': boolean diff --git a/shared/models/server/debug.model.ts b/packages/models/src/server/debug.model.ts similarity index 100% rename from shared/models/server/debug.model.ts rename to packages/models/src/server/debug.model.ts diff --git a/shared/models/server/emailer.model.ts b/packages/models/src/server/emailer.model.ts similarity index 100% rename from shared/models/server/emailer.model.ts rename to packages/models/src/server/emailer.model.ts diff --git a/packages/models/src/server/index.ts b/packages/models/src/server/index.ts new file mode 100644 index 000000000..ba6af8f6f --- /dev/null +++ b/packages/models/src/server/index.ts @@ -0,0 +1,16 @@ +export * from './about.model.js' +export * from './broadcast-message-level.type.js' +export * from './client-log-create.model.js' +export * from './client-log-level.type.js' +export * from './contact-form.model.js' +export * from './custom-config.model.js' +export * from './debug.model.js' +export * from './emailer.model.js' +export * from './job.model.js' +export * from './peertube-problem-document.model.js' +export * from './server-config.model.js' +export * from './server-debug.model.js' +export * from './server-error-code.enum.js' +export * from './server-follow-create.model.js' +export * from './server-log-level.type.js' +export * from './server-stats.model.js' diff --git a/shared/models/server/job.model.ts b/packages/models/src/server/job.model.ts similarity index 94% rename from shared/models/server/job.model.ts rename to packages/models/src/server/job.model.ts index c14806dab..f86a20e28 100644 --- a/shared/models/server/job.model.ts +++ b/packages/models/src/server/job.model.ts @@ -1,8 +1,7 @@ -import { ContextType } from '../activitypub/context' -import { VideoState } from '../videos' -import { VideoResolution } from '../videos/file/video-resolution.enum' -import { VideoStudioTaskCut } from '../videos/studio' -import { SendEmailOptions } from './emailer.model' +import { ContextType } from '../activitypub/context.js' +import { VideoStateType } from '../videos/index.js' +import { VideoStudioTaskCut } from '../videos/studio/index.js' +import { SendEmailOptions } from './emailer.model.js' export type JobState = 'active' | 'completed' | 'failed' | 'waiting' | 'delayed' | 'paused' | 'waiting-children' @@ -144,7 +143,7 @@ interface BaseTranscodingPayload { export interface HLSTranscodingPayload extends BaseTranscodingPayload { type: 'new-resolution-to-hls' - resolution: VideoResolution + resolution: number fps: number copyCodecs: boolean @@ -153,14 +152,14 @@ export interface HLSTranscodingPayload extends BaseTranscodingPayload { export interface NewWebVideoResolutionTranscodingPayload extends BaseTranscodingPayload { type: 'new-resolution-to-web-video' - resolution: VideoResolution + resolution: number fps: number } export interface MergeAudioTranscodingPayload extends BaseTranscodingPayload { type: 'merge-audio-to-web-video' - resolution: VideoResolution + resolution: number fps: number hasChildren: boolean @@ -200,7 +199,7 @@ export interface DeleteResumableUploadMetaFilePayload { export interface MoveObjectStoragePayload { videoUUID: string isNewVideo: boolean - previousVideoState: VideoState + previousVideoState: VideoStateType } export type VideoStudioTaskCutPayload = VideoStudioTaskCut diff --git a/shared/models/server/peertube-problem-document.model.ts b/packages/models/src/server/peertube-problem-document.model.ts similarity index 59% rename from shared/models/server/peertube-problem-document.model.ts rename to packages/models/src/server/peertube-problem-document.model.ts index 83d9cea9b..c717fc152 100644 --- a/shared/models/server/peertube-problem-document.model.ts +++ b/packages/models/src/server/peertube-problem-document.model.ts @@ -1,5 +1,5 @@ -import { HttpStatusCode } from '../../models' -import { OAuth2ErrorCode, ServerErrorCode } from './server-error-code.enum' +import { HttpStatusCodeType } from '../http/http-status-codes.js' +import { OAuth2ErrorCodeType, ServerErrorCodeType } from './server-error-code.enum.js' export interface PeerTubeProblemDocumentData { 'invalid-params'?: Record @@ -22,11 +22,11 @@ export interface PeerTubeProblemDocument extends PeerTubeProblemDocumentData { title: string detail: string - // Compat PeerTube <= 3.2 + // FIXME: Compat PeerTube <= 3.2 error: string - status: HttpStatusCode + status: HttpStatusCodeType docs?: string - code?: ServerErrorCode | OAuth2ErrorCode + code?: OAuth2ErrorCodeType | ServerErrorCodeType } diff --git a/shared/models/server/server-config.model.ts b/packages/models/src/server/server-config.model.ts similarity index 96% rename from shared/models/server/server-config.model.ts rename to packages/models/src/server/server-config.model.ts index 3f61e93b5..a2a2bd5aa 100644 --- a/shared/models/server/server-config.model.ts +++ b/packages/models/src/server/server-config.model.ts @@ -1,7 +1,7 @@ -import { ClientScriptJSON } from '../plugins/plugin-package-json.model' -import { NSFWPolicyType } from '../videos/nsfw-policy.type' -import { VideoPrivacy } from '../videos/video-privacy.enum' -import { BroadcastMessageLevel } from './broadcast-message-level.type' +import { ClientScriptJSON } from '../plugins/plugin-package-json.model.js' +import { NSFWPolicyType } from '../videos/nsfw-policy.type.js' +import { VideoPrivacyType } from '../videos/video-privacy.enum.js' +import { BroadcastMessageLevel } from './broadcast-message-level.type.js' export interface ServerConfigPlugin { name: string @@ -57,7 +57,7 @@ export interface ServerConfig { publish: { downloadEnabled: boolean commentsEnabled: boolean - privacy: VideoPrivacy + privacy: VideoPrivacyType licence: number } diff --git a/shared/models/server/server-debug.model.ts b/packages/models/src/server/server-debug.model.ts similarity index 100% rename from shared/models/server/server-debug.model.ts rename to packages/models/src/server/server-debug.model.ts diff --git a/shared/models/server/server-error-code.enum.ts b/packages/models/src/server/server-error-code.enum.ts similarity index 55% rename from shared/models/server/server-error-code.enum.ts rename to packages/models/src/server/server-error-code.enum.ts index 583e8245f..dc200c1ea 100644 --- a/shared/models/server/server-error-code.enum.ts +++ b/packages/models/src/server/server-error-code.enum.ts @@ -1,67 +1,67 @@ -export const enum ServerErrorCode { +export const ServerErrorCode = { /** * The simplest form of payload too large: when the file size is over the * global file size limit */ - MAX_FILE_SIZE_REACHED = 'max_file_size_reached', + MAX_FILE_SIZE_REACHED:'max_file_size_reached', /** * The payload is too large for the user quota set */ - QUOTA_REACHED = 'quota_reached', + QUOTA_REACHED:'quota_reached', /** * Error yielded upon trying to access a video that is not federated, nor can * be. This may be due to: remote videos on instances that are not followed by * yours, and with your instance disallowing unknown instances being accessed. */ - DOES_NOT_RESPECT_FOLLOW_CONSTRAINTS = 'does_not_respect_follow_constraints', + DOES_NOT_RESPECT_FOLLOW_CONSTRAINTS:'does_not_respect_follow_constraints', - LIVE_NOT_ENABLED = 'live_not_enabled', - LIVE_NOT_ALLOWING_REPLAY = 'live_not_allowing_replay', - LIVE_CONFLICTING_PERMANENT_AND_SAVE_REPLAY = 'live_conflicting_permanent_and_save_replay', + LIVE_NOT_ENABLED:'live_not_enabled', + LIVE_NOT_ALLOWING_REPLAY:'live_not_allowing_replay', + LIVE_CONFLICTING_PERMANENT_AND_SAVE_REPLAY:'live_conflicting_permanent_and_save_replay', /** * Pretty self-explanatory: the set maximum number of simultaneous lives was * reached, and this error is typically there to inform the user trying to * broadcast one. */ - MAX_INSTANCE_LIVES_LIMIT_REACHED = 'max_instance_lives_limit_reached', + MAX_INSTANCE_LIVES_LIMIT_REACHED:'max_instance_lives_limit_reached', /** * Pretty self-explanatory: the set maximum number of simultaneous lives FOR * THIS USER was reached, and this error is typically there to inform the user * trying to broadcast one. */ - MAX_USER_LIVES_LIMIT_REACHED = 'max_user_lives_limit_reached', + MAX_USER_LIVES_LIMIT_REACHED:'max_user_lives_limit_reached', /** * A torrent should have at most one correct video file. Any more and we will * not be able to choose automatically. */ - INCORRECT_FILES_IN_TORRENT = 'incorrect_files_in_torrent', + INCORRECT_FILES_IN_TORRENT:'incorrect_files_in_torrent', - COMMENT_NOT_ASSOCIATED_TO_VIDEO = 'comment_not_associated_to_video', + COMMENT_NOT_ASSOCIATED_TO_VIDEO:'comment_not_associated_to_video', - MISSING_TWO_FACTOR = 'missing_two_factor', - INVALID_TWO_FACTOR = 'invalid_two_factor', + MISSING_TWO_FACTOR:'missing_two_factor', + INVALID_TWO_FACTOR:'invalid_two_factor', - ACCOUNT_WAITING_FOR_APPROVAL = 'account_waiting_for_approval', - ACCOUNT_APPROVAL_REJECTED = 'account_approval_rejected', + ACCOUNT_WAITING_FOR_APPROVAL:'account_waiting_for_approval', + ACCOUNT_APPROVAL_REJECTED:'account_approval_rejected', - RUNNER_JOB_NOT_IN_PROCESSING_STATE = 'runner_job_not_in_processing_state', - RUNNER_JOB_NOT_IN_PENDING_STATE = 'runner_job_not_in_pending_state', - UNKNOWN_RUNNER_TOKEN = 'unknown_runner_token', + RUNNER_JOB_NOT_IN_PROCESSING_STATE:'runner_job_not_in_processing_state', + RUNNER_JOB_NOT_IN_PENDING_STATE:'runner_job_not_in_pending_state', + UNKNOWN_RUNNER_TOKEN:'unknown_runner_token', - VIDEO_REQUIRES_PASSWORD = 'video_requires_password', - INCORRECT_VIDEO_PASSWORD = 'incorrect_video_password', + VIDEO_REQUIRES_PASSWORD:'video_requires_password', + INCORRECT_VIDEO_PASSWORD:'incorrect_video_password', - VIDEO_ALREADY_BEING_TRANSCODED = 'video_already_being_transcoded' -} + VIDEO_ALREADY_BEING_TRANSCODED:'video_already_being_transcoded' +} as const /** * oauthjs/oauth2-server error codes * @see https://datatracker.ietf.org/doc/html/rfc6749#section-5.2 **/ -export const enum OAuth2ErrorCode { +export const OAuth2ErrorCode = { /** * The provided authorization grant (e.g., authorization code, resource owner * credentials) or refresh token is invalid, expired, revoked, does not match @@ -70,7 +70,7 @@ export const enum OAuth2ErrorCode { * * @see https://github.com/oauthjs/node-oauth2-server/blob/master/lib/errors/invalid-grant-error.js */ - INVALID_GRANT = 'invalid_grant', + INVALID_GRANT: 'invalid_grant', /** * Client authentication failed (e.g., unknown client, no client authentication @@ -78,12 +78,15 @@ export const enum OAuth2ErrorCode { * * @see https://github.com/oauthjs/node-oauth2-server/blob/master/lib/errors/invalid-client-error.js */ - INVALID_CLIENT = 'invalid_client', + INVALID_CLIENT: 'invalid_client', /** * The access token provided is expired, revoked, malformed, or invalid for other reasons * * @see https://github.com/oauthjs/node-oauth2-server/blob/master/lib/errors/invalid-token-error.js */ - INVALID_TOKEN = 'invalid_token' -} + INVALID_TOKEN: 'invalid_token' +} as const + +export type OAuth2ErrorCodeType = typeof OAuth2ErrorCode[keyof typeof OAuth2ErrorCode] +export type ServerErrorCodeType = typeof ServerErrorCode[keyof typeof ServerErrorCode] diff --git a/shared/models/server/server-follow-create.model.ts b/packages/models/src/server/server-follow-create.model.ts similarity index 100% rename from shared/models/server/server-follow-create.model.ts rename to packages/models/src/server/server-follow-create.model.ts diff --git a/shared/models/server/server-log-level.type.ts b/packages/models/src/server/server-log-level.type.ts similarity index 100% rename from shared/models/server/server-log-level.type.ts rename to packages/models/src/server/server-log-level.type.ts diff --git a/shared/models/server/server-stats.model.ts b/packages/models/src/server/server-stats.model.ts similarity index 95% rename from shared/models/server/server-stats.model.ts rename to packages/models/src/server/server-stats.model.ts index 82f5a737f..5870ee73d 100644 --- a/shared/models/server/server-stats.model.ts +++ b/packages/models/src/server/server-stats.model.ts @@ -1,5 +1,5 @@ -import { ActivityType } from '../activitypub' -import { VideoRedundancyStrategyWithManual } from '../redundancy' +import { ActivityType } from '../activitypub/index.js' +import { VideoRedundancyStrategyWithManual } from '../redundancy/index.js' type ActivityPubMessagesSuccess = Record<`totalActivityPub${ActivityType}MessagesSuccesses`, number> type ActivityPubMessagesErrors = Record<`totalActivityPub${ActivityType}MessagesErrors`, number> diff --git a/packages/models/src/tokens/index.ts b/packages/models/src/tokens/index.ts new file mode 100644 index 000000000..db2d63d21 --- /dev/null +++ b/packages/models/src/tokens/index.ts @@ -0,0 +1 @@ +export * from './oauth-client-local.model.js' diff --git a/shared/models/tokens/oauth-client-local.model.ts b/packages/models/src/tokens/oauth-client-local.model.ts similarity index 100% rename from shared/models/tokens/oauth-client-local.model.ts rename to packages/models/src/tokens/oauth-client-local.model.ts diff --git a/packages/models/src/users/index.ts b/packages/models/src/users/index.ts new file mode 100644 index 000000000..6f5218234 --- /dev/null +++ b/packages/models/src/users/index.ts @@ -0,0 +1,16 @@ +export * from './registration/index.js' +export * from './two-factor-enable-result.model.js' +export * from './user-create-result.model.js' +export * from './user-create.model.js' +export * from './user-flag.model.js' +export * from './user-login.model.js' +export * from './user-notification-setting.model.js' +export * from './user-notification.model.js' +export * from './user-refresh-token.model.js' +export * from './user-right.enum.js' +export * from './user-role.js' +export * from './user-scoped-token.js' +export * from './user-update-me.model.js' +export * from './user-update.model.js' +export * from './user-video-quota.model.js' +export * from './user.model.js' diff --git a/packages/models/src/users/registration/index.ts b/packages/models/src/users/registration/index.ts new file mode 100644 index 000000000..dcf16ef9d --- /dev/null +++ b/packages/models/src/users/registration/index.ts @@ -0,0 +1,5 @@ +export * from './user-register.model.js' +export * from './user-registration-request.model.js' +export * from './user-registration-state.model.js' +export * from './user-registration-update-state.model.js' +export * from './user-registration.model.js' diff --git a/shared/models/users/registration/user-register.model.ts b/packages/models/src/users/registration/user-register.model.ts similarity index 100% rename from shared/models/users/registration/user-register.model.ts rename to packages/models/src/users/registration/user-register.model.ts diff --git a/shared/models/users/registration/user-registration-request.model.ts b/packages/models/src/users/registration/user-registration-request.model.ts similarity index 63% rename from shared/models/users/registration/user-registration-request.model.ts rename to packages/models/src/users/registration/user-registration-request.model.ts index 6c38817e0..ed369f96a 100644 --- a/shared/models/users/registration/user-registration-request.model.ts +++ b/packages/models/src/users/registration/user-registration-request.model.ts @@ -1,4 +1,4 @@ -import { UserRegister } from './user-register.model' +import { UserRegister } from './user-register.model.js' export interface UserRegistrationRequest extends UserRegister { registrationReason: string diff --git a/packages/models/src/users/registration/user-registration-state.model.ts b/packages/models/src/users/registration/user-registration-state.model.ts new file mode 100644 index 000000000..7c51f3f9d --- /dev/null +++ b/packages/models/src/users/registration/user-registration-state.model.ts @@ -0,0 +1,7 @@ +export const UserRegistrationState = { + PENDING: 1, + REJECTED: 2, + ACCEPTED: 3 +} + +export type UserRegistrationStateType = typeof UserRegistrationState[keyof typeof UserRegistrationState] diff --git a/shared/models/users/registration/user-registration-update-state.model.ts b/packages/models/src/users/registration/user-registration-update-state.model.ts similarity index 100% rename from shared/models/users/registration/user-registration-update-state.model.ts rename to packages/models/src/users/registration/user-registration-update-state.model.ts diff --git a/shared/models/users/registration/user-registration.model.ts b/packages/models/src/users/registration/user-registration.model.ts similarity index 76% rename from shared/models/users/registration/user-registration.model.ts rename to packages/models/src/users/registration/user-registration.model.ts index 0d74dc28b..0d01add36 100644 --- a/shared/models/users/registration/user-registration.model.ts +++ b/packages/models/src/users/registration/user-registration.model.ts @@ -1,10 +1,10 @@ -import { UserRegistrationState } from './user-registration-state.model' +import { UserRegistrationStateType } from './user-registration-state.model.js' export interface UserRegistration { id: number state: { - id: UserRegistrationState + id: UserRegistrationStateType label: string } diff --git a/shared/models/users/two-factor-enable-result.model.ts b/packages/models/src/users/two-factor-enable-result.model.ts similarity index 100% rename from shared/models/users/two-factor-enable-result.model.ts rename to packages/models/src/users/two-factor-enable-result.model.ts diff --git a/shared/models/users/user-create-result.model.ts b/packages/models/src/users/user-create-result.model.ts similarity index 100% rename from shared/models/users/user-create-result.model.ts rename to packages/models/src/users/user-create-result.model.ts diff --git a/shared/models/users/user-create.model.ts b/packages/models/src/users/user-create.model.ts similarity index 50% rename from shared/models/users/user-create.model.ts rename to packages/models/src/users/user-create.model.ts index ddc71dd59..b62cf692f 100644 --- a/shared/models/users/user-create.model.ts +++ b/packages/models/src/users/user-create.model.ts @@ -1,5 +1,5 @@ -import { UserRole } from './user-role' -import { UserAdminFlag } from './user-flag.model' +import { UserAdminFlagType } from './user-flag.model.js' +import { UserRoleType } from './user-role.js' export interface UserCreate { username: string @@ -7,7 +7,7 @@ export interface UserCreate { email: string videoQuota: number videoQuotaDaily: number - role: UserRole - adminFlags?: UserAdminFlag + role: UserRoleType + adminFlags?: UserAdminFlagType channelName?: string } diff --git a/packages/models/src/users/user-flag.model.ts b/packages/models/src/users/user-flag.model.ts new file mode 100644 index 000000000..0ecbacecc --- /dev/null +++ b/packages/models/src/users/user-flag.model.ts @@ -0,0 +1,6 @@ +export const UserAdminFlag = { + NONE: 0, + BYPASS_VIDEO_AUTO_BLACKLIST: 1 << 0 +} as const + +export type UserAdminFlagType = typeof UserAdminFlag[keyof typeof UserAdminFlag] diff --git a/shared/models/users/user-login.model.ts b/packages/models/src/users/user-login.model.ts similarity index 100% rename from shared/models/users/user-login.model.ts rename to packages/models/src/users/user-login.model.ts diff --git a/packages/models/src/users/user-notification-setting.model.ts b/packages/models/src/users/user-notification-setting.model.ts new file mode 100644 index 000000000..fbd94994e --- /dev/null +++ b/packages/models/src/users/user-notification-setting.model.ts @@ -0,0 +1,34 @@ +export const UserNotificationSettingValue = { + NONE: 0, + WEB: 1 << 0, + EMAIL: 1 << 1 +} as const + +export type UserNotificationSettingValueType = typeof UserNotificationSettingValue[keyof typeof UserNotificationSettingValue] + +export interface UserNotificationSetting { + abuseAsModerator: UserNotificationSettingValueType + videoAutoBlacklistAsModerator: UserNotificationSettingValueType + newUserRegistration: UserNotificationSettingValueType + + newVideoFromSubscription: UserNotificationSettingValueType + + blacklistOnMyVideo: UserNotificationSettingValueType + myVideoPublished: UserNotificationSettingValueType + myVideoImportFinished: UserNotificationSettingValueType + + commentMention: UserNotificationSettingValueType + newCommentOnMyVideo: UserNotificationSettingValueType + + newFollow: UserNotificationSettingValueType + newInstanceFollower: UserNotificationSettingValueType + autoInstanceFollowing: UserNotificationSettingValueType + + abuseStateChange: UserNotificationSettingValueType + abuseNewMessage: UserNotificationSettingValueType + + newPeerTubeVersion: UserNotificationSettingValueType + newPluginVersion: UserNotificationSettingValueType + + myVideoStudioEditionFinished: UserNotificationSettingValueType +} diff --git a/shared/models/users/user-notification.model.ts b/packages/models/src/users/user-notification.model.ts similarity index 57% rename from shared/models/users/user-notification.model.ts rename to packages/models/src/users/user-notification.model.ts index 294c921bd..991fe6728 100644 --- a/shared/models/users/user-notification.model.ts +++ b/packages/models/src/users/user-notification.model.ts @@ -1,41 +1,43 @@ -import { FollowState } from '../actors' -import { AbuseState } from '../moderation' -import { PluginType } from '../plugins' +import { FollowState } from '../actors/index.js' +import { AbuseStateType } from '../moderation/index.js' +import { PluginType_Type } from '../plugins/index.js' -export const enum UserNotificationType { - NEW_VIDEO_FROM_SUBSCRIPTION = 1, - NEW_COMMENT_ON_MY_VIDEO = 2, - NEW_ABUSE_FOR_MODERATORS = 3, +export const UserNotificationType = { + NEW_VIDEO_FROM_SUBSCRIPTION: 1, + NEW_COMMENT_ON_MY_VIDEO: 2, + NEW_ABUSE_FOR_MODERATORS: 3, - BLACKLIST_ON_MY_VIDEO = 4, - UNBLACKLIST_ON_MY_VIDEO = 5, + BLACKLIST_ON_MY_VIDEO: 4, + UNBLACKLIST_ON_MY_VIDEO: 5, - MY_VIDEO_PUBLISHED = 6, + MY_VIDEO_PUBLISHED: 6, - MY_VIDEO_IMPORT_SUCCESS = 7, - MY_VIDEO_IMPORT_ERROR = 8, + MY_VIDEO_IMPORT_SUCCESS: 7, + MY_VIDEO_IMPORT_ERROR: 8, - NEW_USER_REGISTRATION = 9, - NEW_FOLLOW = 10, - COMMENT_MENTION = 11, + NEW_USER_REGISTRATION: 9, + NEW_FOLLOW: 10, + COMMENT_MENTION: 11, - VIDEO_AUTO_BLACKLIST_FOR_MODERATORS = 12, + VIDEO_AUTO_BLACKLIST_FOR_MODERATORS: 12, - NEW_INSTANCE_FOLLOWER = 13, + NEW_INSTANCE_FOLLOWER: 13, - AUTO_INSTANCE_FOLLOWING = 14, + AUTO_INSTANCE_FOLLOWING: 14, - ABUSE_STATE_CHANGE = 15, + ABUSE_STATE_CHANGE: 15, - ABUSE_NEW_MESSAGE = 16, + ABUSE_NEW_MESSAGE: 16, - NEW_PLUGIN_VERSION = 17, - NEW_PEERTUBE_VERSION = 18, + NEW_PLUGIN_VERSION: 17, + NEW_PEERTUBE_VERSION: 18, - MY_VIDEO_STUDIO_EDITION_FINISHED = 19, + MY_VIDEO_STUDIO_EDITION_FINISHED: 19, - NEW_USER_REGISTRATION_REQUEST = 20 -} + NEW_USER_REGISTRATION_REQUEST: 20 +} as const + +export type UserNotificationType_Type = typeof UserNotificationType[keyof typeof UserNotificationType] export interface VideoInfo { id: number @@ -61,7 +63,7 @@ export interface ActorInfo { export interface UserNotification { id: number - type: UserNotificationType + type: UserNotificationType_Type read: boolean video?: VideoInfo & { @@ -85,7 +87,7 @@ export interface UserNotification { abuse?: { id: number - state: AbuseState + state: AbuseStateType video?: VideoInfo @@ -120,7 +122,7 @@ export interface UserNotification { plugin?: { name: string - type: PluginType + type: PluginType_Type latestVersion: string } diff --git a/shared/models/users/user-refresh-token.model.ts b/packages/models/src/users/user-refresh-token.model.ts similarity index 100% rename from shared/models/users/user-refresh-token.model.ts rename to packages/models/src/users/user-refresh-token.model.ts diff --git a/packages/models/src/users/user-right.enum.ts b/packages/models/src/users/user-right.enum.ts new file mode 100644 index 000000000..534b9feb0 --- /dev/null +++ b/packages/models/src/users/user-right.enum.ts @@ -0,0 +1,53 @@ +export const UserRight = { + ALL: 0, + + MANAGE_USERS: 1, + + MANAGE_SERVER_FOLLOW: 2, + + MANAGE_LOGS: 3, + + MANAGE_DEBUG: 4, + + MANAGE_SERVER_REDUNDANCY: 5, + + MANAGE_ABUSES: 6, + + MANAGE_JOBS: 7, + + MANAGE_CONFIGURATION: 8, + MANAGE_INSTANCE_CUSTOM_PAGE: 9, + + MANAGE_ACCOUNTS_BLOCKLIST: 10, + MANAGE_SERVERS_BLOCKLIST: 11, + + MANAGE_VIDEO_BLACKLIST: 12, + MANAGE_ANY_VIDEO_CHANNEL: 13, + + REMOVE_ANY_VIDEO: 14, + REMOVE_ANY_VIDEO_PLAYLIST: 15, + REMOVE_ANY_VIDEO_COMMENT: 16, + + UPDATE_ANY_VIDEO: 17, + UPDATE_ANY_VIDEO_PLAYLIST: 18, + + GET_ANY_LIVE: 19, + SEE_ALL_VIDEOS: 20, + SEE_ALL_COMMENTS: 21, + CHANGE_VIDEO_OWNERSHIP: 22, + + MANAGE_PLUGINS: 23, + + MANAGE_VIDEOS_REDUNDANCIES: 24, + + MANAGE_VIDEO_FILES: 25, + RUN_VIDEO_TRANSCODING: 26, + + MANAGE_VIDEO_IMPORTS: 27, + + MANAGE_REGISTRATIONS: 28, + + MANAGE_RUNNERS: 29 +} as const + +export type UserRightType = typeof UserRight[keyof typeof UserRight] diff --git a/packages/models/src/users/user-role.ts b/packages/models/src/users/user-role.ts new file mode 100644 index 000000000..b496f8153 --- /dev/null +++ b/packages/models/src/users/user-role.ts @@ -0,0 +1,8 @@ +// Always keep this order to prevent security issue since we store these values in the database +export const UserRole = { + ADMINISTRATOR: 0, + MODERATOR: 1, + USER: 2 +} as const + +export type UserRoleType = typeof UserRole[keyof typeof UserRole] diff --git a/shared/models/users/user-scoped-token.ts b/packages/models/src/users/user-scoped-token.ts similarity index 100% rename from shared/models/users/user-scoped-token.ts rename to packages/models/src/users/user-scoped-token.ts diff --git a/shared/models/users/user-update-me.model.ts b/packages/models/src/users/user-update-me.model.ts similarity index 88% rename from shared/models/users/user-update-me.model.ts rename to packages/models/src/users/user-update-me.model.ts index c1d5ffba4..ba9672136 100644 --- a/shared/models/users/user-update-me.model.ts +++ b/packages/models/src/users/user-update-me.model.ts @@ -1,4 +1,4 @@ -import { NSFWPolicyType } from '../videos/nsfw-policy.type' +import { NSFWPolicyType } from '../videos/nsfw-policy.type.js' export interface UserUpdateMe { displayName?: string diff --git a/shared/models/users/user-update.model.ts b/packages/models/src/users/user-update.model.ts similarity index 51% rename from shared/models/users/user-update.model.ts rename to packages/models/src/users/user-update.model.ts index 158738545..283255629 100644 --- a/shared/models/users/user-update.model.ts +++ b/packages/models/src/users/user-update.model.ts @@ -1,5 +1,5 @@ -import { UserRole } from './user-role' -import { UserAdminFlag } from './user-flag.model' +import { UserAdminFlagType } from './user-flag.model.js' +import { UserRoleType } from './user-role.js' export interface UserUpdate { password?: string @@ -7,7 +7,7 @@ export interface UserUpdate { emailVerified?: boolean videoQuota?: number videoQuotaDaily?: number - role?: UserRole - adminFlags?: UserAdminFlag + role?: UserRoleType + adminFlags?: UserAdminFlagType pluginAuth?: string } diff --git a/shared/models/users/user-video-quota.model.ts b/packages/models/src/users/user-video-quota.model.ts similarity index 100% rename from shared/models/users/user-video-quota.model.ts rename to packages/models/src/users/user-video-quota.model.ts diff --git a/shared/models/users/user.model.ts b/packages/models/src/users/user.model.ts similarity index 76% rename from shared/models/users/user.model.ts rename to packages/models/src/users/user.model.ts index 9de4118b4..57b4c1aab 100644 --- a/shared/models/users/user.model.ts +++ b/packages/models/src/users/user.model.ts @@ -1,10 +1,10 @@ -import { Account } from '../actors' -import { VideoChannel } from '../videos/channel/video-channel.model' -import { UserRole } from './user-role' -import { NSFWPolicyType } from '../videos/nsfw-policy.type' -import { UserNotificationSetting } from './user-notification-setting.model' -import { UserAdminFlag } from './user-flag.model' -import { VideoPlaylistType } from '../videos/playlist/video-playlist-type.model' +import { Account } from '../actors/index.js' +import { VideoChannel } from '../videos/channel/video-channel.model.js' +import { NSFWPolicyType } from '../videos/nsfw-policy.type.js' +import { VideoPlaylistType_Type } from '../videos/playlist/video-playlist-type.model.js' +import { UserAdminFlagType } from './user-flag.model.js' +import { UserNotificationSetting } from './user-notification-setting.model.js' +import { UserRoleType } from './user-role.js' export interface User { id: number @@ -16,7 +16,7 @@ export interface User { emailPublic: boolean nsfwPolicy: NSFWPolicyType - adminFlags?: UserAdminFlag + adminFlags?: UserAdminFlagType autoPlayVideo: boolean autoPlayNextVideo: boolean @@ -28,7 +28,7 @@ export interface User { videoLanguages: string[] role: { - id: UserRole + id: UserRoleType label: string } @@ -70,7 +70,7 @@ export interface User { export interface MyUserSpecialPlaylist { id: number name: string - type: VideoPlaylistType + type: VideoPlaylistType_Type } export interface MyUser extends User { diff --git a/packages/models/src/videos/blacklist/index.ts b/packages/models/src/videos/blacklist/index.ts new file mode 100644 index 000000000..5eb36ad48 --- /dev/null +++ b/packages/models/src/videos/blacklist/index.ts @@ -0,0 +1,3 @@ +export * from './video-blacklist.model.js' +export * from './video-blacklist-create.model.js' +export * from './video-blacklist-update.model.js' diff --git a/shared/models/videos/blacklist/video-blacklist-create.model.ts b/packages/models/src/videos/blacklist/video-blacklist-create.model.ts similarity index 100% rename from shared/models/videos/blacklist/video-blacklist-create.model.ts rename to packages/models/src/videos/blacklist/video-blacklist-create.model.ts diff --git a/shared/models/videos/blacklist/video-blacklist-update.model.ts b/packages/models/src/videos/blacklist/video-blacklist-update.model.ts similarity index 100% rename from shared/models/videos/blacklist/video-blacklist-update.model.ts rename to packages/models/src/videos/blacklist/video-blacklist-update.model.ts diff --git a/packages/models/src/videos/blacklist/video-blacklist.model.ts b/packages/models/src/videos/blacklist/video-blacklist.model.ts new file mode 100644 index 000000000..1ca5bbbb7 --- /dev/null +++ b/packages/models/src/videos/blacklist/video-blacklist.model.ts @@ -0,0 +1,20 @@ +import { Video } from '../video.model.js' + +export const VideoBlacklistType = { + MANUAL: 1, + AUTO_BEFORE_PUBLISHED: 2 +} as const + +export type VideoBlacklistType_Type = typeof VideoBlacklistType[keyof typeof VideoBlacklistType] + +export interface VideoBlacklist { + id: number + unfederated: boolean + reason?: string + type: VideoBlacklistType_Type + + video: Video + + createdAt: Date + updatedAt: Date +} diff --git a/packages/models/src/videos/caption/index.ts b/packages/models/src/videos/caption/index.ts new file mode 100644 index 000000000..a175768ce --- /dev/null +++ b/packages/models/src/videos/caption/index.ts @@ -0,0 +1,2 @@ +export * from './video-caption.model.js' +export * from './video-caption-update.model.js' diff --git a/shared/models/videos/caption/video-caption-update.model.ts b/packages/models/src/videos/caption/video-caption-update.model.ts similarity index 100% rename from shared/models/videos/caption/video-caption-update.model.ts rename to packages/models/src/videos/caption/video-caption-update.model.ts diff --git a/shared/models/videos/caption/video-caption.model.ts b/packages/models/src/videos/caption/video-caption.model.ts similarity index 65% rename from shared/models/videos/caption/video-caption.model.ts rename to packages/models/src/videos/caption/video-caption.model.ts index 6d5665006..d6d625ff7 100644 --- a/shared/models/videos/caption/video-caption.model.ts +++ b/packages/models/src/videos/caption/video-caption.model.ts @@ -1,4 +1,4 @@ -import { VideoConstant } from '../video-constant.model' +import { VideoConstant } from '../video-constant.model.js' export interface VideoCaption { language: VideoConstant diff --git a/packages/models/src/videos/change-ownership/index.ts b/packages/models/src/videos/change-ownership/index.ts new file mode 100644 index 000000000..6cf568f4e --- /dev/null +++ b/packages/models/src/videos/change-ownership/index.ts @@ -0,0 +1,3 @@ +export * from './video-change-ownership-accept.model.js' +export * from './video-change-ownership-create.model.js' +export * from './video-change-ownership.model.js' diff --git a/shared/models/videos/change-ownership/video-change-ownership-accept.model.ts b/packages/models/src/videos/change-ownership/video-change-ownership-accept.model.ts similarity index 100% rename from shared/models/videos/change-ownership/video-change-ownership-accept.model.ts rename to packages/models/src/videos/change-ownership/video-change-ownership-accept.model.ts diff --git a/shared/models/videos/change-ownership/video-change-ownership-create.model.ts b/packages/models/src/videos/change-ownership/video-change-ownership-create.model.ts similarity index 100% rename from shared/models/videos/change-ownership/video-change-ownership-create.model.ts rename to packages/models/src/videos/change-ownership/video-change-ownership-create.model.ts diff --git a/packages/models/src/videos/change-ownership/video-change-ownership.model.ts b/packages/models/src/videos/change-ownership/video-change-ownership.model.ts new file mode 100644 index 000000000..353db37f0 --- /dev/null +++ b/packages/models/src/videos/change-ownership/video-change-ownership.model.ts @@ -0,0 +1,19 @@ +import { Account } from '../../actors/index.js' +import { Video } from '../video.model.js' + +export interface VideoChangeOwnership { + id: number + status: VideoChangeOwnershipStatusType + initiatorAccount: Account + nextOwnerAccount: Account + video: Video + createdAt: Date +} + +export const VideoChangeOwnershipStatus = { + WAITING: 'WAITING', + ACCEPTED: 'ACCEPTED', + REFUSED: 'REFUSED' +} as const + +export type VideoChangeOwnershipStatusType = typeof VideoChangeOwnershipStatus[keyof typeof VideoChangeOwnershipStatus] diff --git a/packages/models/src/videos/channel-sync/index.ts b/packages/models/src/videos/channel-sync/index.ts new file mode 100644 index 000000000..206cbe1b6 --- /dev/null +++ b/packages/models/src/videos/channel-sync/index.ts @@ -0,0 +1,3 @@ +export * from './video-channel-sync-state.enum.js' +export * from './video-channel-sync.model.js' +export * from './video-channel-sync-create.model.js' diff --git a/shared/models/videos/channel-sync/video-channel-sync-create.model.ts b/packages/models/src/videos/channel-sync/video-channel-sync-create.model.ts similarity index 100% rename from shared/models/videos/channel-sync/video-channel-sync-create.model.ts rename to packages/models/src/videos/channel-sync/video-channel-sync-create.model.ts diff --git a/packages/models/src/videos/channel-sync/video-channel-sync-state.enum.ts b/packages/models/src/videos/channel-sync/video-channel-sync-state.enum.ts new file mode 100644 index 000000000..047444bbc --- /dev/null +++ b/packages/models/src/videos/channel-sync/video-channel-sync-state.enum.ts @@ -0,0 +1,8 @@ +export const VideoChannelSyncState = { + WAITING_FIRST_RUN: 1, + PROCESSING: 2, + SYNCED: 3, + FAILED: 4 +} as const + +export type VideoChannelSyncStateType = typeof VideoChannelSyncState[keyof typeof VideoChannelSyncState] diff --git a/shared/models/videos/channel-sync/video-channel-sync.model.ts b/packages/models/src/videos/channel-sync/video-channel-sync.model.ts similarity index 52% rename from shared/models/videos/channel-sync/video-channel-sync.model.ts rename to packages/models/src/videos/channel-sync/video-channel-sync.model.ts index 73ac0615b..38ac99668 100644 --- a/shared/models/videos/channel-sync/video-channel-sync.model.ts +++ b/packages/models/src/videos/channel-sync/video-channel-sync.model.ts @@ -1,6 +1,6 @@ -import { VideoChannelSummary } from '../channel/video-channel.model' -import { VideoConstant } from '../video-constant.model' -import { VideoChannelSyncState } from './video-channel-sync-state.enum' +import { VideoChannelSummary } from '../channel/video-channel.model.js' +import { VideoConstant } from '../video-constant.model.js' +import { VideoChannelSyncStateType } from './video-channel-sync-state.enum.js' export interface VideoChannelSync { id: number @@ -9,6 +9,6 @@ export interface VideoChannelSync { createdAt: string channel: VideoChannelSummary - state: VideoConstant + state: VideoConstant lastSyncAt: string } diff --git a/packages/models/src/videos/channel/index.ts b/packages/models/src/videos/channel/index.ts new file mode 100644 index 000000000..3c96e80f0 --- /dev/null +++ b/packages/models/src/videos/channel/index.ts @@ -0,0 +1,4 @@ +export * from './video-channel-create-result.model.js' +export * from './video-channel-create.model.js' +export * from './video-channel-update.model.js' +export * from './video-channel.model.js' diff --git a/shared/models/videos/channel/video-channel-create-result.model.ts b/packages/models/src/videos/channel/video-channel-create-result.model.ts similarity index 100% rename from shared/models/videos/channel/video-channel-create-result.model.ts rename to packages/models/src/videos/channel/video-channel-create-result.model.ts diff --git a/shared/models/videos/channel/video-channel-create.model.ts b/packages/models/src/videos/channel/video-channel-create.model.ts similarity index 100% rename from shared/models/videos/channel/video-channel-create.model.ts rename to packages/models/src/videos/channel/video-channel-create.model.ts diff --git a/shared/models/videos/channel/video-channel-update.model.ts b/packages/models/src/videos/channel/video-channel-update.model.ts similarity index 100% rename from shared/models/videos/channel/video-channel-update.model.ts rename to packages/models/src/videos/channel/video-channel-update.model.ts diff --git a/shared/models/videos/channel/video-channel.model.ts b/packages/models/src/videos/channel/video-channel.model.ts similarity index 82% rename from shared/models/videos/channel/video-channel.model.ts rename to packages/models/src/videos/channel/video-channel.model.ts index ce5fc0e8d..bb10f6da5 100644 --- a/shared/models/videos/channel/video-channel.model.ts +++ b/packages/models/src/videos/channel/video-channel.model.ts @@ -1,5 +1,5 @@ -import { Account, ActorImage } from '../../actors' -import { Actor } from '../../actors/actor.model' +import { Account, ActorImage } from '../../actors/index.js' +import { Actor } from '../../actors/actor.model.js' export type ViewsPerDate = { date: Date diff --git a/packages/models/src/videos/comment/index.ts b/packages/models/src/videos/comment/index.ts new file mode 100644 index 000000000..bd26c652d --- /dev/null +++ b/packages/models/src/videos/comment/index.ts @@ -0,0 +1,2 @@ +export * from './video-comment-create.model.js' +export * from './video-comment.model.js' diff --git a/shared/models/videos/comment/video-comment-create.model.ts b/packages/models/src/videos/comment/video-comment-create.model.ts similarity index 100% rename from shared/models/videos/comment/video-comment-create.model.ts rename to packages/models/src/videos/comment/video-comment-create.model.ts diff --git a/shared/models/videos/comment/video-comment.model.ts b/packages/models/src/videos/comment/video-comment.model.ts similarity index 88% rename from shared/models/videos/comment/video-comment.model.ts rename to packages/models/src/videos/comment/video-comment.model.ts index 737cfe098..e2266545a 100644 --- a/shared/models/videos/comment/video-comment.model.ts +++ b/packages/models/src/videos/comment/video-comment.model.ts @@ -1,5 +1,5 @@ -import { ResultList } from '../../common' -import { Account } from '../../actors' +import { ResultList } from '../../common/index.js' +import { Account } from '../../actors/index.js' export interface VideoComment { id: number diff --git a/packages/models/src/videos/file/index.ts b/packages/models/src/videos/file/index.ts new file mode 100644 index 000000000..ee06f4e20 --- /dev/null +++ b/packages/models/src/videos/file/index.ts @@ -0,0 +1,3 @@ +export * from './video-file-metadata.model.js' +export * from './video-file.model.js' +export * from './video-resolution.enum.js' diff --git a/shared/models/videos/file/video-file-metadata.model.ts b/packages/models/src/videos/file/video-file-metadata.model.ts similarity index 100% rename from shared/models/videos/file/video-file-metadata.model.ts rename to packages/models/src/videos/file/video-file-metadata.model.ts diff --git a/shared/models/videos/file/video-file.model.ts b/packages/models/src/videos/file/video-file.model.ts similarity index 54% rename from shared/models/videos/file/video-file.model.ts rename to packages/models/src/videos/file/video-file.model.ts index 2bbff48eb..2ed1ac4be 100644 --- a/shared/models/videos/file/video-file.model.ts +++ b/packages/models/src/videos/file/video-file.model.ts @@ -1,11 +1,10 @@ -import { VideoConstant } from '../video-constant.model' -import { VideoFileMetadata } from './video-file-metadata.model' -import { VideoResolution } from './video-resolution.enum' +import { VideoConstant } from '../video-constant.model.js' +import { VideoFileMetadata } from './video-file-metadata.model.js' export interface VideoFile { id: number - resolution: VideoConstant + resolution: VideoConstant size: number // Bytes torrentUrl: string diff --git a/packages/models/src/videos/file/video-resolution.enum.ts b/packages/models/src/videos/file/video-resolution.enum.ts new file mode 100644 index 000000000..434e8c36d --- /dev/null +++ b/packages/models/src/videos/file/video-resolution.enum.ts @@ -0,0 +1,13 @@ +export const VideoResolution = { + H_NOVIDEO: 0, + H_144P: 144, + H_240P: 240, + H_360P: 360, + H_480P: 480, + H_720P: 720, + H_1080P: 1080, + H_1440P: 1440, + H_4K: 2160 +} as const + +export type VideoResolutionType = typeof VideoResolution[keyof typeof VideoResolution] diff --git a/packages/models/src/videos/import/index.ts b/packages/models/src/videos/import/index.ts new file mode 100644 index 000000000..6701674c5 --- /dev/null +++ b/packages/models/src/videos/import/index.ts @@ -0,0 +1,4 @@ +export * from './video-import-create.model.js' +export * from './video-import-state.enum.js' +export * from './video-import.model.js' +export * from './videos-import-in-channel-create.model.js' diff --git a/shared/models/videos/import/video-import-create.model.ts b/packages/models/src/videos/import/video-import-create.model.ts similarity index 73% rename from shared/models/videos/import/video-import-create.model.ts rename to packages/models/src/videos/import/video-import-create.model.ts index 425477389..3ec0d22f3 100644 --- a/shared/models/videos/import/video-import-create.model.ts +++ b/packages/models/src/videos/import/video-import-create.model.ts @@ -1,4 +1,4 @@ -import { VideoUpdate } from '../video-update.model' +import { VideoUpdate } from '../video-update.model.js' export interface VideoImportCreate extends VideoUpdate { targetUrl?: string diff --git a/packages/models/src/videos/import/video-import-state.enum.ts b/packages/models/src/videos/import/video-import-state.enum.ts new file mode 100644 index 000000000..475fdbe66 --- /dev/null +++ b/packages/models/src/videos/import/video-import-state.enum.ts @@ -0,0 +1,10 @@ +export const VideoImportState = { + PENDING: 1, + SUCCESS: 2, + FAILED: 3, + REJECTED: 4, + CANCELLED: 5, + PROCESSING: 6 +} as const + +export type VideoImportStateType = typeof VideoImportState[keyof typeof VideoImportState] diff --git a/shared/models/videos/import/video-import.model.ts b/packages/models/src/videos/import/video-import.model.ts similarity index 59% rename from shared/models/videos/import/video-import.model.ts rename to packages/models/src/videos/import/video-import.model.ts index 6aed7a91a..eef23f401 100644 --- a/shared/models/videos/import/video-import.model.ts +++ b/packages/models/src/videos/import/video-import.model.ts @@ -1,6 +1,6 @@ -import { Video } from '../video.model' -import { VideoConstant } from '../video-constant.model' -import { VideoImportState } from './video-import-state.enum' +import { VideoConstant } from '../video-constant.model.js' +import { Video } from '../video.model.js' +import { VideoImportStateType } from './video-import-state.enum.js' export interface VideoImport { id: number @@ -12,7 +12,7 @@ export interface VideoImport { createdAt: string updatedAt: string originallyPublishedAt?: string - state: VideoConstant + state: VideoConstant error?: string video?: Video & { tags: string[] } diff --git a/shared/models/videos/import/videos-import-in-channel-create.model.ts b/packages/models/src/videos/import/videos-import-in-channel-create.model.ts similarity index 100% rename from shared/models/videos/import/videos-import-in-channel-create.model.ts rename to packages/models/src/videos/import/videos-import-in-channel-create.model.ts diff --git a/packages/models/src/videos/index.ts b/packages/models/src/videos/index.ts new file mode 100644 index 000000000..d131212c9 --- /dev/null +++ b/packages/models/src/videos/index.ts @@ -0,0 +1,43 @@ +export * from './blacklist/index.js' +export * from './caption/index.js' +export * from './change-ownership/index.js' +export * from './channel/index.js' +export * from './comment/index.js' +export * from './studio/index.js' +export * from './live/index.js' +export * from './file/index.js' +export * from './import/index.js' +export * from './playlist/index.js' +export * from './rate/index.js' +export * from './stats/index.js' +export * from './transcoding/index.js' +export * from './channel-sync/index.js' + +export * from './nsfw-policy.type.js' + +export * from './storyboard.model.js' +export * from './thumbnail.type.js' + +export * from './video-constant.model.js' +export * from './video-create.model.js' + +export * from './video-privacy.enum.js' +export * from './video-include.enum.js' +export * from './video-rate.type.js' + +export * from './video-schedule-update.model.js' +export * from './video-sort-field.type.js' +export * from './video-state.enum.js' +export * from './video-storage.enum.js' +export * from './video-source.model.js' + +export * from './video-streaming-playlist.model.js' +export * from './video-streaming-playlist.type.js' + +export * from './video-token.model.js' + +export * from './video-update.model.js' +export * from './video-view.model.js' +export * from './video.model.js' +export * from './video-create-result.model.js' +export * from './video-password.model.js' diff --git a/packages/models/src/videos/live/index.ts b/packages/models/src/videos/live/index.ts new file mode 100644 index 000000000..1763eb574 --- /dev/null +++ b/packages/models/src/videos/live/index.ts @@ -0,0 +1,8 @@ +export * from './live-video-create.model.js' +export * from './live-video-error.enum.js' +export * from './live-video-event-payload.model.js' +export * from './live-video-event.type.js' +export * from './live-video-latency-mode.enum.js' +export * from './live-video-session.model.js' +export * from './live-video-update.model.js' +export * from './live-video.model.js' diff --git a/packages/models/src/videos/live/live-video-create.model.ts b/packages/models/src/videos/live/live-video-create.model.ts new file mode 100644 index 000000000..e4e39518c --- /dev/null +++ b/packages/models/src/videos/live/live-video-create.model.ts @@ -0,0 +1,11 @@ +import { VideoCreate } from '../video-create.model.js' +import { VideoPrivacyType } from '../video-privacy.enum.js' +import { LiveVideoLatencyModeType } from './live-video-latency-mode.enum.js' + +export interface LiveVideoCreate extends VideoCreate { + permanentLive?: boolean + latencyMode?: LiveVideoLatencyModeType + + saveReplay?: boolean + replaySettings?: { privacy: VideoPrivacyType } +} diff --git a/packages/models/src/videos/live/live-video-error.enum.ts b/packages/models/src/videos/live/live-video-error.enum.ts new file mode 100644 index 000000000..cd92a1cff --- /dev/null +++ b/packages/models/src/videos/live/live-video-error.enum.ts @@ -0,0 +1,11 @@ +export const LiveVideoError = { + BAD_SOCKET_HEALTH: 1, + DURATION_EXCEEDED: 2, + QUOTA_EXCEEDED: 3, + FFMPEG_ERROR: 4, + BLACKLISTED: 5, + RUNNER_JOB_ERROR: 6, + RUNNER_JOB_CANCEL: 7 +} as const + +export type LiveVideoErrorType = typeof LiveVideoError[keyof typeof LiveVideoError] diff --git a/packages/models/src/videos/live/live-video-event-payload.model.ts b/packages/models/src/videos/live/live-video-event-payload.model.ts new file mode 100644 index 000000000..507f8d153 --- /dev/null +++ b/packages/models/src/videos/live/live-video-event-payload.model.ts @@ -0,0 +1,7 @@ +import { VideoStateType } from '../video-state.enum.js' + +export interface LiveVideoEventPayload { + state?: VideoStateType + + viewers?: number +} diff --git a/shared/models/videos/live/live-video-event.type.ts b/packages/models/src/videos/live/live-video-event.type.ts similarity index 100% rename from shared/models/videos/live/live-video-event.type.ts rename to packages/models/src/videos/live/live-video-event.type.ts diff --git a/packages/models/src/videos/live/live-video-latency-mode.enum.ts b/packages/models/src/videos/live/live-video-latency-mode.enum.ts new file mode 100644 index 000000000..6fd8fe8e9 --- /dev/null +++ b/packages/models/src/videos/live/live-video-latency-mode.enum.ts @@ -0,0 +1,7 @@ +export const LiveVideoLatencyMode = { + DEFAULT: 1, + HIGH_LATENCY: 2, + SMALL_LATENCY: 3 +} as const + +export type LiveVideoLatencyModeType = typeof LiveVideoLatencyMode[keyof typeof LiveVideoLatencyMode] diff --git a/shared/models/videos/live/live-video-session.model.ts b/packages/models/src/videos/live/live-video-session.model.ts similarity index 52% rename from shared/models/videos/live/live-video-session.model.ts rename to packages/models/src/videos/live/live-video-session.model.ts index 888c20a8a..8d45bc86a 100644 --- a/shared/models/videos/live/live-video-session.model.ts +++ b/packages/models/src/videos/live/live-video-session.model.ts @@ -1,5 +1,5 @@ -import { VideoPrivacy } from '../video-privacy.enum' -import { LiveVideoError } from './live-video-error.enum' +import { VideoPrivacyType } from '../video-privacy.enum.js' +import { LiveVideoErrorType } from './live-video-error.enum.js' export interface LiveVideoSession { id: number @@ -7,12 +7,12 @@ export interface LiveVideoSession { startDate: string endDate: string - error: LiveVideoError + error: LiveVideoErrorType saveReplay: boolean endingProcessed: boolean - replaySettings?: { privacy: VideoPrivacy } + replaySettings?: { privacy: VideoPrivacyType } replayVideo: { id: number diff --git a/packages/models/src/videos/live/live-video-update.model.ts b/packages/models/src/videos/live/live-video-update.model.ts new file mode 100644 index 000000000..b4d91e447 --- /dev/null +++ b/packages/models/src/videos/live/live-video-update.model.ts @@ -0,0 +1,9 @@ +import { VideoPrivacyType } from '../video-privacy.enum.js' +import { LiveVideoLatencyModeType } from './live-video-latency-mode.enum.js' + +export interface LiveVideoUpdate { + permanentLive?: boolean + saveReplay?: boolean + replaySettings?: { privacy: VideoPrivacyType } + latencyMode?: LiveVideoLatencyModeType +} diff --git a/packages/models/src/videos/live/live-video.model.ts b/packages/models/src/videos/live/live-video.model.ts new file mode 100644 index 000000000..3e91f677c --- /dev/null +++ b/packages/models/src/videos/live/live-video.model.ts @@ -0,0 +1,14 @@ +import { VideoPrivacyType } from '../video-privacy.enum.js' +import { LiveVideoLatencyModeType } from './live-video-latency-mode.enum.js' + +export interface LiveVideo { + // If owner + rtmpUrl?: string + rtmpsUrl?: string + streamKey?: string + + saveReplay: boolean + replaySettings?: { privacy: VideoPrivacyType } + permanentLive: boolean + latencyMode: LiveVideoLatencyModeType +} diff --git a/shared/models/videos/nsfw-policy.type.ts b/packages/models/src/videos/nsfw-policy.type.ts similarity index 100% rename from shared/models/videos/nsfw-policy.type.ts rename to packages/models/src/videos/nsfw-policy.type.ts diff --git a/packages/models/src/videos/playlist/index.ts b/packages/models/src/videos/playlist/index.ts new file mode 100644 index 000000000..0e139657a --- /dev/null +++ b/packages/models/src/videos/playlist/index.ts @@ -0,0 +1,12 @@ +export * from './video-exist-in-playlist.model.js' +export * from './video-playlist-create-result.model.js' +export * from './video-playlist-create.model.js' +export * from './video-playlist-element-create-result.model.js' +export * from './video-playlist-element-create.model.js' +export * from './video-playlist-element-update.model.js' +export * from './video-playlist-element.model.js' +export * from './video-playlist-privacy.model.js' +export * from './video-playlist-reorder.model.js' +export * from './video-playlist-type.model.js' +export * from './video-playlist-update.model.js' +export * from './video-playlist.model.js' diff --git a/shared/models/videos/playlist/video-exist-in-playlist.model.ts b/packages/models/src/videos/playlist/video-exist-in-playlist.model.ts similarity index 100% rename from shared/models/videos/playlist/video-exist-in-playlist.model.ts rename to packages/models/src/videos/playlist/video-exist-in-playlist.model.ts diff --git a/shared/models/videos/playlist/video-playlist-create-result.model.ts b/packages/models/src/videos/playlist/video-playlist-create-result.model.ts similarity index 100% rename from shared/models/videos/playlist/video-playlist-create-result.model.ts rename to packages/models/src/videos/playlist/video-playlist-create-result.model.ts diff --git a/shared/models/videos/playlist/video-playlist-create.model.ts b/packages/models/src/videos/playlist/video-playlist-create.model.ts similarity index 54% rename from shared/models/videos/playlist/video-playlist-create.model.ts rename to packages/models/src/videos/playlist/video-playlist-create.model.ts index 67a33fa35..f9dd1e0d1 100644 --- a/shared/models/videos/playlist/video-playlist-create.model.ts +++ b/packages/models/src/videos/playlist/video-playlist-create.model.ts @@ -1,8 +1,8 @@ -import { VideoPlaylistPrivacy } from './video-playlist-privacy.model' +import { VideoPlaylistPrivacyType } from './video-playlist-privacy.model.js' export interface VideoPlaylistCreate { displayName: string - privacy: VideoPlaylistPrivacy + privacy: VideoPlaylistPrivacyType description?: string videoChannelId?: number diff --git a/shared/models/videos/playlist/video-playlist-element-create-result.model.ts b/packages/models/src/videos/playlist/video-playlist-element-create-result.model.ts similarity index 100% rename from shared/models/videos/playlist/video-playlist-element-create-result.model.ts rename to packages/models/src/videos/playlist/video-playlist-element-create-result.model.ts diff --git a/shared/models/videos/playlist/video-playlist-element-create.model.ts b/packages/models/src/videos/playlist/video-playlist-element-create.model.ts similarity index 100% rename from shared/models/videos/playlist/video-playlist-element-create.model.ts rename to packages/models/src/videos/playlist/video-playlist-element-create.model.ts diff --git a/shared/models/videos/playlist/video-playlist-element-update.model.ts b/packages/models/src/videos/playlist/video-playlist-element-update.model.ts similarity index 100% rename from shared/models/videos/playlist/video-playlist-element-update.model.ts rename to packages/models/src/videos/playlist/video-playlist-element-update.model.ts diff --git a/packages/models/src/videos/playlist/video-playlist-element.model.ts b/packages/models/src/videos/playlist/video-playlist-element.model.ts new file mode 100644 index 000000000..a4711f919 --- /dev/null +++ b/packages/models/src/videos/playlist/video-playlist-element.model.ts @@ -0,0 +1,21 @@ +import { Video } from '../video.model.js' + +export const VideoPlaylistElementType = { + REGULAR: 0, + DELETED: 1, + PRIVATE: 2, + UNAVAILABLE: 3 // Blacklisted, blocked by the user/instance, NSFW... +} as const + +export type VideoPlaylistElementType_Type = typeof VideoPlaylistElementType[keyof typeof VideoPlaylistElementType] + +export interface VideoPlaylistElement { + id: number + position: number + startTimestamp: number + stopTimestamp: number + + type: VideoPlaylistElementType_Type + + video?: Video +} diff --git a/packages/models/src/videos/playlist/video-playlist-privacy.model.ts b/packages/models/src/videos/playlist/video-playlist-privacy.model.ts new file mode 100644 index 000000000..23f6a1a16 --- /dev/null +++ b/packages/models/src/videos/playlist/video-playlist-privacy.model.ts @@ -0,0 +1,7 @@ +export const VideoPlaylistPrivacy = { + PUBLIC: 1, + UNLISTED: 2, + PRIVATE: 3 +} as const + +export type VideoPlaylistPrivacyType = typeof VideoPlaylistPrivacy[keyof typeof VideoPlaylistPrivacy] diff --git a/shared/models/videos/playlist/video-playlist-reorder.model.ts b/packages/models/src/videos/playlist/video-playlist-reorder.model.ts similarity index 100% rename from shared/models/videos/playlist/video-playlist-reorder.model.ts rename to packages/models/src/videos/playlist/video-playlist-reorder.model.ts diff --git a/packages/models/src/videos/playlist/video-playlist-type.model.ts b/packages/models/src/videos/playlist/video-playlist-type.model.ts new file mode 100644 index 000000000..183439f98 --- /dev/null +++ b/packages/models/src/videos/playlist/video-playlist-type.model.ts @@ -0,0 +1,6 @@ +export const VideoPlaylistType = { + REGULAR: 1, + WATCH_LATER: 2 +} as const + +export type VideoPlaylistType_Type = typeof VideoPlaylistType[keyof typeof VideoPlaylistType] diff --git a/shared/models/videos/playlist/video-playlist-update.model.ts b/packages/models/src/videos/playlist/video-playlist-update.model.ts similarity index 54% rename from shared/models/videos/playlist/video-playlist-update.model.ts rename to packages/models/src/videos/playlist/video-playlist-update.model.ts index a6a3f74d9..ed536367e 100644 --- a/shared/models/videos/playlist/video-playlist-update.model.ts +++ b/packages/models/src/videos/playlist/video-playlist-update.model.ts @@ -1,8 +1,8 @@ -import { VideoPlaylistPrivacy } from './video-playlist-privacy.model' +import { VideoPlaylistPrivacyType } from './video-playlist-privacy.model.js' export interface VideoPlaylistUpdate { displayName?: string - privacy?: VideoPlaylistPrivacy + privacy?: VideoPlaylistPrivacyType description?: string videoChannelId?: number diff --git a/packages/models/src/videos/playlist/video-playlist.model.ts b/packages/models/src/videos/playlist/video-playlist.model.ts new file mode 100644 index 000000000..4261aac25 --- /dev/null +++ b/packages/models/src/videos/playlist/video-playlist.model.ts @@ -0,0 +1,35 @@ +import { AccountSummary } from '../../actors/index.js' +import { VideoChannelSummary } from '../channel/index.js' +import { VideoConstant } from '../video-constant.model.js' +import { VideoPlaylistPrivacyType } from './video-playlist-privacy.model.js' +import { VideoPlaylistType_Type } from './video-playlist-type.model.js' + +export interface VideoPlaylist { + id: number + uuid: string + shortUUID: string + + isLocal: boolean + + url: string + + displayName: string + description: string + privacy: VideoConstant + + thumbnailPath: string + thumbnailUrl?: string + + videosLength: number + + type: VideoConstant + + embedPath: string + embedUrl?: string + + createdAt: Date | string + updatedAt: Date | string + + ownerAccount: AccountSummary + videoChannel?: VideoChannelSummary +} diff --git a/packages/models/src/videos/rate/account-video-rate.model.ts b/packages/models/src/videos/rate/account-video-rate.model.ts new file mode 100644 index 000000000..d19ccdbdd --- /dev/null +++ b/packages/models/src/videos/rate/account-video-rate.model.ts @@ -0,0 +1,7 @@ +import { UserVideoRateType } from './user-video-rate.type.js' +import { Video } from '../video.model.js' + +export interface AccountVideoRate { + video: Video + rating: UserVideoRateType +} diff --git a/packages/models/src/videos/rate/index.ts b/packages/models/src/videos/rate/index.ts new file mode 100644 index 000000000..ecbe3523d --- /dev/null +++ b/packages/models/src/videos/rate/index.ts @@ -0,0 +1,5 @@ + +export * from './user-video-rate-update.model.js' +export * from './user-video-rate.model.js' +export * from './account-video-rate.model.js' +export * from './user-video-rate.type.js' diff --git a/shared/models/videos/rate/user-video-rate-update.model.ts b/packages/models/src/videos/rate/user-video-rate-update.model.ts similarity index 53% rename from shared/models/videos/rate/user-video-rate-update.model.ts rename to packages/models/src/videos/rate/user-video-rate-update.model.ts index 85e89271a..8ee1e78ca 100644 --- a/shared/models/videos/rate/user-video-rate-update.model.ts +++ b/packages/models/src/videos/rate/user-video-rate-update.model.ts @@ -1,4 +1,4 @@ -import { UserVideoRateType } from './user-video-rate.type' +import { UserVideoRateType } from './user-video-rate.type.js' export interface UserVideoRateUpdate { rating: UserVideoRateType diff --git a/shared/models/videos/rate/user-video-rate.model.ts b/packages/models/src/videos/rate/user-video-rate.model.ts similarity index 56% rename from shared/models/videos/rate/user-video-rate.model.ts rename to packages/models/src/videos/rate/user-video-rate.model.ts index d39a1c3d5..344cf9a68 100644 --- a/shared/models/videos/rate/user-video-rate.model.ts +++ b/packages/models/src/videos/rate/user-video-rate.model.ts @@ -1,4 +1,4 @@ -import { UserVideoRateType } from './user-video-rate.type' +import { UserVideoRateType } from './user-video-rate.type.js' export interface UserVideoRate { videoId: number diff --git a/shared/models/videos/rate/user-video-rate.type.ts b/packages/models/src/videos/rate/user-video-rate.type.ts similarity index 100% rename from shared/models/videos/rate/user-video-rate.type.ts rename to packages/models/src/videos/rate/user-video-rate.type.ts diff --git a/packages/models/src/videos/stats/index.ts b/packages/models/src/videos/stats/index.ts new file mode 100644 index 000000000..7187cac26 --- /dev/null +++ b/packages/models/src/videos/stats/index.ts @@ -0,0 +1,6 @@ +export * from './video-stats-overall-query.model.js' +export * from './video-stats-overall.model.js' +export * from './video-stats-retention.model.js' +export * from './video-stats-timeserie-query.model.js' +export * from './video-stats-timeserie-metric.type.js' +export * from './video-stats-timeserie.model.js' diff --git a/shared/models/videos/stats/video-stats-overall-query.model.ts b/packages/models/src/videos/stats/video-stats-overall-query.model.ts similarity index 100% rename from shared/models/videos/stats/video-stats-overall-query.model.ts rename to packages/models/src/videos/stats/video-stats-overall-query.model.ts diff --git a/shared/models/videos/stats/video-stats-overall.model.ts b/packages/models/src/videos/stats/video-stats-overall.model.ts similarity index 100% rename from shared/models/videos/stats/video-stats-overall.model.ts rename to packages/models/src/videos/stats/video-stats-overall.model.ts diff --git a/shared/models/videos/stats/video-stats-retention.model.ts b/packages/models/src/videos/stats/video-stats-retention.model.ts similarity index 100% rename from shared/models/videos/stats/video-stats-retention.model.ts rename to packages/models/src/videos/stats/video-stats-retention.model.ts diff --git a/shared/models/videos/stats/video-stats-timeserie-metric.type.ts b/packages/models/src/videos/stats/video-stats-timeserie-metric.type.ts similarity index 100% rename from shared/models/videos/stats/video-stats-timeserie-metric.type.ts rename to packages/models/src/videos/stats/video-stats-timeserie-metric.type.ts diff --git a/shared/models/videos/stats/video-stats-timeserie-query.model.ts b/packages/models/src/videos/stats/video-stats-timeserie-query.model.ts similarity index 100% rename from shared/models/videos/stats/video-stats-timeserie-query.model.ts rename to packages/models/src/videos/stats/video-stats-timeserie-query.model.ts diff --git a/shared/models/videos/stats/video-stats-timeserie.model.ts b/packages/models/src/videos/stats/video-stats-timeserie.model.ts similarity index 100% rename from shared/models/videos/stats/video-stats-timeserie.model.ts rename to packages/models/src/videos/stats/video-stats-timeserie.model.ts diff --git a/shared/models/videos/storyboard.model.ts b/packages/models/src/videos/storyboard.model.ts similarity index 100% rename from shared/models/videos/storyboard.model.ts rename to packages/models/src/videos/storyboard.model.ts diff --git a/packages/models/src/videos/studio/index.ts b/packages/models/src/videos/studio/index.ts new file mode 100644 index 000000000..0d8ad3227 --- /dev/null +++ b/packages/models/src/videos/studio/index.ts @@ -0,0 +1 @@ +export * from './video-studio-create-edit.model.js' diff --git a/shared/models/videos/studio/video-studio-create-edit.model.ts b/packages/models/src/videos/studio/video-studio-create-edit.model.ts similarity index 100% rename from shared/models/videos/studio/video-studio-create-edit.model.ts rename to packages/models/src/videos/studio/video-studio-create-edit.model.ts diff --git a/packages/models/src/videos/thumbnail.type.ts b/packages/models/src/videos/thumbnail.type.ts new file mode 100644 index 000000000..0cb7483ec --- /dev/null +++ b/packages/models/src/videos/thumbnail.type.ts @@ -0,0 +1,6 @@ +export const ThumbnailType = { + MINIATURE: 1, + PREVIEW: 2 +} as const + +export type ThumbnailType_Type = typeof ThumbnailType[keyof typeof ThumbnailType] diff --git a/packages/models/src/videos/transcoding/index.ts b/packages/models/src/videos/transcoding/index.ts new file mode 100644 index 000000000..e1d931bd5 --- /dev/null +++ b/packages/models/src/videos/transcoding/index.ts @@ -0,0 +1,3 @@ +export * from './video-transcoding-create.model.js' +export * from './video-transcoding-fps.model.js' +export * from './video-transcoding.model.js' diff --git a/shared/models/videos/transcoding/video-transcoding-create.model.ts b/packages/models/src/videos/transcoding/video-transcoding-create.model.ts similarity index 100% rename from shared/models/videos/transcoding/video-transcoding-create.model.ts rename to packages/models/src/videos/transcoding/video-transcoding-create.model.ts diff --git a/shared/models/videos/transcoding/video-transcoding-fps.model.ts b/packages/models/src/videos/transcoding/video-transcoding-fps.model.ts similarity index 100% rename from shared/models/videos/transcoding/video-transcoding-fps.model.ts rename to packages/models/src/videos/transcoding/video-transcoding-fps.model.ts diff --git a/shared/models/videos/transcoding/video-transcoding.model.ts b/packages/models/src/videos/transcoding/video-transcoding.model.ts similarity index 92% rename from shared/models/videos/transcoding/video-transcoding.model.ts rename to packages/models/src/videos/transcoding/video-transcoding.model.ts index 91eacf8dc..e2c2a56e5 100644 --- a/shared/models/videos/transcoding/video-transcoding.model.ts +++ b/packages/models/src/videos/transcoding/video-transcoding.model.ts @@ -1,11 +1,9 @@ -import { VideoResolution } from '../file/video-resolution.enum' - // Types used by plugins and ffmpeg-utils export type EncoderOptionsBuilderParams = { input: string - resolution: VideoResolution + resolution: number // If PeerTube applies a filter, transcoding profile must not copy input stream canCopyAudio: boolean diff --git a/shared/models/videos/video-constant.model.ts b/packages/models/src/videos/video-constant.model.ts similarity index 100% rename from shared/models/videos/video-constant.model.ts rename to packages/models/src/videos/video-constant.model.ts diff --git a/shared/models/videos/video-create-result.model.ts b/packages/models/src/videos/video-create-result.model.ts similarity index 100% rename from shared/models/videos/video-create-result.model.ts rename to packages/models/src/videos/video-create-result.model.ts diff --git a/shared/models/videos/video-create.model.ts b/packages/models/src/videos/video-create.model.ts similarity index 84% rename from shared/models/videos/video-create.model.ts rename to packages/models/src/videos/video-create.model.ts index 7a34b5afe..472201211 100644 --- a/shared/models/videos/video-create.model.ts +++ b/packages/models/src/videos/video-create.model.ts @@ -1,5 +1,5 @@ -import { VideoPrivacy } from './video-privacy.enum' -import { VideoScheduleUpdate } from './video-schedule-update.model' +import { VideoPrivacyType } from './video-privacy.enum.js' +import { VideoScheduleUpdate } from './video-schedule-update.model.js' export interface VideoCreate { name: string @@ -15,7 +15,7 @@ export interface VideoCreate { tags?: string[] commentsEnabled?: boolean downloadEnabled?: boolean - privacy: VideoPrivacy + privacy: VideoPrivacyType scheduleUpdate?: VideoScheduleUpdate originallyPublishedAt?: Date | string videoPasswords?: string[] diff --git a/packages/models/src/videos/video-include.enum.ts b/packages/models/src/videos/video-include.enum.ts new file mode 100644 index 000000000..7d88a6890 --- /dev/null +++ b/packages/models/src/videos/video-include.enum.ts @@ -0,0 +1,10 @@ +export const VideoInclude = { + NONE: 0, + NOT_PUBLISHED_STATE: 1 << 0, + BLACKLISTED: 1 << 1, + BLOCKED_OWNER: 1 << 2, + FILES: 1 << 3, + CAPTIONS: 1 << 4 +} as const + +export type VideoIncludeType = typeof VideoInclude[keyof typeof VideoInclude] diff --git a/shared/models/videos/video-password.model.ts b/packages/models/src/videos/video-password.model.ts similarity index 100% rename from shared/models/videos/video-password.model.ts rename to packages/models/src/videos/video-password.model.ts diff --git a/packages/models/src/videos/video-privacy.enum.ts b/packages/models/src/videos/video-privacy.enum.ts new file mode 100644 index 000000000..cbcc91b3f --- /dev/null +++ b/packages/models/src/videos/video-privacy.enum.ts @@ -0,0 +1,9 @@ +export const VideoPrivacy = { + PUBLIC: 1, + UNLISTED: 2, + PRIVATE: 3, + INTERNAL: 4, + PASSWORD_PROTECTED: 5 +} as const + +export type VideoPrivacyType = typeof VideoPrivacy[keyof typeof VideoPrivacy] diff --git a/shared/models/videos/video-rate.type.ts b/packages/models/src/videos/video-rate.type.ts similarity index 100% rename from shared/models/videos/video-rate.type.ts rename to packages/models/src/videos/video-rate.type.ts diff --git a/packages/models/src/videos/video-schedule-update.model.ts b/packages/models/src/videos/video-schedule-update.model.ts new file mode 100644 index 000000000..2e6a5551d --- /dev/null +++ b/packages/models/src/videos/video-schedule-update.model.ts @@ -0,0 +1,7 @@ +import { VideoPrivacy } from './video-privacy.enum.js' + +export interface VideoScheduleUpdate { + updateAt: Date | string + // Cannot schedule an update to PRIVATE + privacy?: typeof VideoPrivacy.PUBLIC | typeof VideoPrivacy.UNLISTED | typeof VideoPrivacy.INTERNAL +} diff --git a/shared/models/videos/video-sort-field.type.ts b/packages/models/src/videos/video-sort-field.type.ts similarity index 100% rename from shared/models/videos/video-sort-field.type.ts rename to packages/models/src/videos/video-sort-field.type.ts diff --git a/shared/models/videos/video-source.ts b/packages/models/src/videos/video-source.model.ts similarity index 100% rename from shared/models/videos/video-source.ts rename to packages/models/src/videos/video-source.model.ts diff --git a/packages/models/src/videos/video-state.enum.ts b/packages/models/src/videos/video-state.enum.ts new file mode 100644 index 000000000..ae7c6a0c4 --- /dev/null +++ b/packages/models/src/videos/video-state.enum.ts @@ -0,0 +1,13 @@ +export const VideoState = { + PUBLISHED: 1, + TO_TRANSCODE: 2, + TO_IMPORT: 3, + WAITING_FOR_LIVE: 4, + LIVE_ENDED: 5, + TO_MOVE_TO_EXTERNAL_STORAGE: 6, + TRANSCODING_FAILED: 7, + TO_MOVE_TO_EXTERNAL_STORAGE_FAILED: 8, + TO_EDIT: 9 +} as const + +export type VideoStateType = typeof VideoState[keyof typeof VideoState] diff --git a/packages/models/src/videos/video-storage.enum.ts b/packages/models/src/videos/video-storage.enum.ts new file mode 100644 index 000000000..de5c92e0d --- /dev/null +++ b/packages/models/src/videos/video-storage.enum.ts @@ -0,0 +1,6 @@ +export const VideoStorage = { + FILE_SYSTEM: 0, + OBJECT_STORAGE: 1 +} as const + +export type VideoStorageType = typeof VideoStorage[keyof typeof VideoStorage] diff --git a/shared/models/videos/video-streaming-playlist.model.ts b/packages/models/src/videos/video-streaming-playlist.model.ts similarity index 50% rename from shared/models/videos/video-streaming-playlist.model.ts rename to packages/models/src/videos/video-streaming-playlist.model.ts index 11919a4ee..80aa70e3c 100644 --- a/shared/models/videos/video-streaming-playlist.model.ts +++ b/packages/models/src/videos/video-streaming-playlist.model.ts @@ -1,9 +1,9 @@ -import { VideoStreamingPlaylistType } from './video-streaming-playlist.type' -import { VideoFile } from './file' +import { VideoFile } from './file/index.js' +import { VideoStreamingPlaylistType_Type } from './video-streaming-playlist.type.js' export interface VideoStreamingPlaylist { id: number - type: VideoStreamingPlaylistType + type: VideoStreamingPlaylistType_Type playlistUrl: string segmentsSha256Url: string diff --git a/packages/models/src/videos/video-streaming-playlist.type.ts b/packages/models/src/videos/video-streaming-playlist.type.ts new file mode 100644 index 000000000..07a2c207f --- /dev/null +++ b/packages/models/src/videos/video-streaming-playlist.type.ts @@ -0,0 +1,5 @@ +export const VideoStreamingPlaylistType = { + HLS: 1 +} as const + +export type VideoStreamingPlaylistType_Type = typeof VideoStreamingPlaylistType[keyof typeof VideoStreamingPlaylistType] diff --git a/shared/models/videos/video-token.model.ts b/packages/models/src/videos/video-token.model.ts similarity index 100% rename from shared/models/videos/video-token.model.ts rename to packages/models/src/videos/video-token.model.ts diff --git a/shared/models/videos/video-update.model.ts b/packages/models/src/videos/video-update.model.ts similarity index 84% rename from shared/models/videos/video-update.model.ts rename to packages/models/src/videos/video-update.model.ts index 43537b5af..8af298160 100644 --- a/shared/models/videos/video-update.model.ts +++ b/packages/models/src/videos/video-update.model.ts @@ -1,5 +1,5 @@ -import { VideoPrivacy } from './video-privacy.enum' -import { VideoScheduleUpdate } from './video-schedule-update.model' +import { VideoPrivacyType } from './video-privacy.enum.js' +import { VideoScheduleUpdate } from './video-schedule-update.model.js' export interface VideoUpdate { name?: string @@ -8,7 +8,7 @@ export interface VideoUpdate { language?: string description?: string support?: string - privacy?: VideoPrivacy + privacy?: VideoPrivacyType tags?: string[] commentsEnabled?: boolean downloadEnabled?: boolean diff --git a/shared/models/videos/video-view.model.ts b/packages/models/src/videos/video-view.model.ts similarity index 100% rename from shared/models/videos/video-view.model.ts rename to packages/models/src/videos/video-view.model.ts diff --git a/shared/models/videos/video.model.ts b/packages/models/src/videos/video.model.ts similarity index 80% rename from shared/models/videos/video.model.ts rename to packages/models/src/videos/video.model.ts index 7e5930067..a750e220d 100644 --- a/shared/models/videos/video.model.ts +++ b/packages/models/src/videos/video.model.ts @@ -1,11 +1,11 @@ -import { Account, AccountSummary } from '../actors' -import { VideoChannel, VideoChannelSummary } from './channel/video-channel.model' -import { VideoFile } from './file' -import { VideoConstant } from './video-constant.model' -import { VideoPrivacy } from './video-privacy.enum' -import { VideoScheduleUpdate } from './video-schedule-update.model' -import { VideoState } from './video-state.enum' -import { VideoStreamingPlaylist } from './video-streaming-playlist.model' +import { Account, AccountSummary } from '../actors/index.js' +import { VideoChannel, VideoChannelSummary } from './channel/video-channel.model.js' +import { VideoFile } from './file/index.js' +import { VideoConstant } from './video-constant.model.js' +import { VideoPrivacyType } from './video-privacy.enum.js' +import { VideoScheduleUpdate } from './video-schedule-update.model.js' +import { VideoStateType } from './video-state.enum.js' +import { VideoStreamingPlaylist } from './video-streaming-playlist.model.js' export interface Video extends Partial { id: number @@ -19,7 +19,7 @@ export interface Video extends Partial { category: VideoConstant licence: VideoConstant language: VideoConstant - privacy: VideoConstant + privacy: VideoConstant // Deprecated in 5.0 in favour of truncatedDescription description: string @@ -62,7 +62,7 @@ export interface Video extends Partial { // Not included by default, needs query params export interface VideoAdditionalAttributes { waitTranscoding: boolean - state: VideoConstant + state: VideoConstant scheduledUpdate: VideoScheduleUpdate blacklisted: boolean @@ -88,7 +88,7 @@ export interface VideoDetails extends Video { // Not optional in details (unlike in parent Video) waitTranscoding: boolean - state: VideoConstant + state: VideoConstant trackerUrls: string[] diff --git a/packages/models/tsconfig.json b/packages/models/tsconfig.json new file mode 100644 index 000000000..58fa2330b --- /dev/null +++ b/packages/models/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./dist", + "rootDir": "src", + "tsBuildInfoFile": "./dist/.tsbuildinfo" + } +} diff --git a/shared/tsconfig.types.json b/packages/models/tsconfig.types.json similarity index 51% rename from shared/tsconfig.types.json rename to packages/models/tsconfig.types.json index 6acfc05e1..997161c21 100644 --- a/shared/tsconfig.types.json +++ b/packages/models/tsconfig.types.json @@ -1,12 +1,10 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../packages/types/dist/shared", + "outDir": "../types-generator/dist/peertube-models", + "tsBuildInfoFile": "../types-generator/dist/peertube-models/.tsbuildinfo", "stripInternal": true, "removeComments": false, "emitDeclarationOnly": true - }, - "exclude": [ - "server-commands/" - ] + } } diff --git a/packages/node-utils/package.json b/packages/node-utils/package.json new file mode 100644 index 000000000..cd7d8ac80 --- /dev/null +++ b/packages/node-utils/package.json @@ -0,0 +1,19 @@ +{ + "name": "@peertube/peertube-node-utils", + "private": true, + "version": "0.0.0", + "main": "dist/index.js", + "files": [ "dist" ], + "exports": { + "types": "./dist/index.d.ts", + "peertube:tsx": "./src/index.ts", + "default": "./dist/index.js" + }, + "type": "module", + "devDependencies": {}, + "scripts": { + "build": "tsc", + "watch": "tsc -w" + }, + "dependencies": {} +} diff --git a/shared/extra-utils/crypto.ts b/packages/node-utils/src/crypto.ts similarity index 100% rename from shared/extra-utils/crypto.ts rename to packages/node-utils/src/crypto.ts diff --git a/shared/core-utils/common/env.ts b/packages/node-utils/src/env.ts similarity index 58% rename from shared/core-utils/common/env.ts rename to packages/node-utils/src/env.ts index 973f895d4..1a28f509e 100644 --- a/shared/core-utils/common/env.ts +++ b/packages/node-utils/src/env.ts @@ -1,12 +1,12 @@ -function parallelTests () { +export function parallelTests () { return process.env.MOCHA_PARALLEL === 'true' } -function isGithubCI () { +export function isGithubCI () { return !!process.env.GITHUB_WORKSPACE } -function areHttpImportTestsDisabled () { +export function areHttpImportTestsDisabled () { const disabled = process.env.DISABLE_HTTP_IMPORT_TESTS === 'true' if (disabled) console.log('DISABLE_HTTP_IMPORT_TESTS env set to "true" so import tests are disabled') @@ -14,7 +14,7 @@ function areHttpImportTestsDisabled () { return disabled } -function areMockObjectStorageTestsDisabled () { +export function areMockObjectStorageTestsDisabled () { const disabled = process.env.ENABLE_OBJECT_STORAGE_TESTS !== 'true' if (disabled) console.log('ENABLE_OBJECT_STORAGE_TESTS env is not set to "true" so object storage tests are disabled') @@ -22,7 +22,7 @@ function areMockObjectStorageTestsDisabled () { return disabled } -function areScalewayObjectStorageTestsDisabled () { +export function areScalewayObjectStorageTestsDisabled () { if (areMockObjectStorageTestsDisabled()) return true const enabled = process.env.OBJECT_STORAGE_SCALEWAY_KEY_ID && process.env.OBJECT_STORAGE_SCALEWAY_ACCESS_KEY @@ -37,10 +37,22 @@ function areScalewayObjectStorageTestsDisabled () { return false } -export { - parallelTests, - isGithubCI, - areHttpImportTestsDisabled, - areMockObjectStorageTestsDisabled, - areScalewayObjectStorageTestsDisabled +export function isTestInstance () { + return process.env.NODE_ENV === 'test' +} + +export function isDevInstance () { + return process.env.NODE_ENV === 'dev' +} + +export function isTestOrDevInstance () { + return isTestInstance() || isDevInstance() +} + +export function isProdInstance () { + return process.env.NODE_ENV === 'production' +} + +export function getAppNumber () { + return process.env.NODE_APP_INSTANCE || '' } diff --git a/shared/extra-utils/file.ts b/packages/node-utils/src/file.ts similarity index 78% rename from shared/extra-utils/file.ts rename to packages/node-utils/src/file.ts index 8060ab520..89cf5fe0f 100644 --- a/shared/extra-utils/file.ts +++ b/packages/node-utils/src/file.ts @@ -1,4 +1,4 @@ -import { stat } from 'fs-extra' +import { stat } from 'fs/promises' async function getFileSize (path: string) { const stats = await stat(path) diff --git a/packages/node-utils/src/index.ts b/packages/node-utils/src/index.ts new file mode 100644 index 000000000..89f22e7d3 --- /dev/null +++ b/packages/node-utils/src/index.ts @@ -0,0 +1,5 @@ +export * from './crypto.js' +export * from './env.js' +export * from './file.js' +export * from './path.js' +export * from './uuid.js' diff --git a/packages/node-utils/src/path.ts b/packages/node-utils/src/path.ts new file mode 100644 index 000000000..1d569833e --- /dev/null +++ b/packages/node-utils/src/path.ts @@ -0,0 +1,50 @@ +import { basename, extname, isAbsolute, join, resolve } from 'path' +import { fileURLToPath } from 'url' + +let rootPath: string + +export function currentDir (metaUrl: string) { + return resolve(fileURLToPath(metaUrl), '..') +} + +export function root (metaUrl?: string) { + if (rootPath) return rootPath + + if (!metaUrl) { + metaUrl = import.meta.url + + const filename = basename(metaUrl) === 'path.js' || basename(metaUrl) === 'path.ts' + if (!filename) throw new Error('meta url must be specified as this file has been bundled in another one') + } + + rootPath = currentDir(metaUrl) + + if (basename(rootPath) === 'src' || basename(rootPath) === 'dist') rootPath = resolve(rootPath, '..') + if ([ 'node-utils', 'peertube-cli', 'peertube-runner' ].includes(basename(rootPath))) rootPath = resolve(rootPath, '..') + if ([ 'packages', 'apps' ].includes(basename(rootPath))) rootPath = resolve(rootPath, '..') + if (basename(rootPath) === 'dist') rootPath = resolve(rootPath, '..') + + return rootPath +} + +export function buildPath (path: string) { + if (isAbsolute(path)) return path + + return join(root(), path) +} + +export function getLowercaseExtension (filename: string) { + const ext = extname(filename) || '' + + return ext.toLowerCase() +} + +export function buildAbsoluteFixturePath (path: string, customCIPath = false) { + if (isAbsolute(path)) return path + + if (customCIPath && process.env.GITHUB_WORKSPACE) { + return join(process.env.GITHUB_WORKSPACE, 'fixtures', path) + } + + return join(root(), 'packages', 'tests', 'fixtures', path) +} diff --git a/shared/extra-utils/uuid.ts b/packages/node-utils/src/uuid.ts similarity index 89% rename from shared/extra-utils/uuid.ts rename to packages/node-utils/src/uuid.ts index f3c80e046..f158ec487 100644 --- a/shared/extra-utils/uuid.ts +++ b/packages/node-utils/src/uuid.ts @@ -1,9 +1,9 @@ -import short, { uuid } from 'short-uuid' +import short from 'short-uuid' const translator = short() function buildUUID () { - return uuid() + return short.uuid() } function uuidToShort (uuid: string) { diff --git a/packages/node-utils/tsconfig.json b/packages/node-utils/tsconfig.json new file mode 100644 index 000000000..58fa2330b --- /dev/null +++ b/packages/node-utils/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./dist", + "rootDir": "src", + "tsBuildInfoFile": "./dist/.tsbuildinfo" + } +} diff --git a/packages/peertube-runner/.npmignore b/packages/peertube-runner/.npmignore deleted file mode 100644 index f38d9947c..000000000 --- a/packages/peertube-runner/.npmignore +++ /dev/null @@ -1,6 +0,0 @@ -register -server -shared -meta.json -peertube-runner.ts -tsconfig.json diff --git a/packages/peertube-runner/README.md b/packages/peertube-runner/README.md deleted file mode 100644 index 84974bb80..000000000 --- a/packages/peertube-runner/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# PeerTube runner - -Runner program to execute jobs (transcoding...) of remote PeerTube instances. - -Commands below has to be run at the root of PeerTube git repository. - -## Develop - -```bash -npm run dev:peertube-runner -``` - -## Build - -```bash -npm run build:peertube-runner -``` - -## Run - -```bash -node packages/peertube-runner/dist/peertube-runner.js --help -``` - -## Publish on NPM - -```bash -(cd packages/peertube-runner && npm version patch) && npm run build:peertube-runner && (cd packages/peertube-runner && npm publish --access=public) -``` diff --git a/packages/peertube-runner/register/index.ts b/packages/peertube-runner/register/index.ts deleted file mode 100644 index 3d4273ef8..000000000 --- a/packages/peertube-runner/register/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './register' diff --git a/packages/peertube-runner/server/index.ts b/packages/peertube-runner/server/index.ts deleted file mode 100644 index 371836515..000000000 --- a/packages/peertube-runner/server/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './server' diff --git a/packages/peertube-runner/server/process/index.ts b/packages/peertube-runner/server/process/index.ts deleted file mode 100644 index 6caedbdaf..000000000 --- a/packages/peertube-runner/server/process/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './shared' -export * from './process' diff --git a/packages/peertube-runner/server/process/shared/index.ts b/packages/peertube-runner/server/process/shared/index.ts deleted file mode 100644 index 556c51365..000000000 --- a/packages/peertube-runner/server/process/shared/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './common' -export * from './process-vod' -export * from './transcoding-logger' diff --git a/packages/peertube-runner/server/shared/index.ts b/packages/peertube-runner/server/shared/index.ts deleted file mode 100644 index 5c86bafc0..000000000 --- a/packages/peertube-runner/server/shared/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './supported-job' diff --git a/packages/peertube-runner/shared/index.ts b/packages/peertube-runner/shared/index.ts deleted file mode 100644 index d0b5a2e3e..000000000 --- a/packages/peertube-runner/shared/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './config-manager' -export * from './http' -export * from './logger' diff --git a/packages/peertube-runner/shared/ipc/index.ts b/packages/peertube-runner/shared/ipc/index.ts deleted file mode 100644 index ad4590281..000000000 --- a/packages/peertube-runner/shared/ipc/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './ipc-client' -export * from './ipc-server' diff --git a/packages/peertube-runner/shared/ipc/shared/index.ts b/packages/peertube-runner/shared/ipc/shared/index.ts deleted file mode 100644 index deaaa152e..000000000 --- a/packages/peertube-runner/shared/ipc/shared/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './ipc-request.model' -export * from './ipc-response.model' diff --git a/packages/peertube-runner/tsconfig.json b/packages/peertube-runner/tsconfig.json deleted file mode 100644 index b6c62bc34..000000000 --- a/packages/peertube-runner/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist" - }, - "references": [ - { "path": "../../shared" } - ] -} diff --git a/packages/server-commands/package.json b/packages/server-commands/package.json new file mode 100644 index 000000000..df9778198 --- /dev/null +++ b/packages/server-commands/package.json @@ -0,0 +1,19 @@ +{ + "name": "@peertube/peertube-server-commands", + "private": true, + "version": "0.0.0", + "main": "dist/index.js", + "files": [ "dist" ], + "exports": { + "types": "./dist/index.d.ts", + "peertube:tsx": "./src/index.ts", + "default": "./dist/index.js" + }, + "type": "module", + "devDependencies": {}, + "scripts": { + "build": "tsc", + "watch": "tsc -w" + }, + "dependencies": {} +} diff --git a/shared/server-commands/bulk/bulk-command.ts b/packages/server-commands/src/bulk/bulk-command.ts similarity index 83% rename from shared/server-commands/bulk/bulk-command.ts rename to packages/server-commands/src/bulk/bulk-command.ts index b5c5673ce..784836e19 100644 --- a/shared/server-commands/bulk/bulk-command.ts +++ b/packages/server-commands/src/bulk/bulk-command.ts @@ -1,5 +1,5 @@ -import { BulkRemoveCommentsOfBody, HttpStatusCode } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { BulkRemoveCommentsOfBody, HttpStatusCode } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class BulkCommand extends AbstractCommand { diff --git a/packages/server-commands/src/bulk/index.ts b/packages/server-commands/src/bulk/index.ts new file mode 100644 index 000000000..903f7a282 --- /dev/null +++ b/packages/server-commands/src/bulk/index.ts @@ -0,0 +1 @@ +export * from './bulk-command.js' diff --git a/shared/server-commands/cli/cli-command.ts b/packages/server-commands/src/cli/cli-command.ts similarity index 92% rename from shared/server-commands/cli/cli-command.ts rename to packages/server-commands/src/cli/cli-command.ts index ab9738174..8b9400c85 100644 --- a/shared/server-commands/cli/cli-command.ts +++ b/packages/server-commands/src/cli/cli-command.ts @@ -1,5 +1,5 @@ import { exec } from 'child_process' -import { AbstractCommand } from '../shared' +import { AbstractCommand } from '../shared/index.js' export class CLICommand extends AbstractCommand { diff --git a/packages/server-commands/src/cli/index.ts b/packages/server-commands/src/cli/index.ts new file mode 100644 index 000000000..d79b13a76 --- /dev/null +++ b/packages/server-commands/src/cli/index.ts @@ -0,0 +1 @@ +export * from './cli-command.js' diff --git a/shared/server-commands/custom-pages/custom-pages-command.ts b/packages/server-commands/src/custom-pages/custom-pages-command.ts similarity index 90% rename from shared/server-commands/custom-pages/custom-pages-command.ts rename to packages/server-commands/src/custom-pages/custom-pages-command.ts index cd869a8de..412f3f763 100644 --- a/shared/server-commands/custom-pages/custom-pages-command.ts +++ b/packages/server-commands/src/custom-pages/custom-pages-command.ts @@ -1,5 +1,5 @@ -import { CustomPage, HttpStatusCode } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { CustomPage, HttpStatusCode } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class CustomPagesCommand extends AbstractCommand { diff --git a/packages/server-commands/src/custom-pages/index.ts b/packages/server-commands/src/custom-pages/index.ts new file mode 100644 index 000000000..67f537f07 --- /dev/null +++ b/packages/server-commands/src/custom-pages/index.ts @@ -0,0 +1 @@ +export * from './custom-pages-command.js' diff --git a/shared/server-commands/feeds/feeds-command.ts b/packages/server-commands/src/feeds/feeds-command.ts similarity index 93% rename from shared/server-commands/feeds/feeds-command.ts rename to packages/server-commands/src/feeds/feeds-command.ts index 26763b43e..51bc45b7f 100644 --- a/shared/server-commands/feeds/feeds-command.ts +++ b/packages/server-commands/src/feeds/feeds-command.ts @@ -1,6 +1,6 @@ -import { buildUUID } from '@shared/extra-utils' -import { HttpStatusCode } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { buildUUID } from '@peertube/peertube-node-utils' +import { HttpStatusCode } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' type FeedType = 'videos' | 'video-comments' | 'subscriptions' diff --git a/packages/server-commands/src/feeds/index.ts b/packages/server-commands/src/feeds/index.ts new file mode 100644 index 000000000..316ebb974 --- /dev/null +++ b/packages/server-commands/src/feeds/index.ts @@ -0,0 +1 @@ +export * from './feeds-command.js' diff --git a/packages/server-commands/src/index.ts b/packages/server-commands/src/index.ts new file mode 100644 index 000000000..382fe966e --- /dev/null +++ b/packages/server-commands/src/index.ts @@ -0,0 +1,14 @@ +export * from './bulk/index.js' +export * from './cli/index.js' +export * from './custom-pages/index.js' +export * from './feeds/index.js' +export * from './logs/index.js' +export * from './moderation/index.js' +export * from './overviews/index.js' +export * from './requests/index.js' +export * from './runners/index.js' +export * from './search/index.js' +export * from './server/index.js' +export * from './socket/index.js' +export * from './users/index.js' +export * from './videos/index.js' diff --git a/packages/server-commands/src/logs/index.ts b/packages/server-commands/src/logs/index.ts new file mode 100644 index 000000000..37e77901c --- /dev/null +++ b/packages/server-commands/src/logs/index.ts @@ -0,0 +1 @@ +export * from './logs-command.js' diff --git a/shared/server-commands/logs/logs-command.ts b/packages/server-commands/src/logs/logs-command.ts similarity index 97% rename from shared/server-commands/logs/logs-command.ts rename to packages/server-commands/src/logs/logs-command.ts index 1c5de7f59..d5d11b997 100644 --- a/shared/server-commands/logs/logs-command.ts +++ b/packages/server-commands/src/logs/logs-command.ts @@ -1,5 +1,5 @@ -import { ClientLogCreate, HttpStatusCode, ServerLogLevel } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { ClientLogCreate, HttpStatusCode, ServerLogLevel } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class LogsCommand extends AbstractCommand { diff --git a/shared/server-commands/moderation/abuses-command.ts b/packages/server-commands/src/moderation/abuses-command.ts similarity index 95% rename from shared/server-commands/moderation/abuses-command.ts rename to packages/server-commands/src/moderation/abuses-command.ts index 0db32ba46..e267709e2 100644 --- a/shared/server-commands/moderation/abuses-command.ts +++ b/packages/server-commands/src/moderation/abuses-command.ts @@ -1,18 +1,18 @@ -import { pick } from '@shared/core-utils' +import { pick } from '@peertube/peertube-core-utils' import { AbuseFilter, AbuseMessage, AbusePredefinedReasonsString, - AbuseState, + AbuseStateType, AbuseUpdate, AbuseVideoIs, AdminAbuse, HttpStatusCode, ResultList, UserAbuse -} from '@shared/models' -import { unwrapBody } from '../requests/requests' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +} from '@peertube/peertube-models' +import { unwrapBody } from '../requests/requests.js' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class AbusesCommand extends AbstractCommand { @@ -74,7 +74,7 @@ export class AbusesCommand extends AbstractCommand { predefinedReason?: AbusePredefinedReasonsString search?: string filter?: AbuseFilter - state?: AbuseState + state?: AbuseStateType videoIs?: AbuseVideoIs searchReporter?: string searchReportee?: string @@ -119,7 +119,7 @@ export class AbusesCommand extends AbstractCommand { id?: number search?: string - state?: AbuseState + state?: AbuseStateType }) { const toPick: (keyof typeof options)[] = [ 'id', diff --git a/packages/server-commands/src/moderation/index.ts b/packages/server-commands/src/moderation/index.ts new file mode 100644 index 000000000..8164afd7c --- /dev/null +++ b/packages/server-commands/src/moderation/index.ts @@ -0,0 +1 @@ +export * from './abuses-command.js' diff --git a/packages/server-commands/src/overviews/index.ts b/packages/server-commands/src/overviews/index.ts new file mode 100644 index 000000000..54c90705a --- /dev/null +++ b/packages/server-commands/src/overviews/index.ts @@ -0,0 +1 @@ +export * from './overviews-command.js' diff --git a/shared/server-commands/overviews/overviews-command.ts b/packages/server-commands/src/overviews/overviews-command.ts similarity index 84% rename from shared/server-commands/overviews/overviews-command.ts rename to packages/server-commands/src/overviews/overviews-command.ts index 06b4892d2..decd2fd8e 100644 --- a/shared/server-commands/overviews/overviews-command.ts +++ b/packages/server-commands/src/overviews/overviews-command.ts @@ -1,5 +1,5 @@ -import { HttpStatusCode, VideosOverview } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { HttpStatusCode, VideosOverview } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class OverviewsCommand extends AbstractCommand { diff --git a/packages/server-commands/src/requests/index.ts b/packages/server-commands/src/requests/index.ts new file mode 100644 index 000000000..4c818659e --- /dev/null +++ b/packages/server-commands/src/requests/index.ts @@ -0,0 +1 @@ +export * from './requests.js' diff --git a/shared/server-commands/requests/requests.ts b/packages/server-commands/src/requests/requests.ts similarity index 94% rename from shared/server-commands/requests/requests.ts rename to packages/server-commands/src/requests/requests.ts index 8227017eb..ac143ea5d 100644 --- a/shared/server-commands/requests/requests.ts +++ b/packages/server-commands/src/requests/requests.ts @@ -3,8 +3,9 @@ import { decode } from 'querystring' import request from 'supertest' import { URL } from 'url' -import { buildAbsoluteFixturePath, pick } from '@shared/core-utils' -import { HttpStatusCode } from '@shared/models' +import { pick } from '@peertube/peertube-core-utils' +import { HttpStatusCode, HttpStatusCodeType } from '@peertube/peertube-models' +import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils' export type CommonRequestParams = { url: string @@ -19,13 +20,13 @@ export type CommonRequestParams = { headers?: { [ name: string ]: string } type?: string xForwardedFor?: string - expectedStatus?: HttpStatusCode + expectedStatus?: HttpStatusCodeType } function makeRawRequest (options: { url: string token?: string - expectedStatus?: HttpStatusCode + expectedStatus?: HttpStatusCodeType range?: string query?: { [ id: string ]: string } method?: 'GET' | 'POST' @@ -69,7 +70,7 @@ function makeHTMLRequest (url: string, path: string) { }) } -function makeActivityPubGetRequest (url: string, path: string, expectedStatus = HttpStatusCode.OK_200) { +function makeActivityPubGetRequest (url: string, path: string, expectedStatus: HttpStatusCodeType = HttpStatusCode.OK_200) { return makeGetRequest({ url, path, @@ -132,7 +133,7 @@ function makePutBodyRequest (options: { path: string token?: string fields: { [ fieldName: string ]: any } - expectedStatus?: HttpStatusCode + expectedStatus?: HttpStatusCodeType headers?: { [name: string]: string } }) { const req = request(options.url).put(options.path) diff --git a/packages/server-commands/src/runners/index.ts b/packages/server-commands/src/runners/index.ts new file mode 100644 index 000000000..c868fa78e --- /dev/null +++ b/packages/server-commands/src/runners/index.ts @@ -0,0 +1,3 @@ +export * from './runner-jobs-command.js' +export * from './runner-registration-tokens-command.js' +export * from './runners-command.js' diff --git a/shared/server-commands/runners/runner-jobs-command.ts b/packages/server-commands/src/runners/runner-jobs-command.ts similarity index 91% rename from shared/server-commands/runners/runner-jobs-command.ts rename to packages/server-commands/src/runners/runner-jobs-command.ts index 0a0ffb5d3..4e702199f 100644 --- a/shared/server-commands/runners/runner-jobs-command.ts +++ b/packages/server-commands/src/runners/runner-jobs-command.ts @@ -1,4 +1,4 @@ -import { omit, pick, wait } from '@shared/core-utils' +import { omit, pick, wait } from '@peertube/peertube-core-utils' import { AbortRunnerJobBody, AcceptRunnerJobBody, @@ -16,15 +16,18 @@ import { RunnerJobLiveRTMPHLSTranscodingPayload, RunnerJobPayload, RunnerJobState, + RunnerJobStateType, RunnerJobSuccessBody, RunnerJobSuccessPayload, RunnerJobType, RunnerJobUpdateBody, - RunnerJobVODPayload -} from '@shared/models' -import { unwrapBody } from '../requests' -import { waitJobs } from '../server' -import { AbstractCommand, OverrideCommandOptions } from '../shared' + RunnerJobVODPayload, + VODHLSTranscodingSuccess, + VODWebVideoTranscodingSuccess +} from '@peertube/peertube-models' +import { unwrapBody } from '../requests/index.js' +import { waitJobs } from '../server/jobs.js' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class RunnerJobsCommand extends AbstractCommand { @@ -143,7 +146,7 @@ export class RunnerJobsCommand extends AbstractCommand { attaches[`payload[resolutionPlaylistFile]`] = payload.resolutionPlaylistFile attaches[`payload[videoChunkFile]`] = payload.videoChunkFile - payloadWithoutFiles = omit(payloadWithoutFiles as any, [ 'masterPlaylistFile', 'resolutionPlaylistFile', 'videoChunkFile' ]) + payloadWithoutFiles = omit(payloadWithoutFiles, [ 'masterPlaylistFile', 'resolutionPlaylistFile', 'videoChunkFile' ]) } return this.postUploadRequest({ @@ -184,13 +187,13 @@ export class RunnerJobsCommand extends AbstractCommand { if ((isWebVideoOrAudioMergeTranscodingPayloadSuccess(payload) || isHLSTranscodingPayloadSuccess(payload)) && payload.videoFile) { attaches[`payload[videoFile]`] = payload.videoFile - payloadWithoutFiles = omit(payloadWithoutFiles as any, [ 'videoFile' ]) + payloadWithoutFiles = omit(payloadWithoutFiles as VODWebVideoTranscodingSuccess, [ 'videoFile' ]) } if (isHLSTranscodingPayloadSuccess(payload) && payload.resolutionPlaylistFile) { attaches[`payload[resolutionPlaylistFile]`] = payload.resolutionPlaylistFile - payloadWithoutFiles = omit(payloadWithoutFiles as any, [ 'resolutionPlaylistFile' ]) + payloadWithoutFiles = omit(payloadWithoutFiles as VODHLSTranscodingSuccess, [ 'resolutionPlaylistFile' ]) } return this.postUploadRequest({ @@ -252,12 +255,12 @@ export class RunnerJobsCommand extends AbstractCommand { return job } - async cancelAllJobs (options: { state?: RunnerJobState } = {}) { + async cancelAllJobs (options: { state?: RunnerJobStateType } = {}) { const { state } = options const { data } = await this.list({ count: 100 }) - const allowedStates = new Set([ + const allowedStates = new Set([ RunnerJobState.PENDING, RunnerJobState.PROCESSING, RunnerJobState.WAITING_FOR_PARENT_JOB diff --git a/shared/server-commands/runners/runner-registration-tokens-command.ts b/packages/server-commands/src/runners/runner-registration-tokens-command.ts similarity index 93% rename from shared/server-commands/runners/runner-registration-tokens-command.ts rename to packages/server-commands/src/runners/runner-registration-tokens-command.ts index e4f2e3d95..86b6e5f93 100644 --- a/shared/server-commands/runners/runner-registration-tokens-command.ts +++ b/packages/server-commands/src/runners/runner-registration-tokens-command.ts @@ -1,6 +1,6 @@ -import { pick } from '@shared/core-utils' -import { HttpStatusCode, ResultList, RunnerRegistrationToken } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { pick } from '@peertube/peertube-core-utils' +import { HttpStatusCode, ResultList, RunnerRegistrationToken } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class RunnerRegistrationTokensCommand extends AbstractCommand { diff --git a/shared/server-commands/runners/runners-command.ts b/packages/server-commands/src/runners/runners-command.ts similarity index 85% rename from shared/server-commands/runners/runners-command.ts rename to packages/server-commands/src/runners/runners-command.ts index b0083e841..376a1dff9 100644 --- a/shared/server-commands/runners/runners-command.ts +++ b/packages/server-commands/src/runners/runners-command.ts @@ -1,8 +1,15 @@ -import { pick } from '@shared/core-utils' -import { buildUUID } from '@shared/extra-utils' -import { HttpStatusCode, RegisterRunnerBody, RegisterRunnerResult, ResultList, Runner, UnregisterRunnerBody } from '@shared/models' -import { unwrapBody } from '../requests' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { pick } from '@peertube/peertube-core-utils' +import { + HttpStatusCode, + RegisterRunnerBody, + RegisterRunnerResult, + ResultList, + Runner, + UnregisterRunnerBody +} from '@peertube/peertube-models' +import { buildUUID } from '@peertube/peertube-node-utils' +import { unwrapBody } from '../requests/index.js' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class RunnersCommand extends AbstractCommand { diff --git a/packages/server-commands/src/search/index.ts b/packages/server-commands/src/search/index.ts new file mode 100644 index 000000000..ca56fc669 --- /dev/null +++ b/packages/server-commands/src/search/index.ts @@ -0,0 +1 @@ +export * from './search-command.js' diff --git a/shared/server-commands/search/search-command.ts b/packages/server-commands/src/search/search-command.ts similarity index 97% rename from shared/server-commands/search/search-command.ts rename to packages/server-commands/src/search/search-command.ts index a5b498b66..e766a2861 100644 --- a/shared/server-commands/search/search-command.ts +++ b/packages/server-commands/src/search/search-command.ts @@ -7,8 +7,8 @@ import { VideoPlaylist, VideoPlaylistsSearchQuery, VideosSearchQuery -} from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +} from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class SearchCommand extends AbstractCommand { diff --git a/shared/server-commands/server/config-command.ts b/packages/server-commands/src/server/config-command.ts similarity index 98% rename from shared/server-commands/server/config-command.ts rename to packages/server-commands/src/server/config-command.ts index 5ee2fe021..8fcf0bd51 100644 --- a/shared/server-commands/server/config-command.ts +++ b/packages/server-commands/src/server/config-command.ts @@ -1,7 +1,7 @@ -import { merge } from 'lodash' -import { About, CustomConfig, HttpStatusCode, ServerConfig } from '@shared/models' -import { DeepPartial } from '@shared/typescript-utils' -import { AbstractCommand, OverrideCommandOptions } from '../shared/abstract-command' +import merge from 'lodash-es/merge.js' +import { About, CustomConfig, HttpStatusCode, ServerConfig } from '@peertube/peertube-models' +import { DeepPartial } from '@peertube/peertube-typescript-utils' +import { AbstractCommand, OverrideCommandOptions } from '../shared/abstract-command.js' export class ConfigCommand extends AbstractCommand { diff --git a/shared/server-commands/server/contact-form-command.ts b/packages/server-commands/src/server/contact-form-command.ts similarity index 86% rename from shared/server-commands/server/contact-form-command.ts rename to packages/server-commands/src/server/contact-form-command.ts index 0e8fd6d84..399e06d2f 100644 --- a/shared/server-commands/server/contact-form-command.ts +++ b/packages/server-commands/src/server/contact-form-command.ts @@ -1,6 +1,5 @@ -import { HttpStatusCode } from '@shared/models' -import { ContactForm } from '../../models/server' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { ContactForm, HttpStatusCode } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class ContactFormCommand extends AbstractCommand { diff --git a/shared/server-commands/server/debug-command.ts b/packages/server-commands/src/server/debug-command.ts similarity index 88% rename from shared/server-commands/server/debug-command.ts rename to packages/server-commands/src/server/debug-command.ts index 3c5a785bb..9bb7fda10 100644 --- a/shared/server-commands/server/debug-command.ts +++ b/packages/server-commands/src/server/debug-command.ts @@ -1,5 +1,5 @@ -import { Debug, HttpStatusCode, SendDebugCommand } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { Debug, HttpStatusCode, SendDebugCommand } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class DebugCommand extends AbstractCommand { diff --git a/shared/server-commands/server/follows-command.ts b/packages/server-commands/src/server/follows-command.ts similarity index 94% rename from shared/server-commands/server/follows-command.ts rename to packages/server-commands/src/server/follows-command.ts index 496e11df1..cdc263982 100644 --- a/shared/server-commands/server/follows-command.ts +++ b/packages/server-commands/src/server/follows-command.ts @@ -1,7 +1,7 @@ -import { pick } from '@shared/core-utils' -import { ActivityPubActorType, ActorFollow, FollowState, HttpStatusCode, ResultList, ServerFollowCreate } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' -import { PeerTubeServer } from './server' +import { pick } from '@peertube/peertube-core-utils' +import { ActivityPubActorType, ActorFollow, FollowState, HttpStatusCode, ResultList, ServerFollowCreate } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' +import { PeerTubeServer } from './server.js' export class FollowsCommand extends AbstractCommand { diff --git a/shared/server-commands/server/follows.ts b/packages/server-commands/src/server/follows.ts similarity index 83% rename from shared/server-commands/server/follows.ts rename to packages/server-commands/src/server/follows.ts index 698238f29..32304495a 100644 --- a/shared/server-commands/server/follows.ts +++ b/packages/server-commands/src/server/follows.ts @@ -1,5 +1,5 @@ -import { waitJobs } from './jobs' -import { PeerTubeServer } from './server' +import { waitJobs } from './jobs.js' +import { PeerTubeServer } from './server.js' async function doubleFollow (server1: PeerTubeServer, server2: PeerTubeServer) { await Promise.all([ diff --git a/packages/server-commands/src/server/index.ts b/packages/server-commands/src/server/index.ts new file mode 100644 index 000000000..c13972eca --- /dev/null +++ b/packages/server-commands/src/server/index.ts @@ -0,0 +1,15 @@ +export * from './config-command.js' +export * from './contact-form-command.js' +export * from './debug-command.js' +export * from './follows-command.js' +export * from './follows.js' +export * from './jobs.js' +export * from './jobs-command.js' +export * from './metrics-command.js' +export * from './object-storage-command.js' +export * from './plugins-command.js' +export * from './redundancy-command.js' +export * from './server.js' +export * from './servers-command.js' +export * from './servers.js' +export * from './stats-command.js' diff --git a/shared/server-commands/server/jobs-command.ts b/packages/server-commands/src/server/jobs-command.ts similarity index 95% rename from shared/server-commands/server/jobs-command.ts rename to packages/server-commands/src/server/jobs-command.ts index b8790ea00..18aa0cd95 100644 --- a/shared/server-commands/server/jobs-command.ts +++ b/packages/server-commands/src/server/jobs-command.ts @@ -1,6 +1,6 @@ -import { pick } from '@shared/core-utils' -import { HttpStatusCode, Job, JobState, JobType, ResultList } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { pick } from '@peertube/peertube-core-utils' +import { HttpStatusCode, Job, JobState, JobType, ResultList } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class JobsCommand extends AbstractCommand { diff --git a/shared/server-commands/server/jobs.ts b/packages/server-commands/src/server/jobs.ts similarity index 94% rename from shared/server-commands/server/jobs.ts rename to packages/server-commands/src/server/jobs.ts index 8f131fba4..1f3b1f745 100644 --- a/shared/server-commands/server/jobs.ts +++ b/packages/server-commands/src/server/jobs.ts @@ -1,8 +1,7 @@ - import { expect } from 'chai' -import { wait } from '@shared/core-utils' -import { JobState, JobType, RunnerJobState } from '../../models' -import { PeerTubeServer } from './server' +import { wait } from '@peertube/peertube-core-utils' +import { JobState, JobType, RunnerJobState } from '@peertube/peertube-models' +import { PeerTubeServer } from './server.js' async function waitJobs ( serversArg: PeerTubeServer[] | PeerTubeServer, diff --git a/shared/server-commands/server/metrics-command.ts b/packages/server-commands/src/server/metrics-command.ts similarity index 82% rename from shared/server-commands/server/metrics-command.ts rename to packages/server-commands/src/server/metrics-command.ts index d22b4833d..1f969a024 100644 --- a/shared/server-commands/server/metrics-command.ts +++ b/packages/server-commands/src/server/metrics-command.ts @@ -1,5 +1,5 @@ -import { HttpStatusCode, PlaybackMetricCreate } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { HttpStatusCode, PlaybackMetricCreate } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class MetricsCommand extends AbstractCommand { diff --git a/shared/server-commands/server/object-storage-command.ts b/packages/server-commands/src/server/object-storage-command.ts similarity index 97% rename from shared/server-commands/server/object-storage-command.ts rename to packages/server-commands/src/server/object-storage-command.ts index 6bb232c36..ff8d5d75c 100644 --- a/shared/server-commands/server/object-storage-command.ts +++ b/packages/server-commands/src/server/object-storage-command.ts @@ -1,6 +1,6 @@ import { randomInt } from 'crypto' -import { HttpStatusCode } from '@shared/models' -import { makePostBodyRequest } from '../requests' +import { HttpStatusCode } from '@peertube/peertube-models' +import { makePostBodyRequest } from '../requests/index.js' export class ObjectStorageCommand { static readonly DEFAULT_SCALEWAY_BUCKET = 'peertube-ci-test' diff --git a/shared/server-commands/server/plugins-command.ts b/packages/server-commands/src/server/plugins-command.ts similarity index 93% rename from shared/server-commands/server/plugins-command.ts rename to packages/server-commands/src/server/plugins-command.ts index bb1277a7c..f85ef0330 100644 --- a/shared/server-commands/server/plugins-command.ts +++ b/packages/server-commands/src/server/plugins-command.ts @@ -1,33 +1,34 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { readJSON, writeJSON } from 'fs-extra' +import { readJSON, writeJSON } from 'fs-extra/esm' import { join } from 'path' -import { root } from '@shared/core-utils' import { HttpStatusCode, + HttpStatusCodeType, PeerTubePlugin, PeerTubePluginIndex, PeertubePluginIndexList, PluginPackageJSON, PluginTranslation, - PluginType, + PluginType_Type, PublicServerSetting, RegisteredServerSettings, ResultList -} from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +} from '@peertube/peertube-models' +import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class PluginsCommand extends AbstractCommand { static getPluginTestPath (suffix = '') { - return join(root(), 'server', 'tests', 'fixtures', 'peertube-plugin-test' + suffix) + return buildAbsoluteFixturePath('peertube-plugin-test' + suffix) } list (options: OverrideCommandOptions & { start?: number count?: number sort?: string - pluginType?: PluginType + pluginType?: PluginType_Type uninstalled?: boolean }) { const { start, count, sort, pluginType, uninstalled } = options @@ -53,10 +54,10 @@ export class PluginsCommand extends AbstractCommand { start?: number count?: number sort?: string - pluginType?: PluginType + pluginType?: PluginType_Type currentPeerTubeEngine?: string search?: string - expectedStatus?: HttpStatusCode + expectedStatus?: HttpStatusCodeType }) { const { start, count, sort, pluginType, search, currentPeerTubeEngine } = options const path = '/api/v1/plugins/available' diff --git a/shared/server-commands/server/redundancy-command.ts b/packages/server-commands/src/server/redundancy-command.ts similarity index 96% rename from shared/server-commands/server/redundancy-command.ts rename to packages/server-commands/src/server/redundancy-command.ts index e7a8b3c29..a0ec3e80e 100644 --- a/shared/server-commands/server/redundancy-command.ts +++ b/packages/server-commands/src/server/redundancy-command.ts @@ -1,5 +1,5 @@ -import { HttpStatusCode, ResultList, VideoRedundanciesTarget, VideoRedundancy } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { HttpStatusCode, ResultList, VideoRedundanciesTarget, VideoRedundancy } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class RedundancyCommand extends AbstractCommand { diff --git a/shared/server-commands/server/server.ts b/packages/server-commands/src/server/server.ts similarity index 90% rename from shared/server-commands/server/server.ts rename to packages/server-commands/src/server/server.ts index 38568a890..57a897c17 100644 --- a/shared/server-commands/server/server.ts +++ b/packages/server-commands/src/server/server.ts @@ -1,18 +1,19 @@ import { ChildProcess, fork } from 'child_process' -import { copy } from 'fs-extra' +import { copy } from 'fs-extra/esm' import { join } from 'path' -import { parallelTests, randomInt, root } from '@shared/core-utils' -import { Video, VideoChannel, VideoChannelSync, VideoCreateResult, VideoDetails } from '@shared/models' -import { BulkCommand } from '../bulk' -import { CLICommand } from '../cli' -import { CustomPagesCommand } from '../custom-pages' -import { FeedCommand } from '../feeds' -import { LogsCommand } from '../logs' -import { AbusesCommand } from '../moderation' -import { OverviewsCommand } from '../overviews' -import { RunnerJobsCommand, RunnerRegistrationTokensCommand, RunnersCommand } from '../runners' -import { SearchCommand } from '../search' -import { SocketIOCommand } from '../socket' +import { randomInt } from '@peertube/peertube-core-utils' +import { Video, VideoChannel, VideoChannelSync, VideoCreateResult, VideoDetails } from '@peertube/peertube-models' +import { parallelTests, root } from '@peertube/peertube-node-utils' +import { BulkCommand } from '../bulk/index.js' +import { CLICommand } from '../cli/index.js' +import { CustomPagesCommand } from '../custom-pages/index.js' +import { FeedCommand } from '../feeds/index.js' +import { LogsCommand } from '../logs/index.js' +import { AbusesCommand } from '../moderation/index.js' +import { OverviewsCommand } from '../overviews/index.js' +import { RunnerJobsCommand, RunnerRegistrationTokensCommand, RunnersCommand } from '../runners/index.js' +import { SearchCommand } from '../search/index.js' +import { SocketIOCommand } from '../socket/index.js' import { AccountsCommand, BlocklistCommand, @@ -22,38 +23,38 @@ import { SubscriptionsCommand, TwoFactorCommand, UsersCommand -} from '../users' +} from '../users/index.js' import { BlacklistCommand, CaptionsCommand, ChangeOwnershipCommand, ChannelsCommand, ChannelSyncsCommand, + CommentsCommand, HistoryCommand, ImportsCommand, LiveCommand, - VideoPasswordsCommand, PlaylistsCommand, ServicesCommand, StoryboardCommand, StreamingPlaylistsCommand, + VideoPasswordsCommand, VideosCommand, + VideoStatsCommand, VideoStudioCommand, VideoTokenCommand, ViewsCommand -} from '../videos' -import { CommentsCommand } from '../videos/comments-command' -import { VideoStatsCommand } from '../videos/video-stats-command' -import { ConfigCommand } from './config-command' -import { ContactFormCommand } from './contact-form-command' -import { DebugCommand } from './debug-command' -import { FollowsCommand } from './follows-command' -import { JobsCommand } from './jobs-command' -import { MetricsCommand } from './metrics-command' -import { PluginsCommand } from './plugins-command' -import { RedundancyCommand } from './redundancy-command' -import { ServersCommand } from './servers-command' -import { StatsCommand } from './stats-command' +} from '../videos/index.js' +import { ConfigCommand } from './config-command.js' +import { ContactFormCommand } from './contact-form-command.js' +import { DebugCommand } from './debug-command.js' +import { FollowsCommand } from './follows-command.js' +import { JobsCommand } from './jobs-command.js' +import { MetricsCommand } from './metrics-command.js' +import { PluginsCommand } from './plugins-command.js' +import { RedundancyCommand } from './redundancy-command.js' +import { ServersCommand } from './servers-command.js' +import { StatsCommand } from './stats-command.js' export type RunServerOptions = { hideLogs?: boolean diff --git a/shared/server-commands/server/servers-command.ts b/packages/server-commands/src/server/servers-command.ts similarity index 89% rename from shared/server-commands/server/servers-command.ts rename to packages/server-commands/src/server/servers-command.ts index 54e586a18..0b722b62f 100644 --- a/shared/server-commands/server/servers-command.ts +++ b/packages/server-commands/src/server/servers-command.ts @@ -1,10 +1,11 @@ import { exec } from 'child_process' -import { copy, ensureDir, readFile, readdir, remove } from 'fs-extra' +import { copy, ensureDir, remove } from 'fs-extra/esm' +import { readdir, readFile } from 'fs/promises' import { basename, join } from 'path' -import { isGithubCI, root, wait } from '@shared/core-utils' -import { getFileSize } from '@shared/extra-utils' -import { HttpStatusCode } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { wait } from '@peertube/peertube-core-utils' +import { HttpStatusCode } from '@peertube/peertube-models' +import { getFileSize, isGithubCI, root } from '@peertube/peertube-node-utils' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class ServersCommand extends AbstractCommand { diff --git a/shared/server-commands/server/servers.ts b/packages/server-commands/src/server/servers.ts similarity index 90% rename from shared/server-commands/server/servers.ts rename to packages/server-commands/src/server/servers.ts index fe9da9e63..caf9866e1 100644 --- a/shared/server-commands/server/servers.ts +++ b/packages/server-commands/src/server/servers.ts @@ -1,6 +1,6 @@ -import { ensureDir } from 'fs-extra' -import { isGithubCI } from '@shared/core-utils' -import { PeerTubeServer, RunServerOptions } from './server' +import { ensureDir } from 'fs-extra/esm' +import { isGithubCI } from '@peertube/peertube-node-utils' +import { PeerTubeServer, RunServerOptions } from './server.js' async function createSingleServer (serverNumber: number, configOverride?: object, options: RunServerOptions = {}) { const server = new PeerTubeServer({ serverNumber }) diff --git a/shared/server-commands/server/stats-command.ts b/packages/server-commands/src/server/stats-command.ts similarity index 86% rename from shared/server-commands/server/stats-command.ts rename to packages/server-commands/src/server/stats-command.ts index 64a452306..80acd7bdc 100644 --- a/shared/server-commands/server/stats-command.ts +++ b/packages/server-commands/src/server/stats-command.ts @@ -1,5 +1,5 @@ -import { HttpStatusCode, ServerStats } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { HttpStatusCode, ServerStats } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class StatsCommand extends AbstractCommand { diff --git a/shared/server-commands/shared/abstract-command.ts b/packages/server-commands/src/shared/abstract-command.ts similarity index 92% rename from shared/server-commands/shared/abstract-command.ts rename to packages/server-commands/src/shared/abstract-command.ts index 463acc26b..bb6522e07 100644 --- a/shared/server-commands/shared/abstract-command.ts +++ b/packages/server-commands/src/shared/abstract-command.ts @@ -1,5 +1,6 @@ -import { isAbsolute, join } from 'path' -import { root } from '@shared/core-utils' +import { isAbsolute } from 'path' +import { HttpStatusCodeType } from '@peertube/peertube-models' +import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils' import { makeDeleteRequest, makeGetRequest, @@ -8,12 +9,13 @@ import { makeUploadRequest, unwrapBody, unwrapText -} from '../requests/requests' -import { PeerTubeServer } from '../server/server' +} from '../requests/requests.js' + +import type { PeerTubeServer } from '../server/server.js' export interface OverrideCommandOptions { token?: string - expectedStatus?: number + expectedStatus?: HttpStatusCodeType } interface InternalCommonCommandOptions extends OverrideCommandOptions { @@ -23,7 +25,7 @@ interface InternalCommonCommandOptions extends OverrideCommandOptions { path: string // If we automatically send the server token if the token is not provided implicitToken: boolean - defaultExpectedStatus: number + defaultExpectedStatus: HttpStatusCodeType // Common optional request parameters contentType?: string @@ -163,7 +165,7 @@ abstract class AbstractCommand { }) { const filePath = isAbsolute(options.fixture) ? options.fixture - : join(root(), 'server', 'tests', 'fixtures', options.fixture) + : buildAbsoluteFixturePath(options.fixture) return this.postUploadRequest({ ...options, diff --git a/packages/server-commands/src/shared/index.ts b/packages/server-commands/src/shared/index.ts new file mode 100644 index 000000000..795db3d55 --- /dev/null +++ b/packages/server-commands/src/shared/index.ts @@ -0,0 +1 @@ +export * from './abstract-command.js' diff --git a/packages/server-commands/src/socket/index.ts b/packages/server-commands/src/socket/index.ts new file mode 100644 index 000000000..24b8f4b46 --- /dev/null +++ b/packages/server-commands/src/socket/index.ts @@ -0,0 +1 @@ +export * from './socket-io-command.js' diff --git a/shared/server-commands/socket/socket-io-command.ts b/packages/server-commands/src/socket/socket-io-command.ts similarity index 98% rename from shared/server-commands/socket/socket-io-command.ts rename to packages/server-commands/src/socket/socket-io-command.ts index c28a86366..9c18c2a1f 100644 --- a/shared/server-commands/socket/socket-io-command.ts +++ b/packages/server-commands/src/socket/socket-io-command.ts @@ -1,5 +1,5 @@ import { io } from 'socket.io-client' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class SocketIOCommand extends AbstractCommand { diff --git a/shared/server-commands/users/accounts-command.ts b/packages/server-commands/src/users/accounts-command.ts similarity index 96% rename from shared/server-commands/users/accounts-command.ts rename to packages/server-commands/src/users/accounts-command.ts index 5844b330b..fd98b7eea 100644 --- a/shared/server-commands/users/accounts-command.ts +++ b/packages/server-commands/src/users/accounts-command.ts @@ -1,5 +1,5 @@ -import { Account, AccountVideoRate, ActorFollow, HttpStatusCode, ResultList, VideoRateType } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { Account, AccountVideoRate, ActorFollow, HttpStatusCode, ResultList, VideoRateType } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class AccountsCommand extends AbstractCommand { diff --git a/shared/server-commands/users/accounts.ts b/packages/server-commands/src/users/accounts.ts similarity index 86% rename from shared/server-commands/users/accounts.ts rename to packages/server-commands/src/users/accounts.ts index 6387891f4..3b8b9d36a 100644 --- a/shared/server-commands/users/accounts.ts +++ b/packages/server-commands/src/users/accounts.ts @@ -1,4 +1,4 @@ -import { PeerTubeServer } from '../server/server' +import { PeerTubeServer } from '../server/server.js' async function setDefaultAccountAvatar (serversArg: PeerTubeServer | PeerTubeServer[], token?: string) { const servers = Array.isArray(serversArg) diff --git a/shared/server-commands/users/blocklist-command.ts b/packages/server-commands/src/users/blocklist-command.ts similarity index 98% rename from shared/server-commands/users/blocklist-command.ts rename to packages/server-commands/src/users/blocklist-command.ts index 862d8945e..c77c56131 100644 --- a/shared/server-commands/users/blocklist-command.ts +++ b/packages/server-commands/src/users/blocklist-command.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { AccountBlock, BlockStatus, HttpStatusCode, ResultList, ServerBlock } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { AccountBlock, BlockStatus, HttpStatusCode, ResultList, ServerBlock } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' type ListBlocklistOptions = OverrideCommandOptions & { start: number diff --git a/packages/server-commands/src/users/index.ts b/packages/server-commands/src/users/index.ts new file mode 100644 index 000000000..baa048a43 --- /dev/null +++ b/packages/server-commands/src/users/index.ts @@ -0,0 +1,10 @@ +export * from './accounts-command.js' +export * from './accounts.js' +export * from './blocklist-command.js' +export * from './login.js' +export * from './login-command.js' +export * from './notifications-command.js' +export * from './registrations-command.js' +export * from './subscriptions-command.js' +export * from './two-factor-command.js' +export * from './users-command.js' diff --git a/shared/server-commands/users/login-command.ts b/packages/server-commands/src/users/login-command.ts similarity index 96% rename from shared/server-commands/users/login-command.ts rename to packages/server-commands/src/users/login-command.ts index f2fc6d1c5..92d123dfc 100644 --- a/shared/server-commands/users/login-command.ts +++ b/packages/server-commands/src/users/login-command.ts @@ -1,6 +1,6 @@ -import { HttpStatusCode, PeerTubeProblemDocument } from '@shared/models' -import { unwrapBody } from '../requests' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { HttpStatusCode, PeerTubeProblemDocument } from '@peertube/peertube-models' +import { unwrapBody } from '../requests/index.js' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' type LoginOptions = OverrideCommandOptions & { client?: { id?: string, secret?: string } diff --git a/shared/server-commands/users/login.ts b/packages/server-commands/src/users/login.ts similarity index 88% rename from shared/server-commands/users/login.ts rename to packages/server-commands/src/users/login.ts index f1df027d3..c48c42c72 100644 --- a/shared/server-commands/users/login.ts +++ b/packages/server-commands/src/users/login.ts @@ -1,4 +1,4 @@ -import { PeerTubeServer } from '../server/server' +import { PeerTubeServer } from '../server/server.js' function setAccessTokensToServers (servers: PeerTubeServer[]) { const tasks: Promise[] = [] diff --git a/shared/server-commands/users/notifications-command.ts b/packages/server-commands/src/users/notifications-command.ts similarity index 96% rename from shared/server-commands/users/notifications-command.ts rename to packages/server-commands/src/users/notifications-command.ts index 6bd815daa..d90d56900 100644 --- a/shared/server-commands/users/notifications-command.ts +++ b/packages/server-commands/src/users/notifications-command.ts @@ -1,5 +1,5 @@ -import { HttpStatusCode, ResultList, UserNotification, UserNotificationSetting } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { HttpStatusCode, ResultList, UserNotification, UserNotificationSetting } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class NotificationsCommand extends AbstractCommand { diff --git a/shared/server-commands/users/registrations-command.ts b/packages/server-commands/src/users/registrations-command.ts similarity index 93% rename from shared/server-commands/users/registrations-command.ts rename to packages/server-commands/src/users/registrations-command.ts index f57f54b34..2111fbd39 100644 --- a/shared/server-commands/users/registrations-command.ts +++ b/packages/server-commands/src/users/registrations-command.ts @@ -1,7 +1,13 @@ -import { pick } from '@shared/core-utils' -import { HttpStatusCode, ResultList, UserRegistration, UserRegistrationRequest, UserRegistrationUpdateState } from '@shared/models' -import { unwrapBody } from '../requests' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { pick } from '@peertube/peertube-core-utils' +import { + HttpStatusCode, + ResultList, + UserRegistration, + UserRegistrationRequest, + UserRegistrationUpdateState +} from '@peertube/peertube-models' +import { unwrapBody } from '../requests/index.js' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class RegistrationsCommand extends AbstractCommand { diff --git a/shared/server-commands/users/subscriptions-command.ts b/packages/server-commands/src/users/subscriptions-command.ts similarity index 94% rename from shared/server-commands/users/subscriptions-command.ts rename to packages/server-commands/src/users/subscriptions-command.ts index b92f037f8..52a1f0e51 100644 --- a/shared/server-commands/users/subscriptions-command.ts +++ b/packages/server-commands/src/users/subscriptions-command.ts @@ -1,5 +1,5 @@ -import { HttpStatusCode, ResultList, VideoChannel } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { HttpStatusCode, ResultList, VideoChannel } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class SubscriptionsCommand extends AbstractCommand { diff --git a/shared/server-commands/users/two-factor-command.ts b/packages/server-commands/src/users/two-factor-command.ts similarity index 93% rename from shared/server-commands/users/two-factor-command.ts rename to packages/server-commands/src/users/two-factor-command.ts index 5542acfda..cf3d6cb68 100644 --- a/shared/server-commands/users/two-factor-command.ts +++ b/packages/server-commands/src/users/two-factor-command.ts @@ -1,7 +1,7 @@ import { TOTP } from 'otpauth' -import { HttpStatusCode, TwoFactorEnableResult } from '@shared/models' -import { unwrapBody } from '../requests' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { HttpStatusCode, TwoFactorEnableResult } from '@peertube/peertube-models' +import { unwrapBody } from '../requests/index.js' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class TwoFactorCommand extends AbstractCommand { diff --git a/shared/server-commands/users/users-command.ts b/packages/server-commands/src/users/users-command.ts similarity index 95% rename from shared/server-commands/users/users-command.ts rename to packages/server-commands/src/users/users-command.ts index 5b39d3488..d3b11939e 100644 --- a/shared/server-commands/users/users-command.ts +++ b/packages/server-commands/src/users/users-command.ts @@ -1,20 +1,21 @@ -import { omit, pick } from '@shared/core-utils' +import { omit, pick } from '@peertube/peertube-core-utils' import { HttpStatusCode, MyUser, ResultList, ScopedToken, User, - UserAdminFlag, + UserAdminFlagType, UserCreateResult, UserRole, + UserRoleType, UserUpdate, UserUpdateMe, UserVideoQuota, UserVideoRate -} from '@shared/models' -import { unwrapBody } from '../requests' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +} from '@peertube/peertube-models' +import { unwrapBody } from '../requests/index.js' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class UsersCommand extends AbstractCommand { @@ -158,8 +159,8 @@ export class UsersCommand extends AbstractCommand { password?: string videoQuota?: number videoQuotaDaily?: number - role?: UserRole - adminFlags?: UserAdminFlag + role?: UserRoleType + adminFlags?: UserAdminFlagType }) { const { username, @@ -190,7 +191,7 @@ export class UsersCommand extends AbstractCommand { })).then(res => res.user) } - async generate (username: string, role?: UserRole) { + async generate (username: string, role?: UserRoleType) { const password = 'password' const user = await this.create({ username, password, role }) @@ -207,7 +208,7 @@ export class UsersCommand extends AbstractCommand { } } - async generateUserAndToken (username: string, role?: UserRole) { + async generateUserAndToken (username: string, role?: UserRoleType) { const password = 'password' await this.create({ username, password, role }) @@ -360,9 +361,9 @@ export class UsersCommand extends AbstractCommand { videoQuota?: number videoQuotaDaily?: number password?: string - adminFlags?: UserAdminFlag + adminFlags?: UserAdminFlagType pluginAuth?: string - role?: UserRole + role?: UserRoleType }) { const path = '/api/v1/users/' + options.userId diff --git a/shared/server-commands/videos/blacklist-command.ts b/packages/server-commands/src/videos/blacklist-command.ts similarity index 94% rename from shared/server-commands/videos/blacklist-command.ts rename to packages/server-commands/src/videos/blacklist-command.ts index 47e23ebc8..d41001e26 100644 --- a/shared/server-commands/videos/blacklist-command.ts +++ b/packages/server-commands/src/videos/blacklist-command.ts @@ -1,6 +1,5 @@ - -import { HttpStatusCode, ResultList, VideoBlacklist, VideoBlacklistType } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { HttpStatusCode, ResultList, VideoBlacklist, VideoBlacklistType_Type } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class BlacklistCommand extends AbstractCommand { @@ -56,7 +55,7 @@ export class BlacklistCommand extends AbstractCommand { list (options: OverrideCommandOptions & { sort?: string - type?: VideoBlacklistType + type?: VideoBlacklistType_Type } = {}) { const { sort, type } = options const path = '/api/v1/videos/blacklist/' diff --git a/shared/server-commands/videos/captions-command.ts b/packages/server-commands/src/videos/captions-command.ts similarity index 90% rename from shared/server-commands/videos/captions-command.ts rename to packages/server-commands/src/videos/captions-command.ts index a26fcb57d..a8336aa27 100644 --- a/shared/server-commands/videos/captions-command.ts +++ b/packages/server-commands/src/videos/captions-command.ts @@ -1,6 +1,6 @@ -import { buildAbsoluteFixturePath } from '@shared/core-utils' -import { HttpStatusCode, ResultList, VideoCaption } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { HttpStatusCode, ResultList, VideoCaption } from '@peertube/peertube-models' +import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class CaptionsCommand extends AbstractCommand { diff --git a/shared/server-commands/videos/change-ownership-command.ts b/packages/server-commands/src/videos/change-ownership-command.ts similarity index 97% rename from shared/server-commands/videos/change-ownership-command.ts rename to packages/server-commands/src/videos/change-ownership-command.ts index ad4c726ef..1dc7c2c0f 100644 --- a/shared/server-commands/videos/change-ownership-command.ts +++ b/packages/server-commands/src/videos/change-ownership-command.ts @@ -1,6 +1,5 @@ - -import { HttpStatusCode, ResultList, VideoChangeOwnership } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { HttpStatusCode, ResultList, VideoChangeOwnership } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class ChangeOwnershipCommand extends AbstractCommand { diff --git a/shared/server-commands/videos/channel-syncs-command.ts b/packages/server-commands/src/videos/channel-syncs-command.ts similarity index 89% rename from shared/server-commands/videos/channel-syncs-command.ts rename to packages/server-commands/src/videos/channel-syncs-command.ts index de4a160ec..718000c8a 100644 --- a/shared/server-commands/videos/channel-syncs-command.ts +++ b/packages/server-commands/src/videos/channel-syncs-command.ts @@ -1,7 +1,7 @@ -import { HttpStatusCode, ResultList, VideoChannelSync, VideoChannelSyncCreate } from '@shared/models' -import { pick } from '@shared/core-utils' -import { unwrapBody } from '../requests' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { HttpStatusCode, ResultList, VideoChannelSync, VideoChannelSyncCreate } from '@peertube/peertube-models' +import { pick } from '@peertube/peertube-core-utils' +import { unwrapBody } from '../requests/index.js' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class ChannelSyncsCommand extends AbstractCommand { private static readonly API_PATH = '/api/v1/video-channel-syncs' diff --git a/shared/server-commands/videos/channels-command.ts b/packages/server-commands/src/videos/channels-command.ts similarity index 97% rename from shared/server-commands/videos/channels-command.ts rename to packages/server-commands/src/videos/channels-command.ts index 385d0fe73..772677d39 100644 --- a/shared/server-commands/videos/channels-command.ts +++ b/packages/server-commands/src/videos/channels-command.ts @@ -1,4 +1,4 @@ -import { pick } from '@shared/core-utils' +import { pick } from '@peertube/peertube-core-utils' import { ActorFollow, HttpStatusCode, @@ -8,9 +8,9 @@ import { VideoChannelCreateResult, VideoChannelUpdate, VideosImportInChannelCreate -} from '@shared/models' -import { unwrapBody } from '../requests' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +} from '@peertube/peertube-models' +import { unwrapBody } from '../requests/index.js' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class ChannelsCommand extends AbstractCommand { diff --git a/shared/server-commands/videos/channels.ts b/packages/server-commands/src/videos/channels.ts similarity index 93% rename from shared/server-commands/videos/channels.ts rename to packages/server-commands/src/videos/channels.ts index 3c0d4b723..e3487d024 100644 --- a/shared/server-commands/videos/channels.ts +++ b/packages/server-commands/src/videos/channels.ts @@ -1,4 +1,4 @@ -import { PeerTubeServer } from '../server/server' +import { PeerTubeServer } from '../server/server.js' function setDefaultVideoChannel (servers: PeerTubeServer[]) { const tasks: Promise[] = [] diff --git a/shared/server-commands/videos/comments-command.ts b/packages/server-commands/src/videos/comments-command.ts similarity index 95% rename from shared/server-commands/videos/comments-command.ts rename to packages/server-commands/src/videos/comments-command.ts index 0dab1b66a..4835ae1fb 100644 --- a/shared/server-commands/videos/comments-command.ts +++ b/packages/server-commands/src/videos/comments-command.ts @@ -1,7 +1,7 @@ -import { pick } from '@shared/core-utils' -import { HttpStatusCode, ResultList, VideoComment, VideoCommentThreads, VideoCommentThreadTree } from '@shared/models' -import { unwrapBody } from '../requests' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { pick } from '@peertube/peertube-core-utils' +import { HttpStatusCode, ResultList, VideoComment, VideoCommentThreads, VideoCommentThreadTree } from '@peertube/peertube-models' +import { unwrapBody } from '../requests/index.js' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class CommentsCommand extends AbstractCommand { diff --git a/shared/server-commands/videos/history-command.ts b/packages/server-commands/src/videos/history-command.ts similarity index 92% rename from shared/server-commands/videos/history-command.ts rename to packages/server-commands/src/videos/history-command.ts index d27afcff2..fd032504a 100644 --- a/shared/server-commands/videos/history-command.ts +++ b/packages/server-commands/src/videos/history-command.ts @@ -1,5 +1,5 @@ -import { HttpStatusCode, ResultList, Video } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { HttpStatusCode, ResultList, Video } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class HistoryCommand extends AbstractCommand { diff --git a/shared/server-commands/videos/imports-command.ts b/packages/server-commands/src/videos/imports-command.ts similarity index 92% rename from shared/server-commands/videos/imports-command.ts rename to packages/server-commands/src/videos/imports-command.ts index e307a79be..1a1931d64 100644 --- a/shared/server-commands/videos/imports-command.ts +++ b/packages/server-commands/src/videos/imports-command.ts @@ -1,8 +1,7 @@ -import { HttpStatusCode, ResultList } from '@shared/models' -import { VideoImport, VideoImportCreate } from '../../models/videos' -import { unwrapBody } from '../requests' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { HttpStatusCode, ResultList, VideoImport, VideoImportCreate } from '@peertube/peertube-models' +import { unwrapBody } from '../requests/index.js' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class ImportsCommand extends AbstractCommand { diff --git a/packages/server-commands/src/videos/index.ts b/packages/server-commands/src/videos/index.ts new file mode 100644 index 000000000..970026d51 --- /dev/null +++ b/packages/server-commands/src/videos/index.ts @@ -0,0 +1,22 @@ +export * from './blacklist-command.js' +export * from './captions-command.js' +export * from './change-ownership-command.js' +export * from './channels.js' +export * from './channels-command.js' +export * from './channel-syncs-command.js' +export * from './comments-command.js' +export * from './history-command.js' +export * from './imports-command.js' +export * from './live-command.js' +export * from './live.js' +export * from './playlists-command.js' +export * from './services-command.js' +export * from './storyboard-command.js' +export * from './streaming-playlists-command.js' +export * from './comments-command.js' +export * from './video-studio-command.js' +export * from './video-token-command.js' +export * from './views-command.js' +export * from './videos-command.js' +export * from './video-passwords-command.js' +export * from './video-stats-command.js' diff --git a/shared/server-commands/videos/live-command.ts b/packages/server-commands/src/videos/live-command.ts similarity index 95% rename from shared/server-commands/videos/live-command.ts rename to packages/server-commands/src/videos/live-command.ts index 6006d9fe9..793b64f40 100644 --- a/shared/server-commands/videos/live-command.ts +++ b/packages/server-commands/src/videos/live-command.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { readdir } from 'fs-extra' +import { readdir } from 'fs/promises' import { join } from 'path' -import { omit, wait } from '@shared/core-utils' +import { omit, wait } from '@peertube/peertube-core-utils' import { HttpStatusCode, LiveVideo, @@ -13,12 +13,14 @@ import { VideoCreateResult, VideoDetails, VideoPrivacy, - VideoState -} from '@shared/models' -import { unwrapBody } from '../requests' -import { ObjectStorageCommand, PeerTubeServer } from '../server' -import { AbstractCommand, OverrideCommandOptions } from '../shared' -import { sendRTMPStream, testFfmpegStreamError } from './live' + VideoPrivacyType, + VideoState, + VideoStateType +} from '@peertube/peertube-models' +import { unwrapBody } from '../requests/index.js' +import { ObjectStorageCommand, PeerTubeServer } from '../server/index.js' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' +import { sendRTMPStream, testFfmpegStreamError } from './live.js' export class LiveCommand extends AbstractCommand { @@ -119,7 +121,7 @@ export class LiveCommand extends AbstractCommand { async quickCreate (options: OverrideCommandOptions & { saveReplay: boolean permanentLive: boolean - privacy?: VideoPrivacy + privacy?: VideoPrivacyType videoPasswords?: string[] }) { const { saveReplay, permanentLive, privacy = VideoPrivacy.PUBLIC, videoPasswords } = options @@ -324,7 +326,7 @@ export class LiveCommand extends AbstractCommand { private async waitUntilState (options: OverrideCommandOptions & { videoId: number | string - state: VideoState + state: VideoStateType }) { let video: VideoDetails diff --git a/shared/server-commands/videos/live.ts b/packages/server-commands/src/videos/live.ts similarity index 91% rename from shared/server-commands/videos/live.ts rename to packages/server-commands/src/videos/live.ts index cebadb1db..05bfa1113 100644 --- a/shared/server-commands/videos/live.ts +++ b/packages/server-commands/src/videos/live.ts @@ -1,8 +1,9 @@ +import { wait } from '@peertube/peertube-core-utils' +import { VideoDetails, VideoInclude, VideoPrivacy } from '@peertube/peertube-models' +import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils' import ffmpeg, { FfmpegCommand } from 'fluent-ffmpeg' -import { truncate } from 'lodash' -import { buildAbsoluteFixturePath, wait } from '@shared/core-utils' -import { VideoDetails, VideoInclude, VideoPrivacy } from '@shared/models' -import { PeerTubeServer } from '../server/server' +import truncate from 'lodash-es/truncate.js' +import { PeerTubeServer } from '../server/server.js' function sendRTMPStream (options: { rtmpBaseUrl: string diff --git a/shared/server-commands/videos/playlists-command.ts b/packages/server-commands/src/videos/playlists-command.ts similarity index 95% rename from shared/server-commands/videos/playlists-command.ts rename to packages/server-commands/src/videos/playlists-command.ts index da3bef7b0..2e483f318 100644 --- a/shared/server-commands/videos/playlists-command.ts +++ b/packages/server-commands/src/videos/playlists-command.ts @@ -1,4 +1,4 @@ -import { omit, pick } from '@shared/core-utils' +import { omit, pick } from '@peertube/peertube-core-utils' import { BooleanBothQuery, HttpStatusCode, @@ -12,11 +12,11 @@ import { VideoPlaylistElementCreateResult, VideoPlaylistElementUpdate, VideoPlaylistReorder, - VideoPlaylistType, + VideoPlaylistType_Type, VideoPlaylistUpdate -} from '@shared/models' -import { unwrapBody } from '../requests' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +} from '@peertube/peertube-models' +import { unwrapBody } from '../requests/index.js' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class PlaylistsCommand extends AbstractCommand { @@ -24,7 +24,7 @@ export class PlaylistsCommand extends AbstractCommand { start?: number count?: number sort?: string - playlistType?: VideoPlaylistType + playlistType?: VideoPlaylistType_Type }) { const path = '/api/v1/video-playlists' const query = pick(options, [ 'start', 'count', 'sort', 'playlistType' ]) @@ -44,7 +44,7 @@ export class PlaylistsCommand extends AbstractCommand { start?: number count?: number sort?: string - playlistType?: VideoPlaylistType + playlistType?: VideoPlaylistType_Type }) { const path = '/api/v1/video-channels/' + options.handle + '/video-playlists' const query = pick(options, [ 'start', 'count', 'sort', 'playlistType' ]) @@ -65,7 +65,7 @@ export class PlaylistsCommand extends AbstractCommand { count?: number sort?: string search?: string - playlistType?: VideoPlaylistType + playlistType?: VideoPlaylistType_Type }) { const path = '/api/v1/accounts/' + options.handle + '/video-playlists' const query = pick(options, [ 'start', 'count', 'sort', 'search', 'playlistType' ]) diff --git a/shared/server-commands/videos/services-command.ts b/packages/server-commands/src/videos/services-command.ts similarity index 89% rename from shared/server-commands/videos/services-command.ts rename to packages/server-commands/src/videos/services-command.ts index 06760df42..ade10cd3a 100644 --- a/shared/server-commands/videos/services-command.ts +++ b/packages/server-commands/src/videos/services-command.ts @@ -1,5 +1,5 @@ -import { HttpStatusCode } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { HttpStatusCode } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class ServicesCommand extends AbstractCommand { diff --git a/shared/server-commands/videos/storyboard-command.ts b/packages/server-commands/src/videos/storyboard-command.ts similarity index 84% rename from shared/server-commands/videos/storyboard-command.ts rename to packages/server-commands/src/videos/storyboard-command.ts index 06d90fc12..a692ad612 100644 --- a/shared/server-commands/videos/storyboard-command.ts +++ b/packages/server-commands/src/videos/storyboard-command.ts @@ -1,5 +1,5 @@ -import { HttpStatusCode, Storyboard } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { HttpStatusCode, Storyboard } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class StoryboardCommand extends AbstractCommand { diff --git a/shared/server-commands/videos/streaming-playlists-command.ts b/packages/server-commands/src/videos/streaming-playlists-command.ts similarity index 94% rename from shared/server-commands/videos/streaming-playlists-command.ts rename to packages/server-commands/src/videos/streaming-playlists-command.ts index b988ac4b2..2406dd023 100644 --- a/shared/server-commands/videos/streaming-playlists-command.ts +++ b/packages/server-commands/src/videos/streaming-playlists-command.ts @@ -1,7 +1,7 @@ -import { wait } from '@shared/core-utils' -import { HttpStatusCode } from '@shared/models' -import { unwrapBody, unwrapBodyOrDecodeToJSON, unwrapTextOrDecode } from '../requests' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { wait } from '@peertube/peertube-core-utils' +import { HttpStatusCode } from '@peertube/peertube-models' +import { unwrapBody, unwrapBodyOrDecodeToJSON, unwrapTextOrDecode } from '../requests/index.js' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class StreamingPlaylistsCommand extends AbstractCommand { diff --git a/shared/server-commands/videos/video-passwords-command.ts b/packages/server-commands/src/videos/video-passwords-command.ts similarity index 93% rename from shared/server-commands/videos/video-passwords-command.ts rename to packages/server-commands/src/videos/video-passwords-command.ts index bf10335b4..7a56311ca 100644 --- a/shared/server-commands/videos/video-passwords-command.ts +++ b/packages/server-commands/src/videos/video-passwords-command.ts @@ -1,5 +1,6 @@ -import { HttpStatusCode, ResultList, VideoPassword } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { HttpStatusCode, ResultList, VideoPassword } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' + export class VideoPasswordsCommand extends AbstractCommand { list (options: OverrideCommandOptions & { diff --git a/shared/server-commands/videos/video-stats-command.ts b/packages/server-commands/src/videos/video-stats-command.ts similarity index 86% rename from shared/server-commands/videos/video-stats-command.ts rename to packages/server-commands/src/videos/video-stats-command.ts index b9b99bfb5..1b7a9b592 100644 --- a/shared/server-commands/videos/video-stats-command.ts +++ b/packages/server-commands/src/videos/video-stats-command.ts @@ -1,6 +1,12 @@ -import { pick } from '@shared/core-utils' -import { HttpStatusCode, VideoStatsOverall, VideoStatsRetention, VideoStatsTimeserie, VideoStatsTimeserieMetric } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { pick } from '@peertube/peertube-core-utils' +import { + HttpStatusCode, + VideoStatsOverall, + VideoStatsRetention, + VideoStatsTimeserie, + VideoStatsTimeserieMetric +} from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class VideoStatsCommand extends AbstractCommand { diff --git a/shared/server-commands/videos/video-studio-command.ts b/packages/server-commands/src/videos/video-studio-command.ts similarity index 94% rename from shared/server-commands/videos/video-studio-command.ts rename to packages/server-commands/src/videos/video-studio-command.ts index 675cd84b7..8c5ff169a 100644 --- a/shared/server-commands/videos/video-studio-command.ts +++ b/packages/server-commands/src/videos/video-studio-command.ts @@ -1,5 +1,5 @@ -import { HttpStatusCode, VideoStudioTask } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { HttpStatusCode, VideoStudioTask } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class VideoStudioCommand extends AbstractCommand { diff --git a/shared/server-commands/videos/video-token-command.ts b/packages/server-commands/src/videos/video-token-command.ts similarity index 86% rename from shared/server-commands/videos/video-token-command.ts rename to packages/server-commands/src/videos/video-token-command.ts index c4ed29a8c..5812e484a 100644 --- a/shared/server-commands/videos/video-token-command.ts +++ b/packages/server-commands/src/videos/video-token-command.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */ -import { HttpStatusCode, VideoToken } from '@shared/models' -import { unwrapBody } from '../requests' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { HttpStatusCode, VideoToken } from '@peertube/peertube-models' +import { unwrapBody } from '../requests/index.js' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class VideoTokenCommand extends AbstractCommand { diff --git a/shared/server-commands/videos/videos-command.ts b/packages/server-commands/src/videos/videos-command.ts similarity index 96% rename from shared/server-commands/videos/videos-command.ts rename to packages/server-commands/src/videos/videos-command.ts index 4c3513ed4..72dc58a4b 100644 --- a/shared/server-commands/videos/videos-command.ts +++ b/packages/server-commands/src/videos/videos-command.ts @@ -1,13 +1,14 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */ import { expect } from 'chai' -import { createReadStream, stat } from 'fs-extra' +import { createReadStream } from 'fs' +import { stat } from 'fs/promises' import got, { Response as GotResponse } from 'got' import validator from 'validator' -import { buildAbsoluteFixturePath, getAllPrivacies, omit, pick, wait } from '@shared/core-utils' -import { buildUUID } from '@shared/extra-utils' +import { getAllPrivacies, omit, pick, wait } from '@peertube/peertube-core-utils' import { HttpStatusCode, + HttpStatusCodeType, ResultList, UserVideoRateType, Video, @@ -17,13 +18,15 @@ import { VideoFileMetadata, VideoInclude, VideoPrivacy, + VideoPrivacyType, VideosCommonQuery, + VideoSource, VideoTranscodingCreate -} from '@shared/models' -import { VideoSource } from '@shared/models/videos/video-source' -import { unwrapBody } from '../requests' -import { waitJobs } from '../server' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +} from '@peertube/peertube-models' +import { buildAbsoluteFixturePath, buildUUID } from '@peertube/peertube-node-utils' +import { unwrapBody } from '../requests/index.js' +import { waitJobs } from '../server/jobs.js' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export type VideoEdit = Partial> & { fixture?: string @@ -72,7 +75,7 @@ export class VideosCommand extends AbstractCommand { getPrivacies (options: OverrideCommandOptions = {}) { const path = '/api/v1/videos/privacies' - return this.getRequestBody<{ [id in VideoPrivacy]: string }>({ + return this.getRequestBody<{ [id in VideoPrivacyType]: string }>({ ...options, path, @@ -190,7 +193,7 @@ export class VideosCommand extends AbstractCommand { }) { const { uuid } = options - if (validator.isUUID('' + uuid) === false) return uuid as number + if (validator.default.isUUID('' + uuid) === false) return uuid as number const { id } = await this.get({ ...options, id: uuid }) @@ -394,7 +397,7 @@ export class VideosCommand extends AbstractCommand { attributes?: VideoEdit mode?: 'legacy' | 'resumable' // default legacy waitTorrentGeneration?: boolean // default true - completedExpectedStatus?: HttpStatusCode + completedExpectedStatus?: HttpStatusCodeType } = {}) { const { mode = 'legacy', waitTorrentGeneration = true } = options let defaultChannelId = 1 @@ -462,7 +465,7 @@ export class VideosCommand extends AbstractCommand { async buildResumeUpload (options: OverrideCommandOptions & { path: string attributes: { fixture?: string } & { [id: string]: any } - completedExpectedStatus?: HttpStatusCode // When the upload is finished + completedExpectedStatus?: HttpStatusCodeType // When the upload is finished }): Promise { const { path, attributes, expectedStatus = HttpStatusCode.OK_200, completedExpectedStatus } = options @@ -595,9 +598,9 @@ export class VideosCommand extends AbstractCommand { let start = 0 const token = this.buildCommonRequestToken({ ...options, implicitToken: true }) - const url = this.server.url const readable = createReadStream(videoFilePath, { highWaterMark: 8 * 1024 }) + const server = this.server return new Promise>((resolve, reject) => { readable.on('data', async function onData (chunk) { try { @@ -619,10 +622,9 @@ export class VideosCommand extends AbstractCommand { } const res = await got<{ video: VideoCreateResult }>({ - url, + url: new URL(path + '?' + pathUploadId, server.url).toString(), method: 'put', headers, - path: path + '?' + pathUploadId, body: chunk, responseType: 'json', throwHttpErrors: false @@ -670,7 +672,7 @@ export class VideosCommand extends AbstractCommand { quickUpload (options: OverrideCommandOptions & { name: string nsfw?: boolean - privacy?: VideoPrivacy + privacy?: VideoPrivacyType fixture?: string videoPasswords?: string[] }) { @@ -705,7 +707,7 @@ export class VideosCommand extends AbstractCommand { replaceSourceFile (options: OverrideCommandOptions & { videoId: number | string fixture: string - completedExpectedStatus?: HttpStatusCode + completedExpectedStatus?: HttpStatusCodeType }) { return this.buildResumeUpload({ ...options, diff --git a/shared/server-commands/videos/views-command.ts b/packages/server-commands/src/videos/views-command.ts similarity index 93% rename from shared/server-commands/videos/views-command.ts rename to packages/server-commands/src/videos/views-command.ts index bdb8daaa4..048bd3fda 100644 --- a/shared/server-commands/videos/views-command.ts +++ b/packages/server-commands/src/videos/views-command.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */ -import { HttpStatusCode, VideoViewEvent } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' +import { HttpStatusCode, VideoViewEvent } from '@peertube/peertube-models' +import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js' export class ViewsCommand extends AbstractCommand { diff --git a/packages/server-commands/tsconfig.json b/packages/server-commands/tsconfig.json new file mode 100644 index 000000000..eb942f295 --- /dev/null +++ b/packages/server-commands/tsconfig.json @@ -0,0 +1,14 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "baseUrl": "./", + "outDir": "./dist", + "rootDir": "src", + "tsBuildInfoFile": "./dist/.tsbuildinfo" + }, + "references": [ + { "path": "../models" }, + { "path": "../core-utils" }, + { "path": "../typescript-utils" } + ] +} diff --git a/server/tests/fixtures/60fps_720p_small.mp4 b/packages/tests/fixtures/60fps_720p_small.mp4 similarity index 100% rename from server/tests/fixtures/60fps_720p_small.mp4 rename to packages/tests/fixtures/60fps_720p_small.mp4 diff --git a/server/tests/fixtures/ap-json/mastodon/bad-body-http-signature.json b/packages/tests/fixtures/ap-json/mastodon/bad-body-http-signature.json similarity index 100% rename from server/tests/fixtures/ap-json/mastodon/bad-body-http-signature.json rename to packages/tests/fixtures/ap-json/mastodon/bad-body-http-signature.json diff --git a/server/tests/fixtures/ap-json/mastodon/bad-http-signature.json b/packages/tests/fixtures/ap-json/mastodon/bad-http-signature.json similarity index 100% rename from server/tests/fixtures/ap-json/mastodon/bad-http-signature.json rename to packages/tests/fixtures/ap-json/mastodon/bad-http-signature.json diff --git a/server/tests/fixtures/ap-json/mastodon/bad-public-key.json b/packages/tests/fixtures/ap-json/mastodon/bad-public-key.json similarity index 100% rename from server/tests/fixtures/ap-json/mastodon/bad-public-key.json rename to packages/tests/fixtures/ap-json/mastodon/bad-public-key.json diff --git a/server/tests/fixtures/ap-json/mastodon/create-bad-signature.json b/packages/tests/fixtures/ap-json/mastodon/create-bad-signature.json similarity index 100% rename from server/tests/fixtures/ap-json/mastodon/create-bad-signature.json rename to packages/tests/fixtures/ap-json/mastodon/create-bad-signature.json diff --git a/server/tests/fixtures/ap-json/mastodon/create.json b/packages/tests/fixtures/ap-json/mastodon/create.json similarity index 100% rename from server/tests/fixtures/ap-json/mastodon/create.json rename to packages/tests/fixtures/ap-json/mastodon/create.json diff --git a/server/tests/fixtures/ap-json/mastodon/http-signature.json b/packages/tests/fixtures/ap-json/mastodon/http-signature.json similarity index 100% rename from server/tests/fixtures/ap-json/mastodon/http-signature.json rename to packages/tests/fixtures/ap-json/mastodon/http-signature.json diff --git a/server/tests/fixtures/ap-json/mastodon/public-key.json b/packages/tests/fixtures/ap-json/mastodon/public-key.json similarity index 100% rename from server/tests/fixtures/ap-json/mastodon/public-key.json rename to packages/tests/fixtures/ap-json/mastodon/public-key.json diff --git a/server/tests/fixtures/ap-json/peertube/announce-without-context.json b/packages/tests/fixtures/ap-json/peertube/announce-without-context.json similarity index 100% rename from server/tests/fixtures/ap-json/peertube/announce-without-context.json rename to packages/tests/fixtures/ap-json/peertube/announce-without-context.json diff --git a/server/tests/fixtures/ap-json/peertube/invalid-keys.json b/packages/tests/fixtures/ap-json/peertube/invalid-keys.json similarity index 100% rename from server/tests/fixtures/ap-json/peertube/invalid-keys.json rename to packages/tests/fixtures/ap-json/peertube/invalid-keys.json diff --git a/server/tests/fixtures/ap-json/peertube/keys.json b/packages/tests/fixtures/ap-json/peertube/keys.json similarity index 100% rename from server/tests/fixtures/ap-json/peertube/keys.json rename to packages/tests/fixtures/ap-json/peertube/keys.json diff --git a/server/tests/fixtures/avatar-big.png b/packages/tests/fixtures/avatar-big.png similarity index 100% rename from server/tests/fixtures/avatar-big.png rename to packages/tests/fixtures/avatar-big.png diff --git a/server/tests/fixtures/avatar-resized-120x120.gif b/packages/tests/fixtures/avatar-resized-120x120.gif similarity index 100% rename from server/tests/fixtures/avatar-resized-120x120.gif rename to packages/tests/fixtures/avatar-resized-120x120.gif diff --git a/server/tests/fixtures/avatar-resized-120x120.png b/packages/tests/fixtures/avatar-resized-120x120.png similarity index 100% rename from server/tests/fixtures/avatar-resized-120x120.png rename to packages/tests/fixtures/avatar-resized-120x120.png diff --git a/server/tests/fixtures/avatar-resized-48x48.gif b/packages/tests/fixtures/avatar-resized-48x48.gif similarity index 100% rename from server/tests/fixtures/avatar-resized-48x48.gif rename to packages/tests/fixtures/avatar-resized-48x48.gif diff --git a/server/tests/fixtures/avatar-resized-48x48.png b/packages/tests/fixtures/avatar-resized-48x48.png similarity index 100% rename from server/tests/fixtures/avatar-resized-48x48.png rename to packages/tests/fixtures/avatar-resized-48x48.png diff --git a/server/tests/fixtures/avatar.gif b/packages/tests/fixtures/avatar.gif similarity index 100% rename from server/tests/fixtures/avatar.gif rename to packages/tests/fixtures/avatar.gif diff --git a/server/tests/fixtures/avatar.png b/packages/tests/fixtures/avatar.png similarity index 100% rename from server/tests/fixtures/avatar.png rename to packages/tests/fixtures/avatar.png diff --git a/server/tests/fixtures/avatar2-resized-120x120.png b/packages/tests/fixtures/avatar2-resized-120x120.png similarity index 100% rename from server/tests/fixtures/avatar2-resized-120x120.png rename to packages/tests/fixtures/avatar2-resized-120x120.png diff --git a/server/tests/fixtures/avatar2-resized-48x48.png b/packages/tests/fixtures/avatar2-resized-48x48.png similarity index 100% rename from server/tests/fixtures/avatar2-resized-48x48.png rename to packages/tests/fixtures/avatar2-resized-48x48.png diff --git a/server/tests/fixtures/avatar2.png b/packages/tests/fixtures/avatar2.png similarity index 100% rename from server/tests/fixtures/avatar2.png rename to packages/tests/fixtures/avatar2.png diff --git a/server/tests/fixtures/banner-resized.jpg b/packages/tests/fixtures/banner-resized.jpg similarity index 100% rename from server/tests/fixtures/banner-resized.jpg rename to packages/tests/fixtures/banner-resized.jpg diff --git a/server/tests/fixtures/banner.jpg b/packages/tests/fixtures/banner.jpg similarity index 100% rename from server/tests/fixtures/banner.jpg rename to packages/tests/fixtures/banner.jpg diff --git a/server/tests/fixtures/custom-preview-big.png b/packages/tests/fixtures/custom-preview-big.png similarity index 100% rename from server/tests/fixtures/custom-preview-big.png rename to packages/tests/fixtures/custom-preview-big.png diff --git a/server/tests/fixtures/custom-preview.jpg b/packages/tests/fixtures/custom-preview.jpg similarity index 100% rename from server/tests/fixtures/custom-preview.jpg rename to packages/tests/fixtures/custom-preview.jpg diff --git a/server/tests/fixtures/custom-thumbnail-big.jpg b/packages/tests/fixtures/custom-thumbnail-big.jpg similarity index 100% rename from server/tests/fixtures/custom-thumbnail-big.jpg rename to packages/tests/fixtures/custom-thumbnail-big.jpg diff --git a/server/tests/fixtures/custom-thumbnail.jpg b/packages/tests/fixtures/custom-thumbnail.jpg similarity index 100% rename from server/tests/fixtures/custom-thumbnail.jpg rename to packages/tests/fixtures/custom-thumbnail.jpg diff --git a/server/tests/fixtures/custom-thumbnail.png b/packages/tests/fixtures/custom-thumbnail.png similarity index 100% rename from server/tests/fixtures/custom-thumbnail.png rename to packages/tests/fixtures/custom-thumbnail.png diff --git a/server/tests/fixtures/exif.jpg b/packages/tests/fixtures/exif.jpg similarity index 100% rename from server/tests/fixtures/exif.jpg rename to packages/tests/fixtures/exif.jpg diff --git a/server/tests/fixtures/exif.png b/packages/tests/fixtures/exif.png similarity index 100% rename from server/tests/fixtures/exif.png rename to packages/tests/fixtures/exif.png diff --git a/server/tests/fixtures/live/0-000067.ts b/packages/tests/fixtures/live/0-000067.ts similarity index 100% rename from server/tests/fixtures/live/0-000067.ts rename to packages/tests/fixtures/live/0-000067.ts diff --git a/server/tests/fixtures/live/0-000068.ts b/packages/tests/fixtures/live/0-000068.ts similarity index 100% rename from server/tests/fixtures/live/0-000068.ts rename to packages/tests/fixtures/live/0-000068.ts diff --git a/server/tests/fixtures/live/0-000069.ts b/packages/tests/fixtures/live/0-000069.ts similarity index 100% rename from server/tests/fixtures/live/0-000069.ts rename to packages/tests/fixtures/live/0-000069.ts diff --git a/server/tests/fixtures/live/0-000070.ts b/packages/tests/fixtures/live/0-000070.ts similarity index 100% rename from server/tests/fixtures/live/0-000070.ts rename to packages/tests/fixtures/live/0-000070.ts diff --git a/server/tests/fixtures/live/0.m3u8 b/packages/tests/fixtures/live/0.m3u8 similarity index 100% rename from server/tests/fixtures/live/0.m3u8 rename to packages/tests/fixtures/live/0.m3u8 diff --git a/server/tests/fixtures/live/1-000067.ts b/packages/tests/fixtures/live/1-000067.ts similarity index 100% rename from server/tests/fixtures/live/1-000067.ts rename to packages/tests/fixtures/live/1-000067.ts diff --git a/server/tests/fixtures/live/1-000068.ts b/packages/tests/fixtures/live/1-000068.ts similarity index 100% rename from server/tests/fixtures/live/1-000068.ts rename to packages/tests/fixtures/live/1-000068.ts diff --git a/server/tests/fixtures/live/1-000069.ts b/packages/tests/fixtures/live/1-000069.ts similarity index 100% rename from server/tests/fixtures/live/1-000069.ts rename to packages/tests/fixtures/live/1-000069.ts diff --git a/server/tests/fixtures/live/1-000070.ts b/packages/tests/fixtures/live/1-000070.ts similarity index 100% rename from server/tests/fixtures/live/1-000070.ts rename to packages/tests/fixtures/live/1-000070.ts diff --git a/server/tests/fixtures/live/1.m3u8 b/packages/tests/fixtures/live/1.m3u8 similarity index 100% rename from server/tests/fixtures/live/1.m3u8 rename to packages/tests/fixtures/live/1.m3u8 diff --git a/server/tests/fixtures/live/master.m3u8 b/packages/tests/fixtures/live/master.m3u8 similarity index 100% rename from server/tests/fixtures/live/master.m3u8 rename to packages/tests/fixtures/live/master.m3u8 diff --git a/server/tests/fixtures/low-bitrate.mp4 b/packages/tests/fixtures/low-bitrate.mp4 similarity index 100% rename from server/tests/fixtures/low-bitrate.mp4 rename to packages/tests/fixtures/low-bitrate.mp4 diff --git a/server/tests/fixtures/peertube-plugin-test-broken/main.js b/packages/tests/fixtures/peertube-plugin-test-broken/main.js similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-broken/main.js rename to packages/tests/fixtures/peertube-plugin-test-broken/main.js diff --git a/server/tests/fixtures/peertube-plugin-test-broken/package.json b/packages/tests/fixtures/peertube-plugin-test-broken/package.json similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-broken/package.json rename to packages/tests/fixtures/peertube-plugin-test-broken/package.json diff --git a/server/tests/fixtures/peertube-plugin-test-external-auth-one/main.js b/packages/tests/fixtures/peertube-plugin-test-external-auth-one/main.js similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-external-auth-one/main.js rename to packages/tests/fixtures/peertube-plugin-test-external-auth-one/main.js diff --git a/server/tests/fixtures/peertube-plugin-test-external-auth-one/package.json b/packages/tests/fixtures/peertube-plugin-test-external-auth-one/package.json similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-external-auth-one/package.json rename to packages/tests/fixtures/peertube-plugin-test-external-auth-one/package.json diff --git a/server/tests/fixtures/peertube-plugin-test-external-auth-three/main.js b/packages/tests/fixtures/peertube-plugin-test-external-auth-three/main.js similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-external-auth-three/main.js rename to packages/tests/fixtures/peertube-plugin-test-external-auth-three/main.js diff --git a/server/tests/fixtures/peertube-plugin-test-external-auth-three/package.json b/packages/tests/fixtures/peertube-plugin-test-external-auth-three/package.json similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-external-auth-three/package.json rename to packages/tests/fixtures/peertube-plugin-test-external-auth-three/package.json diff --git a/server/tests/fixtures/peertube-plugin-test-external-auth-two/main.js b/packages/tests/fixtures/peertube-plugin-test-external-auth-two/main.js similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-external-auth-two/main.js rename to packages/tests/fixtures/peertube-plugin-test-external-auth-two/main.js diff --git a/server/tests/fixtures/peertube-plugin-test-external-auth-two/package.json b/packages/tests/fixtures/peertube-plugin-test-external-auth-two/package.json similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-external-auth-two/package.json rename to packages/tests/fixtures/peertube-plugin-test-external-auth-two/package.json diff --git a/server/tests/fixtures/peertube-plugin-test-filter-translations/languages/fr.json b/packages/tests/fixtures/peertube-plugin-test-filter-translations/languages/fr.json similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-filter-translations/languages/fr.json rename to packages/tests/fixtures/peertube-plugin-test-filter-translations/languages/fr.json diff --git a/server/tests/fixtures/peertube-plugin-test-filter-translations/languages/it.json b/packages/tests/fixtures/peertube-plugin-test-filter-translations/languages/it.json similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-filter-translations/languages/it.json rename to packages/tests/fixtures/peertube-plugin-test-filter-translations/languages/it.json diff --git a/server/tests/fixtures/peertube-plugin-test-filter-translations/main.js b/packages/tests/fixtures/peertube-plugin-test-filter-translations/main.js similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-filter-translations/main.js rename to packages/tests/fixtures/peertube-plugin-test-filter-translations/main.js diff --git a/server/tests/fixtures/peertube-plugin-test-filter-translations/package.json b/packages/tests/fixtures/peertube-plugin-test-filter-translations/package.json similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-filter-translations/package.json rename to packages/tests/fixtures/peertube-plugin-test-filter-translations/package.json diff --git a/server/tests/fixtures/peertube-plugin-test-five/main.js b/packages/tests/fixtures/peertube-plugin-test-five/main.js similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-five/main.js rename to packages/tests/fixtures/peertube-plugin-test-five/main.js diff --git a/server/tests/fixtures/peertube-plugin-test-five/package.json b/packages/tests/fixtures/peertube-plugin-test-five/package.json similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-five/package.json rename to packages/tests/fixtures/peertube-plugin-test-five/package.json diff --git a/server/tests/fixtures/peertube-plugin-test-four/main.js b/packages/tests/fixtures/peertube-plugin-test-four/main.js similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-four/main.js rename to packages/tests/fixtures/peertube-plugin-test-four/main.js diff --git a/server/tests/fixtures/peertube-plugin-test-four/package.json b/packages/tests/fixtures/peertube-plugin-test-four/package.json similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-four/package.json rename to packages/tests/fixtures/peertube-plugin-test-four/package.json diff --git a/server/tests/fixtures/peertube-plugin-test-id-pass-auth-one/main.js b/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-one/main.js similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-id-pass-auth-one/main.js rename to packages/tests/fixtures/peertube-plugin-test-id-pass-auth-one/main.js diff --git a/server/tests/fixtures/peertube-plugin-test-id-pass-auth-one/package.json b/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-one/package.json similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-id-pass-auth-one/package.json rename to packages/tests/fixtures/peertube-plugin-test-id-pass-auth-one/package.json diff --git a/server/tests/fixtures/peertube-plugin-test-id-pass-auth-three/main.js b/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-three/main.js similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-id-pass-auth-three/main.js rename to packages/tests/fixtures/peertube-plugin-test-id-pass-auth-three/main.js diff --git a/server/tests/fixtures/peertube-plugin-test-id-pass-auth-three/package.json b/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-three/package.json similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-id-pass-auth-three/package.json rename to packages/tests/fixtures/peertube-plugin-test-id-pass-auth-three/package.json diff --git a/server/tests/fixtures/peertube-plugin-test-id-pass-auth-two/main.js b/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-two/main.js similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-id-pass-auth-two/main.js rename to packages/tests/fixtures/peertube-plugin-test-id-pass-auth-two/main.js diff --git a/server/tests/fixtures/peertube-plugin-test-id-pass-auth-two/package.json b/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-two/package.json similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-id-pass-auth-two/package.json rename to packages/tests/fixtures/peertube-plugin-test-id-pass-auth-two/package.json diff --git a/server/tests/fixtures/peertube-plugin-test-native/main.js b/packages/tests/fixtures/peertube-plugin-test-native/main.js similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-native/main.js rename to packages/tests/fixtures/peertube-plugin-test-native/main.js diff --git a/server/tests/fixtures/peertube-plugin-test-native/package.json b/packages/tests/fixtures/peertube-plugin-test-native/package.json similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-native/package.json rename to packages/tests/fixtures/peertube-plugin-test-native/package.json diff --git a/server/tests/fixtures/peertube-plugin-test-podcast-custom-tags/main.js b/packages/tests/fixtures/peertube-plugin-test-podcast-custom-tags/main.js similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-podcast-custom-tags/main.js rename to packages/tests/fixtures/peertube-plugin-test-podcast-custom-tags/main.js diff --git a/server/tests/fixtures/peertube-plugin-test-podcast-custom-tags/package.json b/packages/tests/fixtures/peertube-plugin-test-podcast-custom-tags/package.json similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-podcast-custom-tags/package.json rename to packages/tests/fixtures/peertube-plugin-test-podcast-custom-tags/package.json diff --git a/server/tests/fixtures/peertube-plugin-test-six/main.js b/packages/tests/fixtures/peertube-plugin-test-six/main.js similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-six/main.js rename to packages/tests/fixtures/peertube-plugin-test-six/main.js diff --git a/server/tests/fixtures/peertube-plugin-test-six/package.json b/packages/tests/fixtures/peertube-plugin-test-six/package.json similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-six/package.json rename to packages/tests/fixtures/peertube-plugin-test-six/package.json diff --git a/server/tests/fixtures/peertube-plugin-test-transcoding-one/main.js b/packages/tests/fixtures/peertube-plugin-test-transcoding-one/main.js similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-transcoding-one/main.js rename to packages/tests/fixtures/peertube-plugin-test-transcoding-one/main.js diff --git a/server/tests/fixtures/peertube-plugin-test-transcoding-one/package.json b/packages/tests/fixtures/peertube-plugin-test-transcoding-one/package.json similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-transcoding-one/package.json rename to packages/tests/fixtures/peertube-plugin-test-transcoding-one/package.json diff --git a/server/tests/fixtures/peertube-plugin-test-transcoding-two/main.js b/packages/tests/fixtures/peertube-plugin-test-transcoding-two/main.js similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-transcoding-two/main.js rename to packages/tests/fixtures/peertube-plugin-test-transcoding-two/main.js diff --git a/server/tests/fixtures/peertube-plugin-test-transcoding-two/package.json b/packages/tests/fixtures/peertube-plugin-test-transcoding-two/package.json similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-transcoding-two/package.json rename to packages/tests/fixtures/peertube-plugin-test-transcoding-two/package.json diff --git a/server/tests/fixtures/peertube-plugin-test-unloading/lib.js b/packages/tests/fixtures/peertube-plugin-test-unloading/lib.js similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-unloading/lib.js rename to packages/tests/fixtures/peertube-plugin-test-unloading/lib.js diff --git a/server/tests/fixtures/peertube-plugin-test-unloading/main.js b/packages/tests/fixtures/peertube-plugin-test-unloading/main.js similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-unloading/main.js rename to packages/tests/fixtures/peertube-plugin-test-unloading/main.js diff --git a/server/tests/fixtures/peertube-plugin-test-unloading/package.json b/packages/tests/fixtures/peertube-plugin-test-unloading/package.json similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-unloading/package.json rename to packages/tests/fixtures/peertube-plugin-test-unloading/package.json diff --git a/server/tests/fixtures/peertube-plugin-test-video-constants/main.js b/packages/tests/fixtures/peertube-plugin-test-video-constants/main.js similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-video-constants/main.js rename to packages/tests/fixtures/peertube-plugin-test-video-constants/main.js diff --git a/server/tests/fixtures/peertube-plugin-test-video-constants/package.json b/packages/tests/fixtures/peertube-plugin-test-video-constants/package.json similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-video-constants/package.json rename to packages/tests/fixtures/peertube-plugin-test-video-constants/package.json diff --git a/server/tests/fixtures/peertube-plugin-test-websocket/main.js b/packages/tests/fixtures/peertube-plugin-test-websocket/main.js similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-websocket/main.js rename to packages/tests/fixtures/peertube-plugin-test-websocket/main.js diff --git a/server/tests/fixtures/peertube-plugin-test-websocket/package.json b/packages/tests/fixtures/peertube-plugin-test-websocket/package.json similarity index 100% rename from server/tests/fixtures/peertube-plugin-test-websocket/package.json rename to packages/tests/fixtures/peertube-plugin-test-websocket/package.json diff --git a/server/tests/fixtures/peertube-plugin-test/languages/fr.json b/packages/tests/fixtures/peertube-plugin-test/languages/fr.json similarity index 100% rename from server/tests/fixtures/peertube-plugin-test/languages/fr.json rename to packages/tests/fixtures/peertube-plugin-test/languages/fr.json diff --git a/server/tests/fixtures/peertube-plugin-test/main.js b/packages/tests/fixtures/peertube-plugin-test/main.js similarity index 100% rename from server/tests/fixtures/peertube-plugin-test/main.js rename to packages/tests/fixtures/peertube-plugin-test/main.js diff --git a/server/tests/fixtures/peertube-plugin-test/package.json b/packages/tests/fixtures/peertube-plugin-test/package.json similarity index 100% rename from server/tests/fixtures/peertube-plugin-test/package.json rename to packages/tests/fixtures/peertube-plugin-test/package.json diff --git a/server/tests/fixtures/rtmps.cert b/packages/tests/fixtures/rtmps.cert similarity index 100% rename from server/tests/fixtures/rtmps.cert rename to packages/tests/fixtures/rtmps.cert diff --git a/server/tests/fixtures/rtmps.key b/packages/tests/fixtures/rtmps.key similarity index 100% rename from server/tests/fixtures/rtmps.key rename to packages/tests/fixtures/rtmps.key diff --git a/server/tests/fixtures/sample.ogg b/packages/tests/fixtures/sample.ogg similarity index 100% rename from server/tests/fixtures/sample.ogg rename to packages/tests/fixtures/sample.ogg diff --git a/server/tests/fixtures/subtitle-bad.txt b/packages/tests/fixtures/subtitle-bad.txt similarity index 100% rename from server/tests/fixtures/subtitle-bad.txt rename to packages/tests/fixtures/subtitle-bad.txt diff --git a/server/tests/fixtures/subtitle-good.srt b/packages/tests/fixtures/subtitle-good.srt similarity index 100% rename from server/tests/fixtures/subtitle-good.srt rename to packages/tests/fixtures/subtitle-good.srt diff --git a/server/tests/fixtures/subtitle-good1.vtt b/packages/tests/fixtures/subtitle-good1.vtt similarity index 100% rename from server/tests/fixtures/subtitle-good1.vtt rename to packages/tests/fixtures/subtitle-good1.vtt diff --git a/server/tests/fixtures/subtitle-good2.vtt b/packages/tests/fixtures/subtitle-good2.vtt similarity index 100% rename from server/tests/fixtures/subtitle-good2.vtt rename to packages/tests/fixtures/subtitle-good2.vtt diff --git a/server/tests/fixtures/thumbnail-playlist.jpg b/packages/tests/fixtures/thumbnail-playlist.jpg similarity index 100% rename from server/tests/fixtures/thumbnail-playlist.jpg rename to packages/tests/fixtures/thumbnail-playlist.jpg diff --git a/server/tests/fixtures/video-720p.torrent b/packages/tests/fixtures/video-720p.torrent similarity index 100% rename from server/tests/fixtures/video-720p.torrent rename to packages/tests/fixtures/video-720p.torrent diff --git a/server/tests/fixtures/video_import_preview.jpg b/packages/tests/fixtures/video_import_preview.jpg similarity index 100% rename from server/tests/fixtures/video_import_preview.jpg rename to packages/tests/fixtures/video_import_preview.jpg diff --git a/server/tests/fixtures/video_import_preview_yt_dlp.jpg b/packages/tests/fixtures/video_import_preview_yt_dlp.jpg similarity index 100% rename from server/tests/fixtures/video_import_preview_yt_dlp.jpg rename to packages/tests/fixtures/video_import_preview_yt_dlp.jpg diff --git a/server/tests/fixtures/video_import_thumbnail.jpg b/packages/tests/fixtures/video_import_thumbnail.jpg similarity index 100% rename from server/tests/fixtures/video_import_thumbnail.jpg rename to packages/tests/fixtures/video_import_thumbnail.jpg diff --git a/server/tests/fixtures/video_import_thumbnail_yt_dlp.jpg b/packages/tests/fixtures/video_import_thumbnail_yt_dlp.jpg similarity index 100% rename from server/tests/fixtures/video_import_thumbnail_yt_dlp.jpg rename to packages/tests/fixtures/video_import_thumbnail_yt_dlp.jpg diff --git a/server/tests/fixtures/video_short.avi b/packages/tests/fixtures/video_short.avi similarity index 100% rename from server/tests/fixtures/video_short.avi rename to packages/tests/fixtures/video_short.avi diff --git a/server/tests/fixtures/video_short.mkv b/packages/tests/fixtures/video_short.mkv similarity index 100% rename from server/tests/fixtures/video_short.mkv rename to packages/tests/fixtures/video_short.mkv diff --git a/server/tests/fixtures/video_short.mp4 b/packages/tests/fixtures/video_short.mp4 similarity index 100% rename from server/tests/fixtures/video_short.mp4 rename to packages/tests/fixtures/video_short.mp4 diff --git a/server/tests/fixtures/video_short.mp4.jpg b/packages/tests/fixtures/video_short.mp4.jpg similarity index 100% rename from server/tests/fixtures/video_short.mp4.jpg rename to packages/tests/fixtures/video_short.mp4.jpg diff --git a/server/tests/fixtures/video_short.ogv b/packages/tests/fixtures/video_short.ogv similarity index 100% rename from server/tests/fixtures/video_short.ogv rename to packages/tests/fixtures/video_short.ogv diff --git a/server/tests/fixtures/video_short.ogv.jpg b/packages/tests/fixtures/video_short.ogv.jpg similarity index 100% rename from server/tests/fixtures/video_short.ogv.jpg rename to packages/tests/fixtures/video_short.ogv.jpg diff --git a/server/tests/fixtures/video_short.webm b/packages/tests/fixtures/video_short.webm similarity index 100% rename from server/tests/fixtures/video_short.webm rename to packages/tests/fixtures/video_short.webm diff --git a/server/tests/fixtures/video_short.webm.jpg b/packages/tests/fixtures/video_short.webm.jpg similarity index 100% rename from server/tests/fixtures/video_short.webm.jpg rename to packages/tests/fixtures/video_short.webm.jpg diff --git a/server/tests/fixtures/video_short1-preview.webm.jpg b/packages/tests/fixtures/video_short1-preview.webm.jpg similarity index 100% rename from server/tests/fixtures/video_short1-preview.webm.jpg rename to packages/tests/fixtures/video_short1-preview.webm.jpg diff --git a/server/tests/fixtures/video_short1.webm b/packages/tests/fixtures/video_short1.webm similarity index 100% rename from server/tests/fixtures/video_short1.webm rename to packages/tests/fixtures/video_short1.webm diff --git a/server/tests/fixtures/video_short1.webm.jpg b/packages/tests/fixtures/video_short1.webm.jpg similarity index 100% rename from server/tests/fixtures/video_short1.webm.jpg rename to packages/tests/fixtures/video_short1.webm.jpg diff --git a/server/tests/fixtures/video_short2.webm b/packages/tests/fixtures/video_short2.webm similarity index 100% rename from server/tests/fixtures/video_short2.webm rename to packages/tests/fixtures/video_short2.webm diff --git a/server/tests/fixtures/video_short2.webm.jpg b/packages/tests/fixtures/video_short2.webm.jpg similarity index 100% rename from server/tests/fixtures/video_short2.webm.jpg rename to packages/tests/fixtures/video_short2.webm.jpg diff --git a/server/tests/fixtures/video_short3.webm b/packages/tests/fixtures/video_short3.webm similarity index 100% rename from server/tests/fixtures/video_short3.webm rename to packages/tests/fixtures/video_short3.webm diff --git a/server/tests/fixtures/video_short3.webm.jpg b/packages/tests/fixtures/video_short3.webm.jpg similarity index 100% rename from server/tests/fixtures/video_short3.webm.jpg rename to packages/tests/fixtures/video_short3.webm.jpg diff --git a/server/tests/fixtures/video_short_0p.mp4 b/packages/tests/fixtures/video_short_0p.mp4 similarity index 100% rename from server/tests/fixtures/video_short_0p.mp4 rename to packages/tests/fixtures/video_short_0p.mp4 diff --git a/server/tests/fixtures/video_short_144p.m3u8 b/packages/tests/fixtures/video_short_144p.m3u8 similarity index 100% rename from server/tests/fixtures/video_short_144p.m3u8 rename to packages/tests/fixtures/video_short_144p.m3u8 diff --git a/server/tests/fixtures/video_short_144p.mp4 b/packages/tests/fixtures/video_short_144p.mp4 similarity index 100% rename from server/tests/fixtures/video_short_144p.mp4 rename to packages/tests/fixtures/video_short_144p.mp4 diff --git a/server/tests/fixtures/video_short_240p.m3u8 b/packages/tests/fixtures/video_short_240p.m3u8 similarity index 100% rename from server/tests/fixtures/video_short_240p.m3u8 rename to packages/tests/fixtures/video_short_240p.m3u8 diff --git a/server/tests/fixtures/video_short_240p.mp4 b/packages/tests/fixtures/video_short_240p.mp4 similarity index 100% rename from server/tests/fixtures/video_short_240p.mp4 rename to packages/tests/fixtures/video_short_240p.mp4 diff --git a/server/tests/fixtures/video_short_360p.m3u8 b/packages/tests/fixtures/video_short_360p.m3u8 similarity index 100% rename from server/tests/fixtures/video_short_360p.m3u8 rename to packages/tests/fixtures/video_short_360p.m3u8 diff --git a/server/tests/fixtures/video_short_360p.mp4 b/packages/tests/fixtures/video_short_360p.mp4 similarity index 100% rename from server/tests/fixtures/video_short_360p.mp4 rename to packages/tests/fixtures/video_short_360p.mp4 diff --git a/server/tests/fixtures/video_short_480.webm b/packages/tests/fixtures/video_short_480.webm similarity index 100% rename from server/tests/fixtures/video_short_480.webm rename to packages/tests/fixtures/video_short_480.webm diff --git a/server/tests/fixtures/video_short_480p.m3u8 b/packages/tests/fixtures/video_short_480p.m3u8 similarity index 100% rename from server/tests/fixtures/video_short_480p.m3u8 rename to packages/tests/fixtures/video_short_480p.m3u8 diff --git a/server/tests/fixtures/video_short_480p.mp4 b/packages/tests/fixtures/video_short_480p.mp4 similarity index 100% rename from server/tests/fixtures/video_short_480p.mp4 rename to packages/tests/fixtures/video_short_480p.mp4 diff --git a/server/tests/fixtures/video_short_4k.mp4 b/packages/tests/fixtures/video_short_4k.mp4 similarity index 100% rename from server/tests/fixtures/video_short_4k.mp4 rename to packages/tests/fixtures/video_short_4k.mp4 diff --git a/server/tests/fixtures/video_short_720p.m3u8 b/packages/tests/fixtures/video_short_720p.m3u8 similarity index 100% rename from server/tests/fixtures/video_short_720p.m3u8 rename to packages/tests/fixtures/video_short_720p.m3u8 diff --git a/server/tests/fixtures/video_short_720p.mp4 b/packages/tests/fixtures/video_short_720p.mp4 similarity index 100% rename from server/tests/fixtures/video_short_720p.mp4 rename to packages/tests/fixtures/video_short_720p.mp4 diff --git a/server/tests/fixtures/video_short_fake.webm b/packages/tests/fixtures/video_short_fake.webm similarity index 100% rename from server/tests/fixtures/video_short_fake.webm rename to packages/tests/fixtures/video_short_fake.webm diff --git a/server/tests/fixtures/video_short_mp3_256k.mp4 b/packages/tests/fixtures/video_short_mp3_256k.mp4 similarity index 100% rename from server/tests/fixtures/video_short_mp3_256k.mp4 rename to packages/tests/fixtures/video_short_mp3_256k.mp4 diff --git a/server/tests/fixtures/video_short_no_audio.mp4 b/packages/tests/fixtures/video_short_no_audio.mp4 similarity index 100% rename from server/tests/fixtures/video_short_no_audio.mp4 rename to packages/tests/fixtures/video_short_no_audio.mp4 diff --git a/server/tests/fixtures/video_very_long_10p.mp4 b/packages/tests/fixtures/video_very_long_10p.mp4 similarity index 100% rename from server/tests/fixtures/video_very_long_10p.mp4 rename to packages/tests/fixtures/video_very_long_10p.mp4 diff --git a/server/tests/fixtures/video_very_short_240p.mp4 b/packages/tests/fixtures/video_very_short_240p.mp4 similarity index 100% rename from server/tests/fixtures/video_very_short_240p.mp4 rename to packages/tests/fixtures/video_very_short_240p.mp4 diff --git a/packages/tests/package.json b/packages/tests/package.json new file mode 100644 index 000000000..02882ebc7 --- /dev/null +++ b/packages/tests/package.json @@ -0,0 +1,12 @@ +{ + "name": "@peertube/tests", + "private": true, + "version": "0.0.0", + "type": "module", + "devDependencies": {}, + "scripts": { + "build": "tsc", + "watch": "tsc -w" + }, + "dependencies": {} +} diff --git a/server/tests/api/activitypub/cleaner.ts b/packages/tests/src/api/activitypub/cleaner.ts similarity index 98% rename from server/tests/api/activitypub/cleaner.ts rename to packages/tests/src/api/activitypub/cleaner.ts index d67175e20..4476aea85 100644 --- a/server/tests/api/activitypub/cleaner.ts +++ b/packages/tests/src/api/activitypub/cleaner.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { SQLCommand } from '@server/tests/shared' -import { wait } from '@shared/core-utils' +import { SQLCommand } from '@tests/shared/sql-command.js' +import { wait } from '@peertube/peertube-core-utils' import { cleanupTests, createMultipleServers, @@ -10,7 +10,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test AP cleaner', function () { let servers: PeerTubeServer[] = [] diff --git a/server/tests/api/activitypub/client.ts b/packages/tests/src/api/activitypub/client.ts similarity index 97% rename from server/tests/api/activitypub/client.ts rename to packages/tests/src/api/activitypub/client.ts index 572a358a0..fb9575d31 100644 --- a/server/tests/api/activitypub/client.ts +++ b/packages/tests/src/api/activitypub/client.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { processViewersStats } from '@server/tests/shared' -import { HttpStatusCode, VideoPlaylistPrivacy, WatchActionObject } from '@shared/models' +import { processViewersStats } from '@tests/shared/views.js' +import { HttpStatusCode, VideoPlaylistPrivacy, WatchActionObject } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -11,7 +11,7 @@ import { PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test activitypub', function () { let servers: PeerTubeServer[] = [] diff --git a/server/tests/api/activitypub/fetch.ts b/packages/tests/src/api/activitypub/fetch.ts similarity index 95% rename from server/tests/api/activitypub/fetch.ts rename to packages/tests/src/api/activitypub/fetch.ts index 3899a6a49..c7f5288cc 100644 --- a/server/tests/api/activitypub/fetch.ts +++ b/packages/tests/src/api/activitypub/fetch.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { SQLCommand } from '@server/tests/shared' +import { SQLCommand } from '@tests/shared/sql-command.js' import { cleanupTests, createMultipleServers, @@ -9,7 +9,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test ActivityPub fetcher', function () { let servers: PeerTubeServer[] diff --git a/packages/tests/src/api/activitypub/index.ts b/packages/tests/src/api/activitypub/index.ts new file mode 100644 index 000000000..ef4f1aafb --- /dev/null +++ b/packages/tests/src/api/activitypub/index.ts @@ -0,0 +1,5 @@ +import './cleaner.js' +import './client.js' +import './fetch.js' +import './refresher.js' +import './security.js' diff --git a/server/tests/api/activitypub/refresher.ts b/packages/tests/src/api/activitypub/refresher.ts similarity index 94% rename from server/tests/api/activitypub/refresher.ts rename to packages/tests/src/api/activitypub/refresher.ts index 4ea7929ec..90aa1a5ad 100644 --- a/server/tests/api/activitypub/refresher.ts +++ b/packages/tests/src/api/activitypub/refresher.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { SQLCommand } from '@server/tests/shared' -import { wait } from '@shared/core-utils' -import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models' +import { SQLCommand } from '@tests/shared/sql-command.js' +import { wait } from '@peertube/peertube-core-utils' +import { HttpStatusCode, VideoPlaylistPrivacy } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -12,7 +12,7 @@ import { setAccessTokensToServers, setDefaultVideoChannel, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test AP refresher', function () { let servers: PeerTubeServer[] = [] @@ -24,7 +24,7 @@ describe('Test AP refresher', function () { let playlistUUID2: string before(async function () { - this.timeout(60000) + this.timeout(240000) servers = await createMultipleServers(2) diff --git a/server/tests/api/activitypub/security.ts b/packages/tests/src/api/activitypub/security.ts similarity index 82% rename from server/tests/api/activitypub/security.ts rename to packages/tests/src/api/activitypub/security.ts index 8e87361a9..d9649de50 100644 --- a/server/tests/api/activitypub/security.ts +++ b/packages/tests/src/api/activitypub/security.ts @@ -1,14 +1,24 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ +import { wait } from '@peertube/peertube-core-utils' +import { HttpStatusCode } from '@peertube/peertube-models' +import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils' +import { PeerTubeServer, cleanupTests, createMultipleServers, killallServers } from '@peertube/peertube-server-commands' +import { + activityPubContextify, + buildGlobalHTTPHeaders, + signAndContextify +} from '@peertube/peertube-server/server/helpers/activity-pub-utils.js' +import { buildDigest } from '@peertube/peertube-server/server/helpers/peertube-crypto.js' +import { ACTIVITY_PUB, HTTP_SIGNATURE } from '@peertube/peertube-server/server/initializers/constants.js' +import { makePOSTAPRequest } from '@tests/shared/requests.js' +import { SQLCommand } from '@tests/shared/sql-command.js' import { expect } from 'chai' -import { buildDigest } from '@server/helpers/peertube-crypto' -import { ACTIVITY_PUB, HTTP_SIGNATURE } from '@server/initializers/constants' -import { activityPubContextify } from '@server/lib/activitypub/context' -import { buildGlobalHeaders, signAndContextify } from '@server/lib/activitypub/send' -import { makePOSTAPRequest, SQLCommand } from '@server/tests/shared' -import { buildAbsoluteFixturePath, wait } from '@shared/core-utils' -import { HttpStatusCode } from '@shared/models' -import { cleanupTests, createMultipleServers, killallServers, PeerTubeServer } from '@shared/server-commands' +import { readJsonSync } from 'fs-extra/esm' + +function fakeFilter () { + return (data: any) => Promise.resolve(data) +} function setKeysOfServer (onServer: SQLCommand, ofServerUrl: string, publicKey: string, privateKey: string) { const url = ofServerUrl + '/accounts/peertube' @@ -29,7 +39,7 @@ function setUpdatedAtOfServer (onServer: SQLCommand, ofServerUrl: string, update } function getAnnounceWithoutContext (server: PeerTubeServer) { - const json = require(buildAbsoluteFixturePath('./ap-json/peertube/announce-without-context.json')) + const json = readJsonSync(buildAbsoluteFixturePath('./ap-json/peertube/announce-without-context.json')) const result: typeof json = {} for (const key of Object.keys(json)) { @@ -51,7 +61,7 @@ async function makeFollowRequest (to: { url: string }, by: { url: string, privat object: to.url } - const body = await activityPubContextify(follow, 'Follow') + const body = await activityPubContextify(follow, 'Follow', fakeFilter()) const httpSignature = { algorithm: HTTP_SIGNATURE.ALGORITHM, @@ -75,8 +85,8 @@ describe('Test ActivityPub security', function () { let url: string - const keys = require(buildAbsoluteFixturePath('./ap-json/peertube/keys.json')) - const invalidKeys = require(buildAbsoluteFixturePath('./ap-json/peertube/invalid-keys.json')) + const keys = readJsonSync(buildAbsoluteFixturePath('./ap-json/peertube/keys.json')) + const invalidKeys = readJsonSync(buildAbsoluteFixturePath('./ap-json/peertube/invalid-keys.json')) const baseHttpSignature = () => ({ algorithm: HTTP_SIGNATURE.ALGORITHM, authorizationHeaderName: HTTP_SIGNATURE.HEADER_NAME, @@ -107,7 +117,7 @@ describe('Test ActivityPub security', function () { describe('When checking HTTP signature', function () { it('Should fail with an invalid digest', async function () { - const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce') + const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce', fakeFilter()) const headers = { Digest: buildDigest({ hello: 'coucou' }) } @@ -121,8 +131,8 @@ describe('Test ActivityPub security', function () { }) it('Should fail with an invalid date', async function () { - const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce') - const headers = buildGlobalHeaders(body) + const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce', fakeFilter()) + const headers = buildGlobalHTTPHeaders(body) headers['date'] = 'Wed, 21 Oct 2015 07:28:00 GMT' try { @@ -137,8 +147,8 @@ describe('Test ActivityPub security', function () { await setKeysOfServer(sqlCommands[0], servers[1].url, invalidKeys.publicKey, invalidKeys.privateKey) await setKeysOfServer(sqlCommands[1], servers[1].url, invalidKeys.publicKey, invalidKeys.privateKey) - const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce') - const headers = buildGlobalHeaders(body) + const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce', fakeFilter()) + const headers = buildGlobalHTTPHeaders(body) try { await makePOSTAPRequest(url, body, baseHttpSignature(), headers) @@ -152,8 +162,8 @@ describe('Test ActivityPub security', function () { await setKeysOfServer(sqlCommands[0], servers[1].url, keys.publicKey, keys.privateKey) await setKeysOfServer(sqlCommands[1], servers[1].url, keys.publicKey, keys.privateKey) - const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce') - const headers = buildGlobalHeaders(body) + const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce', fakeFilter()) + const headers = buildGlobalHTTPHeaders(body) const signatureOptions = baseHttpSignature() const badHeadersMatrix = [ @@ -175,8 +185,8 @@ describe('Test ActivityPub security', function () { }) it('Should succeed with a valid HTTP signature draft 11 (without date but with (created))', async function () { - const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce') - const headers = buildGlobalHeaders(body) + const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce', fakeFilter()) + const headers = buildGlobalHTTPHeaders(body) const signatureOptions = baseHttpSignature() signatureOptions.headers = [ '(request-target)', '(created)', 'host', 'digest' ] @@ -186,8 +196,8 @@ describe('Test ActivityPub security', function () { }) it('Should succeed with a valid HTTP signature', async function () { - const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce') - const headers = buildGlobalHeaders(body) + const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce', fakeFilter()) + const headers = buildGlobalHTTPHeaders(body) const { statusCode } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers) expect(statusCode).to.equal(HttpStatusCode.NO_CONTENT_204) @@ -205,8 +215,8 @@ describe('Test ActivityPub security', function () { await killallServers([ servers[1] ]) await servers[1].run() - const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce') - const headers = buildGlobalHeaders(body) + const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce', fakeFilter()) + const headers = buildGlobalHTTPHeaders(body) try { await makePOSTAPRequest(url, body, baseHttpSignature(), headers) @@ -237,9 +247,9 @@ describe('Test ActivityPub security', function () { body.actor = servers[2].url + '/accounts/peertube' const signer: any = { privateKey: invalidKeys.privateKey, url: servers[2].url + '/accounts/peertube' } - const signedBody = await signAndContextify(signer, body, 'Announce') + const signedBody = await signAndContextify(signer, body, 'Announce', fakeFilter()) - const headers = buildGlobalHeaders(signedBody) + const headers = buildGlobalHTTPHeaders(signedBody) try { await makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers) @@ -257,11 +267,11 @@ describe('Test ActivityPub security', function () { body.actor = servers[2].url + '/accounts/peertube' const signer: any = { privateKey: keys.privateKey, url: servers[2].url + '/accounts/peertube' } - const signedBody = await signAndContextify(signer, body, 'Announce') + const signedBody = await signAndContextify(signer, body, 'Announce', fakeFilter()) signedBody.actor = servers[2].url + '/account/peertube' - const headers = buildGlobalHeaders(signedBody) + const headers = buildGlobalHTTPHeaders(signedBody) try { await makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers) @@ -276,9 +286,9 @@ describe('Test ActivityPub security', function () { body.actor = servers[2].url + '/accounts/peertube' const signer: any = { privateKey: keys.privateKey, url: servers[2].url + '/accounts/peertube' } - const signedBody = await signAndContextify(signer, body, 'Announce') + const signedBody = await signAndContextify(signer, body, 'Announce', fakeFilter()) - const headers = buildGlobalHeaders(signedBody) + const headers = buildGlobalHTTPHeaders(signedBody) const { statusCode } = await makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers) expect(statusCode).to.equal(HttpStatusCode.NO_CONTENT_204) @@ -298,9 +308,9 @@ describe('Test ActivityPub security', function () { body.actor = servers[2].url + '/accounts/peertube' const signer: any = { privateKey: keys.privateKey, url: servers[2].url + '/accounts/peertube' } - const signedBody = await signAndContextify(signer, body, 'Announce') + const signedBody = await signAndContextify(signer, body, 'Announce', fakeFilter()) - const headers = buildGlobalHeaders(signedBody) + const headers = buildGlobalHTTPHeaders(signedBody) try { await makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers) diff --git a/server/tests/api/check-params/abuses.ts b/packages/tests/src/api/check-params/abuses.ts similarity index 98% rename from server/tests/api/check-params/abuses.ts rename to packages/tests/src/api/check-params/abuses.ts index 331d3f8f7..1effc82b1 100644 --- a/server/tests/api/check-params/abuses.ts +++ b/packages/tests/src/api/check-params/abuses.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' -import { AbuseCreate, AbuseState, HttpStatusCode } from '@shared/models' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@tests/shared/checks.js' +import { AbuseCreate, AbuseState, HttpStatusCode } from '@peertube/peertube-models' import { AbusesCommand, cleanupTests, @@ -12,7 +12,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test abuses API validators', function () { const basePath = '/api/v1/abuses/' @@ -298,7 +298,7 @@ describe('Test abuses API validators', function () { }) it('Should fail with a bad state', async function () { - const body = { state: 5 } + const body = { state: 5 as any } await command.update({ abuseId, body, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) }) diff --git a/server/tests/api/check-params/accounts.ts b/packages/tests/src/api/check-params/accounts.ts similarity index 90% rename from server/tests/api/check-params/accounts.ts rename to packages/tests/src/api/check-params/accounts.ts index afc0049ff..87810bbd3 100644 --- a/server/tests/api/check-params/accounts.ts +++ b/packages/tests/src/api/check-params/accounts.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' -import { HttpStatusCode } from '@shared/models' -import { cleanupTests, createSingleServer, PeerTubeServer } from '@shared/server-commands' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@tests/shared/checks.js' +import { HttpStatusCode } from '@peertube/peertube-models' +import { cleanupTests, createSingleServer, PeerTubeServer } from '@peertube/peertube-server-commands' describe('Test accounts API validators', function () { const path = '/api/v1/accounts/' diff --git a/server/tests/api/check-params/blocklist.ts b/packages/tests/src/api/check-params/blocklist.ts similarity index 99% rename from server/tests/api/check-params/blocklist.ts rename to packages/tests/src/api/check-params/blocklist.ts index 169b591a3..fcd6d08f8 100644 --- a/server/tests/api/check-params/blocklist.ts +++ b/packages/tests/src/api/check-params/blocklist.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' -import { HttpStatusCode } from '@shared/models' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@tests/shared/checks.js' +import { HttpStatusCode } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -11,7 +11,7 @@ import { makePostBodyRequest, PeerTubeServer, setAccessTokensToServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test blocklist API validators', function () { let servers: PeerTubeServer[] diff --git a/server/tests/api/check-params/bulk.ts b/packages/tests/src/api/check-params/bulk.ts similarity index 91% rename from server/tests/api/check-params/bulk.ts rename to packages/tests/src/api/check-params/bulk.ts index f03264b4f..def0c38eb 100644 --- a/server/tests/api/check-params/bulk.ts +++ b/packages/tests/src/api/check-params/bulk.ts @@ -1,7 +1,13 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { cleanupTests, createSingleServer, makePostBodyRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode } from '@peertube/peertube-models' +import { + cleanupTests, + createSingleServer, + makePostBodyRequest, + PeerTubeServer, + setAccessTokensToServers +} from '@peertube/peertube-server-commands' describe('Test bulk API validators', function () { let server: PeerTubeServer diff --git a/server/tests/api/check-params/channel-import-videos.ts b/packages/tests/src/api/check-params/channel-import-videos.ts similarity index 96% rename from server/tests/api/check-params/channel-import-videos.ts rename to packages/tests/src/api/check-params/channel-import-videos.ts index 2de13b629..0e897dad7 100644 --- a/server/tests/api/check-params/channel-import-videos.ts +++ b/packages/tests/src/api/check-params/channel-import-videos.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { FIXTURE_URLS } from '@server/tests/shared' -import { areHttpImportTestsDisabled } from '@shared/core-utils' -import { HttpStatusCode } from '@shared/models' +import { FIXTURE_URLS } from '@tests/shared/tests.js' +import { areHttpImportTestsDisabled } from '@peertube/peertube-node-utils' +import { HttpStatusCode } from '@peertube/peertube-models' import { ChannelsCommand, cleanupTests, @@ -10,7 +10,7 @@ import { PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test videos import in a channel API validator', function () { let server: PeerTubeServer diff --git a/server/tests/api/check-params/config.ts b/packages/tests/src/api/check-params/config.ts similarity index 97% rename from server/tests/api/check-params/config.ts rename to packages/tests/src/api/check-params/config.ts index 2f523d4ce..8179a8815 100644 --- a/server/tests/api/check-params/config.ts +++ b/packages/tests/src/api/check-params/config.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { merge } from 'lodash' -import { omit } from '@shared/core-utils' -import { CustomConfig, HttpStatusCode } from '@shared/models' +import merge from 'lodash-es/merge.js' +import { omit } from '@peertube/peertube-core-utils' +import { CustomConfig, HttpStatusCode } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -10,7 +10,7 @@ import { makePutBodyRequest, PeerTubeServer, setAccessTokensToServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test config API validators', function () { const path = '/api/v1/config/custom' diff --git a/server/tests/api/check-params/contact-form.ts b/packages/tests/src/api/check-params/contact-form.ts similarity index 94% rename from server/tests/api/check-params/contact-form.ts rename to packages/tests/src/api/check-params/contact-form.ts index f0f8819b9..009cb2ad9 100644 --- a/server/tests/api/check-params/contact-form.ts +++ b/packages/tests/src/api/check-params/contact-form.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { MockSmtpServer } from '@server/tests/shared' -import { HttpStatusCode } from '@shared/models' +import { MockSmtpServer } from '@tests/shared/mock-servers/index.js' +import { HttpStatusCode } from '@peertube/peertube-models' import { cleanupTests, ConfigCommand, @@ -9,7 +9,7 @@ import { createSingleServer, killallServers, PeerTubeServer -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test contact form API validators', function () { let server: PeerTubeServer diff --git a/server/tests/api/check-params/custom-pages.ts b/packages/tests/src/api/check-params/custom-pages.ts similarity index 95% rename from server/tests/api/check-params/custom-pages.ts rename to packages/tests/src/api/check-params/custom-pages.ts index 63e3da3d5..180a5e406 100644 --- a/server/tests/api/check-params/custom-pages.ts +++ b/packages/tests/src/api/check-params/custom-pages.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -8,7 +8,7 @@ import { makePutBodyRequest, PeerTubeServer, setAccessTokensToServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test custom pages validators', function () { const path = '/api/v1/custom-pages/homepage/instance' diff --git a/server/tests/api/check-params/debug.ts b/packages/tests/src/api/check-params/debug.ts similarity index 88% rename from server/tests/api/check-params/debug.ts rename to packages/tests/src/api/check-params/debug.ts index d7b68f163..4a7c18a62 100644 --- a/server/tests/api/check-params/debug.ts +++ b/packages/tests/src/api/check-params/debug.ts @@ -1,7 +1,13 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode } from '@peertube/peertube-models' +import { + cleanupTests, + createSingleServer, + makeGetRequest, + PeerTubeServer, + setAccessTokensToServers +} from '@peertube/peertube-server-commands' describe('Test debug API validators', function () { const path = '/api/v1/server/debug' diff --git a/server/tests/api/check-params/follows.ts b/packages/tests/src/api/check-params/follows.ts similarity index 98% rename from server/tests/api/check-params/follows.ts rename to packages/tests/src/api/check-params/follows.ts index 3c911dcee..e92a3acd6 100644 --- a/server/tests/api/check-params/follows.ts +++ b/packages/tests/src/api/check-params/follows.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' -import { HttpStatusCode } from '@shared/models' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@tests/shared/checks.js' +import { HttpStatusCode } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -10,7 +10,7 @@ import { makePostBodyRequest, PeerTubeServer, setAccessTokensToServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test server follows API validators', function () { let server: PeerTubeServer diff --git a/packages/tests/src/api/check-params/index.ts b/packages/tests/src/api/check-params/index.ts new file mode 100644 index 000000000..ed5fe6b06 --- /dev/null +++ b/packages/tests/src/api/check-params/index.ts @@ -0,0 +1,45 @@ +import './abuses.js' +import './accounts.js' +import './blocklist.js' +import './bulk.js' +import './channel-import-videos.js' +import './config.js' +import './contact-form.js' +import './custom-pages.js' +import './debug.js' +import './follows.js' +import './jobs.js' +import './live.js' +import './logs.js' +import './metrics.js' +import './my-user.js' +import './plugins.js' +import './redundancy.js' +import './registrations.js' +import './runners.js' +import './search.js' +import './services.js' +import './transcoding.js' +import './two-factor.js' +import './upload-quota.js' +import './user-notifications.js' +import './user-subscriptions.js' +import './users-admin.js' +import './users-emails.js' +import './video-blacklist.js' +import './video-captions.js' +import './video-channel-syncs.js' +import './video-channels.js' +import './video-comments.js' +import './video-files.js' +import './video-imports.js' +import './video-playlists.js' +import './video-storyboards.js' +import './video-source.js' +import './video-studio.js' +import './video-token.js' +import './videos-common-filters.js' +import './videos-history.js' +import './videos-overviews.js' +import './videos.js' +import './views.js' diff --git a/server/tests/api/check-params/jobs.ts b/packages/tests/src/api/check-params/jobs.ts similarity index 95% rename from server/tests/api/check-params/jobs.ts rename to packages/tests/src/api/check-params/jobs.ts index 873da3955..331d58c6a 100644 --- a/server/tests/api/check-params/jobs.ts +++ b/packages/tests/src/api/check-params/jobs.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' -import { HttpStatusCode } from '@shared/models' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@tests/shared/checks.js' +import { HttpStatusCode } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -9,7 +9,7 @@ import { makePostBodyRequest, PeerTubeServer, setAccessTokensToServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test jobs API validators', function () { const path = '/api/v1/jobs/failed' diff --git a/server/tests/api/check-params/live.ts b/packages/tests/src/api/check-params/live.ts similarity index 98% rename from server/tests/api/check-params/live.ts rename to packages/tests/src/api/check-params/live.ts index 5021db516..5900823ea 100644 --- a/server/tests/api/check-params/live.ts +++ b/packages/tests/src/api/check-params/live.ts @@ -1,8 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { buildAbsoluteFixturePath, omit } from '@shared/core-utils' -import { HttpStatusCode, LiveVideoLatencyMode, VideoCreateResult, VideoPrivacy } from '@shared/models' +import { omit } from '@peertube/peertube-core-utils' +import { HttpStatusCode, LiveVideoLatencyMode, VideoCreateResult, VideoPrivacy } from '@peertube/peertube-models' +import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils' import { cleanupTests, createSingleServer, @@ -13,7 +14,7 @@ import { sendRTMPStream, setAccessTokensToServers, stopFfmpeg -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test video lives API validator', function () { const path = '/api/v1/videos/live' @@ -466,13 +467,13 @@ describe('Test video lives API validator', function () { }) it('Should fail with bad latency setting', async function () { - const fields = { latencyMode: 42 } + const fields = { latencyMode: 42 as any } await command.update({ videoId: video.id, fields, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) }) it('Should fail with a bad privacy for replay settings', async function () { - const fields = { saveReplay: true, replaySettings: { privacy: 999 } } + const fields = { saveReplay: true, replaySettings: { privacy: 999 as any } } await command.update({ videoId: video.id, fields, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) }) diff --git a/server/tests/api/check-params/logs.ts b/packages/tests/src/api/check-params/logs.ts similarity index 95% rename from server/tests/api/check-params/logs.ts rename to packages/tests/src/api/check-params/logs.ts index 2496cee31..629530e30 100644 --- a/server/tests/api/check-params/logs.ts +++ b/packages/tests/src/api/check-params/logs.ts @@ -1,8 +1,14 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { HttpStatusCode } from '@shared/models' -import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' +import { HttpStatusCode } from '@peertube/peertube-models' +import { + cleanupTests, + createSingleServer, + makeGetRequest, + PeerTubeServer, + setAccessTokensToServers +} from '@peertube/peertube-server-commands' describe('Test logs API validators', function () { const path = '/api/v1/server/logs' diff --git a/server/tests/api/check-params/metrics.ts b/packages/tests/src/api/check-params/metrics.ts similarity index 95% rename from server/tests/api/check-params/metrics.ts rename to packages/tests/src/api/check-params/metrics.ts index 302bef4f5..cda854554 100644 --- a/server/tests/api/check-params/metrics.ts +++ b/packages/tests/src/api/check-params/metrics.ts @@ -1,8 +1,14 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { omit } from '@shared/core-utils' -import { HttpStatusCode, PlaybackMetricCreate, VideoResolution } from '@shared/models' -import { cleanupTests, createSingleServer, makePostBodyRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' +import { omit } from '@peertube/peertube-core-utils' +import { HttpStatusCode, PlaybackMetricCreate, VideoResolution } from '@peertube/peertube-models' +import { + cleanupTests, + createSingleServer, + makePostBodyRequest, + PeerTubeServer, + setAccessTokensToServers +} from '@peertube/peertube-server-commands' describe('Test metrics API validators', function () { let server: PeerTubeServer diff --git a/server/tests/api/check-params/my-user.ts b/packages/tests/src/api/check-params/my-user.ts similarity index 97% rename from server/tests/api/check-params/my-user.ts rename to packages/tests/src/api/check-params/my-user.ts index 18f32d46b..2ef2e242a 100644 --- a/server/tests/api/check-params/my-user.ts +++ b/packages/tests/src/api/check-params/my-user.ts @@ -1,8 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, MockSmtpServer } from '@server/tests/shared' -import { buildAbsoluteFixturePath } from '@shared/core-utils' -import { HttpStatusCode, UserRole, VideoCreateResult } from '@shared/models' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@tests/shared/checks.js' +import { MockSmtpServer } from '@tests/shared/mock-servers/index.js' +import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils' +import { HttpStatusCode, UserRole, VideoCreateResult } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -12,7 +13,7 @@ import { PeerTubeServer, setAccessTokensToServers, UsersCommand -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test my user API validators', function () { const path = '/api/v1/users/' diff --git a/server/tests/api/check-params/plugins.ts b/packages/tests/src/api/check-params/plugins.ts similarity index 98% rename from server/tests/api/check-params/plugins.ts rename to packages/tests/src/api/check-params/plugins.ts index e08cd7ab8..ab2a426fe 100644 --- a/server/tests/api/check-params/plugins.ts +++ b/packages/tests/src/api/check-params/plugins.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' -import { HttpStatusCode, PeerTubePlugin, PluginType } from '@shared/models' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@tests/shared/checks.js' +import { HttpStatusCode, PeerTubePlugin, PluginType } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -10,7 +10,7 @@ import { makePutBodyRequest, PeerTubeServer, setAccessTokensToServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test server plugins API validators', function () { let server: PeerTubeServer diff --git a/server/tests/api/check-params/redundancy.ts b/packages/tests/src/api/check-params/redundancy.ts similarity index 97% rename from server/tests/api/check-params/redundancy.ts rename to packages/tests/src/api/check-params/redundancy.ts index 73dfd489d..16a5d0a3d 100644 --- a/server/tests/api/check-params/redundancy.ts +++ b/packages/tests/src/api/check-params/redundancy.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' -import { HttpStatusCode, VideoCreateResult } from '@shared/models' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@tests/shared/checks.js' +import { HttpStatusCode, VideoCreateResult } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -13,7 +13,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test server redundancy API validators', function () { let servers: PeerTubeServer[] diff --git a/server/tests/api/check-params/registrations.ts b/packages/tests/src/api/check-params/registrations.ts similarity index 97% rename from server/tests/api/check-params/registrations.ts rename to packages/tests/src/api/check-params/registrations.ts index 8cbecdd07..e4e46da2a 100644 --- a/server/tests/api/check-params/registrations.ts +++ b/packages/tests/src/api/check-params/registrations.ts @@ -1,6 +1,6 @@ -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' -import { omit } from '@shared/core-utils' -import { HttpStatusCode, UserRole } from '@shared/models' +import { omit } from '@peertube/peertube-core-utils' +import { HttpStatusCode, HttpStatusCodeType, UserRole } from '@peertube/peertube-models' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@tests/shared/checks.js' import { cleanupTests, createSingleServer, @@ -9,7 +9,7 @@ import { setAccessTokensToServers, setDefaultAccountAvatar, setDefaultChannelAvatar -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test registrations API validators', function () { let server: PeerTubeServer @@ -47,7 +47,7 @@ describe('Test registrations API validators', function () { describe('When registering a new user or requesting user registration', function () { - async function check (fields: any, expectedStatus = HttpStatusCode.BAD_REQUEST_400) { + async function check (fields: any, expectedStatus: HttpStatusCodeType = HttpStatusCode.BAD_REQUEST_400) { await server.config.enableSignup(false) await makePostBodyRequest({ url: server.url, path: registrationPath, fields, expectedStatus }) diff --git a/server/tests/api/check-params/runners.ts b/packages/tests/src/api/check-params/runners.ts similarity index 99% rename from server/tests/api/check-params/runners.ts rename to packages/tests/src/api/check-params/runners.ts index 0e5012da5..dd2d2f0a1 100644 --- a/server/tests/api/check-params/runners.ts +++ b/packages/tests/src/api/check-params/runners.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { basename } from 'path' -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' import { HttpStatusCode, + HttpStatusCodeType, isVideoStudioTaskIntro, RunnerJob, RunnerJobState, @@ -11,7 +11,8 @@ import { RunnerJobUpdatePayload, VideoPrivacy, VideoStudioTaskIntro -} from '@shared/models' +} from '@peertube/peertube-models' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@tests/shared/checks.js' import { cleanupTests, createSingleServer, @@ -23,7 +24,7 @@ import { stopFfmpeg, VideoStudioCommand, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' const badUUID = '910ec12a-d9e6-458b-a274-0abb655f9464' @@ -381,7 +382,7 @@ describe('Test managing runners', function () { videoUUID: string runnerToken: string jobToken: string - expectedStatus: HttpStatusCode + expectedStatus: HttpStatusCodeType }) { const { jobUUID, expectedStatus, videoUUID, runnerToken, jobToken } = options @@ -399,7 +400,7 @@ describe('Test managing runners', function () { runnerToken: string jobToken: string studioFile?: string - expectedStatus: HttpStatusCode + expectedStatus: HttpStatusCodeType }) { const { jobUUID, expectedStatus, videoUUID, runnerToken, jobToken, studioFile } = options @@ -494,7 +495,7 @@ describe('Test managing runners', function () { jobUUID: string runnerToken: string jobToken: string - expectedStatus: HttpStatusCode + expectedStatus: HttpStatusCodeType }) { await server.runnerJobs.abort({ ...options, reason: 'reason' }) await server.runnerJobs.update({ ...options }) @@ -844,7 +845,7 @@ describe('Test managing runners', function () { async function fetchFiles (options: { videoUUID?: string - expectedStatus: HttpStatusCode + expectedStatus: HttpStatusCodeType }) { await fetchVideoInputFiles({ videoUUID, ...options, jobToken, jobUUID, runnerToken }) diff --git a/server/tests/api/check-params/search.ts b/packages/tests/src/api/check-params/search.ts similarity index 97% rename from server/tests/api/check-params/search.ts rename to packages/tests/src/api/check-params/search.ts index b04d30b7f..b886cbc82 100644 --- a/server/tests/api/check-params/search.ts +++ b/packages/tests/src/api/check-params/search.ts @@ -1,8 +1,14 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' -import { HttpStatusCode } from '@shared/models' -import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' +import { HttpStatusCode } from '@peertube/peertube-models' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@tests/shared/checks.js' +import { + cleanupTests, + createSingleServer, + makeGetRequest, + PeerTubeServer, + setAccessTokensToServers +} from '@peertube/peertube-server-commands' function updateSearchIndex (server: PeerTubeServer, enabled: boolean, disableLocalSearch = false) { return server.config.updateCustomSubConfig({ diff --git a/server/tests/api/check-params/services.ts b/packages/tests/src/api/check-params/services.ts similarity index 94% rename from server/tests/api/check-params/services.ts rename to packages/tests/src/api/check-params/services.ts index d45868f36..0b0466d84 100644 --- a/server/tests/api/check-params/services.ts +++ b/packages/tests/src/api/check-params/services.ts @@ -1,6 +1,13 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { HttpStatusCode, VideoCreateResult, VideoPlaylistCreateResult, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' +import { + HttpStatusCode, + HttpStatusCodeType, + VideoCreateResult, + VideoPlaylistCreateResult, + VideoPlaylistPrivacy, + VideoPrivacy +} from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -8,7 +15,7 @@ import { PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test services API validators', function () { let server: PeerTubeServer @@ -183,7 +190,12 @@ describe('Test services API validators', function () { }) }) -function checkParamEmbed (server: PeerTubeServer, embedUrl: string, expectedStatus = HttpStatusCode.BAD_REQUEST_400, query = {}) { +function checkParamEmbed ( + server: PeerTubeServer, + embedUrl: string, + expectedStatus: HttpStatusCodeType = HttpStatusCode.BAD_REQUEST_400, + query = {} +) { const path = '/services/oembed' return makeGetRequest({ diff --git a/server/tests/api/check-params/transcoding.ts b/packages/tests/src/api/check-params/transcoding.ts similarity index 97% rename from server/tests/api/check-params/transcoding.ts rename to packages/tests/src/api/check-params/transcoding.ts index d5899e11b..50935c59e 100644 --- a/server/tests/api/check-params/transcoding.ts +++ b/packages/tests/src/api/check-params/transcoding.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { HttpStatusCode, UserRole } from '@shared/models' +import { HttpStatusCode, UserRole } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -8,7 +8,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test transcoding API validators', function () { let servers: PeerTubeServer[] diff --git a/server/tests/api/check-params/two-factor.ts b/packages/tests/src/api/check-params/two-factor.ts similarity index 97% rename from server/tests/api/check-params/two-factor.ts rename to packages/tests/src/api/check-params/two-factor.ts index f8365f1b5..0b1766eca 100644 --- a/server/tests/api/check-params/two-factor.ts +++ b/packages/tests/src/api/check-params/two-factor.ts @@ -1,7 +1,13 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { HttpStatusCode } from '@shared/models' -import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, TwoFactorCommand } from '@shared/server-commands' +import { HttpStatusCode } from '@peertube/peertube-models' +import { + cleanupTests, + createSingleServer, + PeerTubeServer, + setAccessTokensToServers, + TwoFactorCommand +} from '@peertube/peertube-server-commands' describe('Test two factor API validators', function () { let server: PeerTubeServer diff --git a/server/tests/api/check-params/upload-quota.ts b/packages/tests/src/api/check-params/upload-quota.ts similarity index 96% rename from server/tests/api/check-params/upload-quota.ts rename to packages/tests/src/api/check-params/upload-quota.ts index 06698c056..a77792822 100644 --- a/server/tests/api/check-params/upload-quota.ts +++ b/packages/tests/src/api/check-params/upload-quota.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { FIXTURE_URLS } from '@server/tests/shared' -import { randomInt } from '@shared/core-utils' -import { HttpStatusCode, VideoImportState, VideoPrivacy } from '@shared/models' +import { FIXTURE_URLS } from '@tests/shared/tests.js' +import { randomInt } from '@peertube/peertube-core-utils' +import { HttpStatusCode, VideoImportState, VideoPrivacy } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -12,7 +12,7 @@ import { setDefaultVideoChannel, VideosCommand, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test upload quota', function () { let server: PeerTubeServer diff --git a/server/tests/api/check-params/user-notifications.ts b/packages/tests/src/api/check-params/user-notifications.ts similarity index 97% rename from server/tests/api/check-params/user-notifications.ts rename to packages/tests/src/api/check-params/user-notifications.ts index 6a588e446..cf20324a1 100644 --- a/server/tests/api/check-params/user-notifications.ts +++ b/packages/tests/src/api/check-params/user-notifications.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { io } from 'socket.io-client' -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' -import { wait } from '@shared/core-utils' -import { HttpStatusCode, UserNotificationSetting, UserNotificationSettingValue } from '@shared/models' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@tests/shared/checks.js' +import { wait } from '@peertube/peertube-core-utils' +import { HttpStatusCode, UserNotificationSetting, UserNotificationSettingValue } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -12,7 +12,7 @@ import { makePutBodyRequest, PeerTubeServer, setAccessTokensToServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test user notifications API validators', function () { let server: PeerTubeServer diff --git a/server/tests/api/check-params/user-subscriptions.ts b/packages/tests/src/api/check-params/user-subscriptions.ts similarity index 98% rename from server/tests/api/check-params/user-subscriptions.ts rename to packages/tests/src/api/check-params/user-subscriptions.ts index c4922c7a2..e97f513a0 100644 --- a/server/tests/api/check-params/user-subscriptions.ts +++ b/packages/tests/src/api/check-params/user-subscriptions.ts @@ -9,9 +9,9 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' -import { HttpStatusCode } from '@shared/models' -import { checkBadStartPagination, checkBadCountPagination, checkBadSortPagination } from '@server/tests/shared' +} from '@peertube/peertube-server-commands' +import { HttpStatusCode } from '@peertube/peertube-models' +import { checkBadStartPagination, checkBadCountPagination, checkBadSortPagination } from '@tests/shared/checks.js' describe('Test user subscriptions API validators', function () { const path = '/api/v1/users/me/subscriptions' diff --git a/server/tests/api/check-params/users-admin.ts b/packages/tests/src/api/check-params/users-admin.ts similarity index 97% rename from server/tests/api/check-params/users-admin.ts rename to packages/tests/src/api/check-params/users-admin.ts index 819da0bb2..1ad222ddc 100644 --- a/server/tests/api/check-params/users-admin.ts +++ b/packages/tests/src/api/check-params/users-admin.ts @@ -1,8 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, MockSmtpServer } from '@server/tests/shared' -import { omit } from '@shared/core-utils' -import { HttpStatusCode, UserAdminFlag, UserRole } from '@shared/models' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@tests/shared/checks.js' +import { MockSmtpServer } from '@tests/shared/mock-servers/index.js' +import { omit } from '@peertube/peertube-core-utils' +import { HttpStatusCode, UserAdminFlag, UserRole } from '@peertube/peertube-models' import { cleanupTests, ConfigCommand, @@ -13,7 +14,7 @@ import { makePutBodyRequest, PeerTubeServer, setAccessTokensToServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test users admin API validators', function () { const path = '/api/v1/users/' diff --git a/server/tests/api/check-params/users-emails.ts b/packages/tests/src/api/check-params/users-emails.ts similarity index 93% rename from server/tests/api/check-params/users-emails.ts rename to packages/tests/src/api/check-params/users-emails.ts index 6ebcc8ffe..e382190ec 100644 --- a/server/tests/api/check-params/users-emails.ts +++ b/packages/tests/src/api/check-params/users-emails.ts @@ -1,6 +1,12 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { HttpStatusCode, UserRole } from '@shared/models' -import { cleanupTests, createSingleServer, makePostBodyRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' +import { HttpStatusCode, UserRole } from '@peertube/peertube-models' +import { + cleanupTests, + createSingleServer, + makePostBodyRequest, + PeerTubeServer, + setAccessTokensToServers +} from '@peertube/peertube-server-commands' describe('Test users API validators', function () { let server: PeerTubeServer diff --git a/server/tests/api/check-params/video-blacklist.ts b/packages/tests/src/api/check-params/video-blacklist.ts similarity index 98% rename from server/tests/api/check-params/video-blacklist.ts rename to packages/tests/src/api/check-params/video-blacklist.ts index 8e9f61596..6ec070b9b 100644 --- a/server/tests/api/check-params/video-blacklist.ts +++ b/packages/tests/src/api/check-params/video-blacklist.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' -import { HttpStatusCode, VideoBlacklistType } from '@shared/models' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@tests/shared/checks.js' +import { HttpStatusCode, VideoBlacklistType } from '@peertube/peertube-models' import { BlacklistCommand, cleanupTests, @@ -13,7 +13,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test video blacklist API validators', function () { let servers: PeerTubeServer[] diff --git a/server/tests/api/check-params/video-captions.ts b/packages/tests/src/api/check-params/video-captions.ts similarity index 98% rename from server/tests/api/check-params/video-captions.ts rename to packages/tests/src/api/check-params/video-captions.ts index 532dab1c4..4150b095f 100644 --- a/server/tests/api/check-params/video-captions.ts +++ b/packages/tests/src/api/check-params/video-captions.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { buildAbsoluteFixturePath } from '@shared/core-utils' -import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models' +import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils' +import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -10,7 +10,7 @@ import { makeUploadRequest, PeerTubeServer, setAccessTokensToServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test video captions API validator', function () { const path = '/api/v1/videos/' diff --git a/server/tests/api/check-params/video-channel-syncs.ts b/packages/tests/src/api/check-params/video-channel-syncs.ts similarity index 97% rename from server/tests/api/check-params/video-channel-syncs.ts rename to packages/tests/src/api/check-params/video-channel-syncs.ts index bcd8984df..d95f3319a 100644 --- a/server/tests/api/check-params/video-channel-syncs.ts +++ b/packages/tests/src/api/check-params/video-channel-syncs.ts @@ -1,5 +1,6 @@ -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, FIXTURE_URLS } from '@server/tests/shared' -import { HttpStatusCode, VideoChannelSyncCreate } from '@shared/models' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@tests/shared/checks.js' +import { FIXTURE_URLS } from '@tests/shared/tests.js' +import { HttpStatusCode, VideoChannelSyncCreate } from '@peertube/peertube-models' import { ChannelSyncsCommand, createSingleServer, @@ -7,7 +8,7 @@ import { PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test video channel sync API validator', () => { const path = '/api/v1/video-channel-syncs' diff --git a/server/tests/api/check-params/video-channels.ts b/packages/tests/src/api/check-params/video-channels.ts similarity index 97% rename from server/tests/api/check-params/video-channels.ts rename to packages/tests/src/api/check-params/video-channels.ts index 1782474fd..84b962b19 100644 --- a/server/tests/api/check-params/video-channels.ts +++ b/packages/tests/src/api/check-params/video-channels.ts @@ -1,9 +1,10 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' -import { buildAbsoluteFixturePath, omit } from '@shared/core-utils' -import { HttpStatusCode, VideoChannelUpdate } from '@shared/models' +import { omit } from '@peertube/peertube-core-utils' +import { HttpStatusCode, VideoChannelUpdate } from '@peertube/peertube-models' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@tests/shared/checks.js' +import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils' import { ChannelsCommand, cleanupTests, @@ -14,7 +15,7 @@ import { makeUploadRequest, PeerTubeServer, setAccessTokensToServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test video channels API validator', function () { const videoChannelPath = '/api/v1/video-channels' diff --git a/server/tests/api/check-params/video-comments.ts b/packages/tests/src/api/check-params/video-comments.ts similarity index 99% rename from server/tests/api/check-params/video-comments.ts rename to packages/tests/src/api/check-params/video-comments.ts index 9f497c0cf..177361606 100644 --- a/server/tests/api/check-params/video-comments.ts +++ b/packages/tests/src/api/check-params/video-comments.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' -import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@tests/shared/checks.js' +import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -11,7 +11,7 @@ import { makePostBodyRequest, PeerTubeServer, setAccessTokensToServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test video comments API validator', function () { let pathThread: string diff --git a/server/tests/api/check-params/video-files.ts b/packages/tests/src/api/check-params/video-files.ts similarity index 98% rename from server/tests/api/check-params/video-files.ts rename to packages/tests/src/api/check-params/video-files.ts index 01d6a912b..b5819ff19 100644 --- a/server/tests/api/check-params/video-files.ts +++ b/packages/tests/src/api/check-params/video-files.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { getAllFiles } from '@shared/core-utils' -import { HttpStatusCode, UserRole, VideoDetails, VideoPrivacy } from '@shared/models' +import { getAllFiles } from '@peertube/peertube-core-utils' +import { HttpStatusCode, UserRole, VideoDetails, VideoPrivacy } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -10,7 +10,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test videos files', function () { let servers: PeerTubeServer[] diff --git a/server/tests/api/check-params/video-imports.ts b/packages/tests/src/api/check-params/video-imports.ts similarity index 97% rename from server/tests/api/check-params/video-imports.ts rename to packages/tests/src/api/check-params/video-imports.ts index 8c6f43c12..e078cedd6 100644 --- a/server/tests/api/check-params/video-imports.ts +++ b/packages/tests/src/api/check-params/video-imports.ts @@ -1,8 +1,10 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, FIXTURE_URLS } from '@server/tests/shared' -import { buildAbsoluteFixturePath, omit } from '@shared/core-utils' -import { HttpStatusCode, VideoPrivacy } from '@shared/models' +import { omit } from '@peertube/peertube-core-utils' +import { HttpStatusCode, VideoPrivacy } from '@peertube/peertube-models' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@tests/shared/checks.js' +import { FIXTURE_URLS } from '@tests/shared/tests.js' +import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils' import { cleanupTests, createSingleServer, @@ -13,7 +15,7 @@ import { setAccessTokensToServers, setDefaultVideoChannel, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test video imports API validator', function () { const path = '/api/v1/videos/imports' diff --git a/server/tests/api/check-params/video-passwords.ts b/packages/tests/src/api/check-params/video-passwords.ts similarity index 97% rename from server/tests/api/check-params/video-passwords.ts rename to packages/tests/src/api/check-params/video-passwords.ts index 50b0bacb3..3f57ebe74 100644 --- a/server/tests/api/check-params/video-passwords.ts +++ b/packages/tests/src/api/check-params/video-passwords.ts @@ -1,28 +1,23 @@ -/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { - FIXTURE_URLS, - checkBadCountPagination, - checkBadSortPagination, - checkBadStartPagination, - checkUploadVideoParam -} from '@server/tests/shared' -import { root } from '@shared/core-utils' +import { expect } from 'chai' import { HttpStatusCode, + HttpStatusCodeType, PeerTubeProblemDocument, ServerErrorCode, VideoCreateResult, VideoPrivacy -} from '@shared/models' +} from '@peertube/peertube-models' +import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils' import { cleanupTests, createSingleServer, makePostBodyRequest, PeerTubeServer, setAccessTokensToServers -} from '@shared/server-commands' -import { expect } from 'chai' -import { join } from 'path' +} from '@peertube/peertube-server-commands' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@tests/shared/checks.js' +import { FIXTURE_URLS } from '@tests/shared/tests.js' +import { checkUploadVideoParam } from '@tests/shared/videos.js' describe('Test video passwords validator', function () { let path: string @@ -81,12 +76,12 @@ describe('Test video passwords validator', function () { server: PeerTubeServer token: string videoPasswords: string[] - expectedStatus: HttpStatusCode + expectedStatus: HttpStatusCodeType mode: 'uploadLegacy' | 'uploadResumable' | 'import' | 'updateVideo' | 'updatePasswords' | 'live' }) { const { server, token, videoPasswords, expectedStatus = HttpStatusCode.OK_200, mode } = options const attaches = { - fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.webm') + fixture: buildAbsoluteFixturePath('video_short.webm') } const baseCorrectParams = { name: 'my super name', @@ -271,7 +266,7 @@ describe('Test video passwords validator', function () { server: PeerTubeServer token?: string videoPassword?: string - expectedStatus: HttpStatusCode + expectedStatus: HttpStatusCodeType mode: 'get' | 'getWithPassword' | 'getWithToken' | 'listCaptions' | 'createThread' | 'listThreads' | 'replyThread' | 'rate' | 'token' }) { const { server, token = null, videoPassword, expectedStatus, mode } = options diff --git a/server/tests/api/check-params/video-playlists.ts b/packages/tests/src/api/check-params/video-playlists.ts similarity index 99% rename from server/tests/api/check-params/video-playlists.ts rename to packages/tests/src/api/check-params/video-playlists.ts index 8c3233e0b..7f5be18d4 100644 --- a/server/tests/api/check-params/video-playlists.ts +++ b/packages/tests/src/api/check-params/video-playlists.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@tests/shared/checks.js' import { HttpStatusCode, VideoPlaylistCreate, @@ -10,7 +10,7 @@ import { VideoPlaylistPrivacy, VideoPlaylistReorder, VideoPlaylistType -} from '@shared/models' +} from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -19,7 +19,7 @@ import { PlaylistsCommand, setAccessTokensToServers, setDefaultVideoChannel -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test video playlists API validator', function () { let server: PeerTubeServer diff --git a/server/tests/api/check-params/video-source.ts b/packages/tests/src/api/check-params/video-source.ts similarity index 97% rename from server/tests/api/check-params/video-source.ts rename to packages/tests/src/api/check-params/video-source.ts index 767590d5e..918182b8d 100644 --- a/server/tests/api/check-params/video-source.ts +++ b/packages/tests/src/api/check-params/video-source.ts @@ -1,4 +1,4 @@ -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -6,7 +6,7 @@ import { setAccessTokensToServers, setDefaultVideoChannel, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test video sources API validator', function () { let server: PeerTubeServer = null diff --git a/server/tests/api/check-params/video-storyboards.ts b/packages/tests/src/api/check-params/video-storyboards.ts similarity index 92% rename from server/tests/api/check-params/video-storyboards.ts rename to packages/tests/src/api/check-params/video-storyboards.ts index c038e7370..f83b541d8 100644 --- a/server/tests/api/check-params/video-storyboards.ts +++ b/packages/tests/src/api/check-params/video-storyboards.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { HttpStatusCode, VideoPrivacy } from '@shared/models' -import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' +import { HttpStatusCode, VideoPrivacy } from '@peertube/peertube-models' +import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@peertube/peertube-server-commands' describe('Test video storyboards API validator', function () { let server: PeerTubeServer diff --git a/server/tests/api/check-params/video-studio.ts b/packages/tests/src/api/check-params/video-studio.ts similarity index 95% rename from server/tests/api/check-params/video-studio.ts rename to packages/tests/src/api/check-params/video-studio.ts index 4ac0d93ed..ae83f3590 100644 --- a/server/tests/api/check-params/video-studio.ts +++ b/packages/tests/src/api/check-params/video-studio.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { HttpStatusCode, VideoStudioTask } from '@shared/models' +import { HttpStatusCode, HttpStatusCodeType, VideoStudioTask } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -8,7 +8,7 @@ import { setAccessTokensToServers, VideoStudioCommand, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test video studio API validator', function () { let server: PeerTubeServer @@ -215,7 +215,7 @@ describe('Test video studio API validator', function () { describe('Cut task', function () { - async function cut (start: number, end: number, expectedStatus = HttpStatusCode.BAD_REQUEST_400) { + async function cut (start: number, end: number, expectedStatus: HttpStatusCodeType = HttpStatusCode.BAD_REQUEST_400) { await command.createEditionTasks({ videoId: videoUUID, tasks: [ @@ -267,7 +267,7 @@ describe('Test video studio API validator', function () { describe('Watermark task', function () { - async function addWatermark (file: string, expectedStatus = HttpStatusCode.BAD_REQUEST_400) { + async function addWatermark (file: string, expectedStatus: HttpStatusCodeType = HttpStatusCode.BAD_REQUEST_400) { await command.createEditionTasks({ videoId: videoUUID, tasks: [ @@ -301,7 +301,11 @@ describe('Test video studio API validator', function () { describe('Intro/Outro task', function () { - async function addIntroOutro (type: 'add-intro' | 'add-outro', file: string, expectedStatus = HttpStatusCode.BAD_REQUEST_400) { + async function addIntroOutro ( + type: 'add-intro' | 'add-outro', + file: string, + expectedStatus: HttpStatusCodeType = HttpStatusCode.BAD_REQUEST_400 + ) { await command.createEditionTasks({ videoId: videoUUID, tasks: [ @@ -349,7 +353,7 @@ describe('Test video studio API validator', function () { const token = await server.login.getAccessToken('user_quota_1') const { uuid } = await server.videos.quickUpload({ token, name: 'video_quota_1', fixture: 'video_short.mp4' }) - const addIntroOutroByUser = (type: 'add-intro' | 'add-outro', expectedStatus: HttpStatusCode) => { + const addIntroOutroByUser = (type: 'add-intro' | 'add-outro', expectedStatus: HttpStatusCodeType) => { return command.createEditionTasks({ token, videoId: uuid, diff --git a/server/tests/api/check-params/video-token.ts b/packages/tests/src/api/check-params/video-token.ts similarity index 94% rename from server/tests/api/check-params/video-token.ts rename to packages/tests/src/api/check-params/video-token.ts index 7cb3e84a2..5f838102d 100644 --- a/server/tests/api/check-params/video-token.ts +++ b/packages/tests/src/api/check-params/video-token.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { HttpStatusCode, VideoPrivacy } from '@shared/models' -import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' +import { HttpStatusCode, VideoPrivacy } from '@peertube/peertube-models' +import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@peertube/peertube-server-commands' describe('Test video tokens', function () { let server: PeerTubeServer diff --git a/server/tests/api/check-params/videos-common-filters.ts b/packages/tests/src/api/check-params/videos-common-filters.ts similarity index 94% rename from server/tests/api/check-params/videos-common-filters.ts rename to packages/tests/src/api/check-params/videos-common-filters.ts index 603f7f777..dbae3010c 100644 --- a/server/tests/api/check-params/videos-common-filters.ts +++ b/packages/tests/src/api/check-params/videos-common-filters.ts @@ -1,6 +1,14 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { HttpStatusCode, UserRole, VideoInclude, VideoPrivacy } from '@shared/models' +import { + HttpStatusCode, + HttpStatusCodeType, + UserRole, + VideoInclude, + VideoIncludeType, + VideoPrivacy, + VideoPrivacyType +} from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -8,7 +16,7 @@ import { PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test video filters validators', function () { let server: PeerTubeServer @@ -46,9 +54,9 @@ describe('Test video filters validators', function () { async function testEndpoints (options: { token?: string isLocal?: boolean - include?: VideoInclude - privacyOneOf?: VideoPrivacy[] - expectedStatus: HttpStatusCode + include?: VideoIncludeType + privacyOneOf?: VideoPrivacyType[] + expectedStatus: HttpStatusCodeType excludeAlreadyWatched?: boolean unauthenticatedUser?: boolean }) { diff --git a/server/tests/api/check-params/videos-history.ts b/packages/tests/src/api/check-params/videos-history.ts similarity index 97% rename from server/tests/api/check-params/videos-history.ts rename to packages/tests/src/api/check-params/videos-history.ts index d96fe7ca9..65d1e9fac 100644 --- a/server/tests/api/check-params/videos-history.ts +++ b/packages/tests/src/api/check-params/videos-history.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { checkBadCountPagination, checkBadStartPagination } from '@server/tests/shared' -import { HttpStatusCode } from '@shared/models' +import { checkBadCountPagination, checkBadStartPagination } from '@tests/shared/checks.js' +import { HttpStatusCode } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -11,7 +11,7 @@ import { makePutBodyRequest, PeerTubeServer, setAccessTokensToServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test videos history API validator', function () { const myHistoryPath = '/api/v1/users/me/history/videos' diff --git a/server/tests/api/check-params/videos-overviews.ts b/packages/tests/src/api/check-params/videos-overviews.ts similarity index 95% rename from server/tests/api/check-params/videos-overviews.ts rename to packages/tests/src/api/check-params/videos-overviews.ts index ae7de24dd..ba6f6ac69 100644 --- a/server/tests/api/check-params/videos-overviews.ts +++ b/packages/tests/src/api/check-params/videos-overviews.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { cleanupTests, createSingleServer, PeerTubeServer } from '@shared/server-commands' +import { cleanupTests, createSingleServer, PeerTubeServer } from '@peertube/peertube-server-commands' describe('Test videos overview API validator', function () { let server: PeerTubeServer diff --git a/server/tests/api/check-params/videos.ts b/packages/tests/src/api/check-params/videos.ts similarity index 94% rename from server/tests/api/check-params/videos.ts rename to packages/tests/src/api/check-params/videos.ts index f00698fe3..c349ed9fe 100644 --- a/server/tests/api/check-params/videos.ts +++ b/packages/tests/src/api/check-params/videos.ts @@ -2,9 +2,9 @@ import { expect } from 'chai' import { join } from 'path' -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, checkUploadVideoParam } from '@server/tests/shared' -import { omit, randomInt, root } from '@shared/core-utils' -import { HttpStatusCode, PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models' +import { omit, randomInt } from '@peertube/peertube-core-utils' +import { HttpStatusCode, PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@peertube/peertube-models' +import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils' import { cleanupTests, createSingleServer, @@ -14,7 +14,9 @@ import { makeUploadRequest, PeerTubeServer, setAccessTokensToServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' +import { checkBadStartPagination, checkBadCountPagination, checkBadSortPagination } from '@tests/shared/checks.js' +import { checkUploadVideoParam } from '@tests/shared/videos.js' describe('Test videos API validator', function () { const path = '/api/v1/videos/' @@ -183,7 +185,7 @@ describe('Test videos API validator', function () { describe('When adding a video', function () { let baseCorrectParams const baseCorrectAttaches = { - fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.webm') + fixture: buildAbsoluteFixturePath('video_short.webm') } before(function () { @@ -364,7 +366,7 @@ describe('Test videos API validator', function () { it('Should fail with an incorrect input file', async function () { const fields = baseCorrectParams - let attaches = { fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short_fake.webm') } + let attaches = { fixture: buildAbsoluteFixturePath('video_short_fake.webm') } await checkUploadVideoParam({ ...baseOptions(), @@ -374,7 +376,7 @@ describe('Test videos API validator', function () { completedExpectedStatus: HttpStatusCode.UNPROCESSABLE_ENTITY_422 }) - attaches = { fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mkv') } + attaches = { fixture: buildAbsoluteFixturePath('video_short.mkv') } await checkUploadVideoParam({ ...baseOptions(), attributes: { ...fields, ...attaches }, @@ -385,8 +387,8 @@ describe('Test videos API validator', function () { it('Should fail with an incorrect thumbnail file', async function () { const fields = baseCorrectParams const attaches = { - thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4'), - fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') + thumbnailfile: buildAbsoluteFixturePath('video_short.mp4'), + fixture: buildAbsoluteFixturePath('video_short.mp4') } await checkUploadVideoParam({ ...baseOptions(), attributes: { ...fields, ...attaches } }) @@ -395,8 +397,8 @@ describe('Test videos API validator', function () { it('Should fail with a big thumbnail file', async function () { const fields = baseCorrectParams const attaches = { - thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'custom-preview-big.png'), - fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') + thumbnailfile: buildAbsoluteFixturePath('custom-preview-big.png'), + fixture: buildAbsoluteFixturePath('video_short.mp4') } await checkUploadVideoParam({ ...baseOptions(), attributes: { ...fields, ...attaches } }) @@ -405,8 +407,8 @@ describe('Test videos API validator', function () { it('Should fail with an incorrect preview file', async function () { const fields = baseCorrectParams const attaches = { - previewfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4'), - fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') + previewfile: buildAbsoluteFixturePath('video_short.mp4'), + fixture: buildAbsoluteFixturePath('video_short.mp4') } await checkUploadVideoParam({ ...baseOptions(), attributes: { ...fields, ...attaches } }) @@ -415,8 +417,8 @@ describe('Test videos API validator', function () { it('Should fail with a big preview file', async function () { const fields = baseCorrectParams const attaches = { - previewfile: join(root(), 'server', 'tests', 'fixtures', 'custom-preview-big.png'), - fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') + previewfile: buildAbsoluteFixturePath('custom-preview-big.png'), + fixture: buildAbsoluteFixturePath('video_short.mp4') } await checkUploadVideoParam({ ...baseOptions(), attributes: { ...fields, ...attaches } }) @@ -465,7 +467,7 @@ describe('Test videos API validator', function () { const attaches = { ...baseCorrectAttaches, - videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') + videofile: buildAbsoluteFixturePath('video_short.mp4') } await checkUploadVideoParam({ @@ -479,7 +481,7 @@ describe('Test videos API validator', function () { const attaches = { ...baseCorrectAttaches, - videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.ogv') + videofile: buildAbsoluteFixturePath('video_short.ogv') } await checkUploadVideoParam({ @@ -622,7 +624,7 @@ describe('Test videos API validator', function () { it('Should fail with an incorrect thumbnail file', async function () { const fields = baseCorrectParams const attaches = { - thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') + thumbnailfile: buildAbsoluteFixturePath('video_short.mp4') } await makeUploadRequest({ @@ -638,7 +640,7 @@ describe('Test videos API validator', function () { it('Should fail with a big thumbnail file', async function () { const fields = baseCorrectParams const attaches = { - thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'custom-preview-big.png') + thumbnailfile: buildAbsoluteFixturePath('custom-preview-big.png') } await makeUploadRequest({ @@ -654,7 +656,7 @@ describe('Test videos API validator', function () { it('Should fail with an incorrect preview file', async function () { const fields = baseCorrectParams const attaches = { - previewfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') + previewfile: buildAbsoluteFixturePath('video_short.mp4') } await makeUploadRequest({ @@ -670,7 +672,7 @@ describe('Test videos API validator', function () { it('Should fail with a big preview file', async function () { const fields = baseCorrectParams const attaches = { - previewfile: join(root(), 'server', 'tests', 'fixtures', 'custom-preview-big.png') + previewfile: buildAbsoluteFixturePath('custom-preview-big.png') } await makeUploadRequest({ diff --git a/server/tests/api/check-params/views.ts b/packages/tests/src/api/check-params/views.ts similarity index 98% rename from server/tests/api/check-params/views.ts rename to packages/tests/src/api/check-params/views.ts index 11416ccb8..c454d4b80 100644 --- a/server/tests/api/check-params/views.ts +++ b/packages/tests/src/api/check-params/views.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { HttpStatusCode, VideoPrivacy } from '@shared/models' +import { HttpStatusCode, VideoPrivacy } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -8,7 +8,7 @@ import { PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test videos views', function () { let servers: PeerTubeServer[] diff --git a/packages/tests/src/api/live/index.ts b/packages/tests/src/api/live/index.ts new file mode 100644 index 000000000..e61e6c611 --- /dev/null +++ b/packages/tests/src/api/live/index.ts @@ -0,0 +1,7 @@ +import './live-constraints.js' +import './live-fast-restream.js' +import './live-socket-messages.js' +import './live-permanent.js' +import './live-rtmps.js' +import './live-save-replay.js' +import './live.js' diff --git a/server/tests/api/live/live-constraints.ts b/packages/tests/src/api/live/live-constraints.ts similarity index 97% rename from server/tests/api/live/live-constraints.ts rename to packages/tests/src/api/live/live-constraints.ts index 697d808d5..f62994cbd 100644 --- a/server/tests/api/live/live-constraints.ts +++ b/packages/tests/src/api/live/live-constraints.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { wait } from '@shared/core-utils' -import { LiveVideoError, UserVideoQuota, VideoPrivacy } from '@shared/models' +import { wait } from '@peertube/peertube-core-utils' +import { LiveVideoError, UserVideoQuota, VideoPrivacy } from '@peertube/peertube-models' import { cleanupTests, ConfigCommand, @@ -15,8 +15,8 @@ import { waitJobs, waitUntilLiveReplacedByReplayOnAllServers, waitUntilLiveWaitingOnAllServers -} from '@shared/server-commands' -import { checkLiveCleanup } from '../../shared' +} from '@peertube/peertube-server-commands' +import { checkLiveCleanup } from '../../shared/live.js' describe('Test live constraints', function () { let servers: PeerTubeServer[] = [] diff --git a/server/tests/api/live/live-fast-restream.ts b/packages/tests/src/api/live/live-fast-restream.ts similarity index 96% rename from server/tests/api/live/live-fast-restream.ts rename to packages/tests/src/api/live/live-fast-restream.ts index 1b7fddd8b..d34b00cbe 100644 --- a/server/tests/api/live/live-fast-restream.ts +++ b/packages/tests/src/api/live/live-fast-restream.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { wait } from '@shared/core-utils' -import { LiveVideoCreate, VideoPrivacy } from '@shared/models' +import { wait } from '@peertube/peertube-core-utils' +import { LiveVideoCreate, VideoPrivacy } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -11,7 +11,7 @@ import { setDefaultVideoChannel, stopFfmpeg, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Fast restream in live', function () { let server: PeerTubeServer diff --git a/server/tests/api/live/live-permanent.ts b/packages/tests/src/api/live/live-permanent.ts similarity index 95% rename from server/tests/api/live/live-permanent.ts rename to packages/tests/src/api/live/live-permanent.ts index 4203b1bfc..4ffcc7ed4 100644 --- a/server/tests/api/live/live-permanent.ts +++ b/packages/tests/src/api/live/live-permanent.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { checkLiveCleanup } from '@server/tests/shared' -import { wait } from '@shared/core-utils' -import { LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models' +import { wait } from '@peertube/peertube-core-utils' +import { LiveVideoCreate, VideoPrivacy, VideoState, VideoStateType } from '@peertube/peertube-models' +import { checkLiveCleanup } from '@tests/shared/live.js' import { cleanupTests, ConfigCommand, @@ -14,7 +14,7 @@ import { setDefaultVideoChannel, stopFfmpeg, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Permanent live', function () { let servers: PeerTubeServer[] = [] @@ -33,7 +33,7 @@ describe('Permanent live', function () { return uuid } - async function checkVideoState (videoId: string, state: VideoState) { + async function checkVideoState (videoId: string, state: VideoStateType) { for (const server of servers) { const video = await server.videos.get({ id: videoId }) expect(video.state.id).to.equal(state) diff --git a/server/tests/api/live/live-rtmps.ts b/packages/tests/src/api/live/live-rtmps.ts similarity index 95% rename from server/tests/api/live/live-rtmps.ts rename to packages/tests/src/api/live/live-rtmps.ts index dcaee90cf..4ab59ed4c 100644 --- a/server/tests/api/live/live-rtmps.ts +++ b/packages/tests/src/api/live/live-rtmps.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { buildAbsoluteFixturePath } from '@shared/core-utils' -import { VideoPrivacy } from '@shared/models' +import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils' +import { VideoPrivacy } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -13,7 +13,7 @@ import { stopFfmpeg, testFfmpegStreamError, waitUntilLivePublishedOnAllServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test live RTMPS', function () { let server: PeerTubeServer diff --git a/server/tests/api/live/live-save-replay.ts b/packages/tests/src/api/live/live-save-replay.ts similarity index 96% rename from server/tests/api/live/live-save-replay.ts rename to packages/tests/src/api/live/live-save-replay.ts index d554cf208..84135365b 100644 --- a/server/tests/api/live/live-save-replay.ts +++ b/packages/tests/src/api/live/live-save-replay.ts @@ -2,9 +2,18 @@ import { expect } from 'chai' import { FfmpegCommand } from 'fluent-ffmpeg' -import { checkLiveCleanup } from '@server/tests/shared' -import { wait } from '@shared/core-utils' -import { HttpStatusCode, LiveVideoCreate, LiveVideoError, VideoPrivacy, VideoState } from '@shared/models' +import { wait } from '@peertube/peertube-core-utils' +import { + HttpStatusCode, + HttpStatusCodeType, + LiveVideoCreate, + LiveVideoError, + VideoPrivacy, + VideoPrivacyType, + VideoState, + VideoStateType +} from '@peertube/peertube-models' +import { checkLiveCleanup } from '@tests/shared/live.js' import { cleanupTests, ConfigCommand, @@ -20,14 +29,14 @@ import { waitUntilLivePublishedOnAllServers, waitUntilLiveReplacedByReplayOnAllServers, waitUntilLiveWaitingOnAllServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Save replay setting', function () { let servers: PeerTubeServer[] = [] let liveVideoUUID: string let ffmpegCommand: FfmpegCommand - async function createLiveWrapper (options: { permanent: boolean, replay: boolean, replaySettings?: { privacy: VideoPrivacy } }) { + async function createLiveWrapper (options: { permanent: boolean, replay: boolean, replaySettings?: { privacy: VideoPrivacyType } }) { if (liveVideoUUID) { try { await servers[0].videos.remove({ id: liveVideoUUID }) @@ -48,7 +57,7 @@ describe('Save replay setting', function () { return uuid } - async function publishLive (options: { permanent: boolean, replay: boolean, replaySettings?: { privacy: VideoPrivacy } }) { + async function publishLive (options: { permanent: boolean, replay: boolean, replaySettings?: { privacy: VideoPrivacyType } }) { liveVideoUUID = await createLiveWrapper(options) const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) @@ -62,7 +71,7 @@ describe('Save replay setting', function () { return { ffmpegCommand, liveDetails } } - async function publishLiveAndDelete (options: { permanent: boolean, replay: boolean, replaySettings?: { privacy: VideoPrivacy } }) { + async function publishLiveAndDelete (options: { permanent: boolean, replay: boolean, replaySettings?: { privacy: VideoPrivacyType } }) { const { ffmpegCommand, liveDetails } = await publishLive(options) await Promise.all([ @@ -77,7 +86,11 @@ describe('Save replay setting', function () { return { liveDetails } } - async function publishLiveAndBlacklist (options: { permanent: boolean, replay: boolean, replaySettings?: { privacy: VideoPrivacy } }) { + async function publishLiveAndBlacklist (options: { + permanent: boolean + replay: boolean + replaySettings?: { privacy: VideoPrivacyType } + }) { const { ffmpegCommand, liveDetails } = await publishLive(options) await Promise.all([ @@ -92,7 +105,7 @@ describe('Save replay setting', function () { return { liveDetails } } - async function checkVideosExist (videoId: string, existsInList: boolean, expectedStatus?: number) { + async function checkVideosExist (videoId: string, existsInList: boolean, expectedStatus?: HttpStatusCodeType) { for (const server of servers) { const length = existsInList ? 1 : 0 @@ -106,14 +119,14 @@ describe('Save replay setting', function () { } } - async function checkVideoState (videoId: string, state: VideoState) { + async function checkVideoState (videoId: string, state: VideoStateType) { for (const server of servers) { const video = await server.videos.get({ id: videoId }) expect(video.state.id).to.equal(state) } } - async function checkVideoPrivacy (videoId: string, privacy: VideoPrivacy) { + async function checkVideoPrivacy (videoId: string, privacy: VideoPrivacyType) { for (const server of servers) { const video = await server.videos.get({ id: videoId }) expect(video.privacy.id).to.equal(privacy) diff --git a/server/tests/api/live/live-socket-messages.ts b/packages/tests/src/api/live/live-socket-messages.ts similarity index 93% rename from server/tests/api/live/live-socket-messages.ts rename to packages/tests/src/api/live/live-socket-messages.ts index 0cccd1594..80bae154c 100644 --- a/server/tests/api/live/live-socket-messages.ts +++ b/packages/tests/src/api/live/live-socket-messages.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { wait } from '@shared/core-utils' -import { LiveVideoEventPayload, VideoPrivacy, VideoState } from '@shared/models' +import { wait } from '@peertube/peertube-core-utils' +import { LiveVideoEventPayload, VideoPrivacy, VideoState, VideoStateType } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -13,7 +13,7 @@ import { stopFfmpeg, waitJobs, waitUntilLivePublishedOnAllServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test live socket messages', function () { let servers: PeerTubeServer[] = [] @@ -59,8 +59,8 @@ describe('Test live socket messages', function () { it('Should correctly send a message when the live starts and ends', async function () { this.timeout(60000) - const localStateChanges: VideoState[] = [] - const remoteStateChanges: VideoState[] = [] + const localStateChanges: VideoStateType[] = [] + const remoteStateChanges: VideoStateType[] = [] const liveVideoUUID = await createLiveWrapper() await waitJobs(servers) @@ -151,7 +151,7 @@ describe('Test live socket messages', function () { it('Should not receive a notification after unsubscribe', async function () { this.timeout(120000) - const stateChanges: VideoState[] = [] + const stateChanges: VideoStateType[] = [] const liveVideoUUID = await createLiveWrapper() await waitJobs(servers) diff --git a/server/tests/api/live/live.ts b/packages/tests/src/api/live/live.ts similarity index 98% rename from server/tests/api/live/live.ts rename to packages/tests/src/api/live/live.ts index 2b302a8a2..20804f889 100644 --- a/server/tests/api/live/live.ts +++ b/packages/tests/src/api/live/live.ts @@ -2,9 +2,8 @@ import { expect } from 'chai' import { basename, join } from 'path' -import { SQLCommand, testImageGeneratedByFFmpeg, testLiveVideoResolutions } from '@server/tests/shared' -import { getAllFiles, wait } from '@shared/core-utils' -import { ffprobePromise, getVideoStream } from '@shared/ffmpeg' +import { getAllFiles, wait } from '@peertube/peertube-core-utils' +import { ffprobePromise, getVideoStream } from '@peertube/peertube-ffmpeg' import { HttpStatusCode, LiveVideo, @@ -14,7 +13,7 @@ import { VideoPrivacy, VideoState, VideoStreamingPlaylistType -} from '@shared/models' +} from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -31,7 +30,10 @@ import { testFfmpegStreamError, waitJobs, waitUntilLivePublishedOnAllServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' +import { testImageGeneratedByFFmpeg } from '@tests/shared/checks.js' +import { testLiveVideoResolutions } from '@tests/shared/live.js' +import { SQLCommand } from '@tests/shared/sql-command.js' describe('Test live', function () { let servers: PeerTubeServer[] = [] diff --git a/server/tests/api/moderation/abuses.ts b/packages/tests/src/api/moderation/abuses.ts similarity index 99% rename from server/tests/api/moderation/abuses.ts rename to packages/tests/src/api/moderation/abuses.ts index 9fc296ea8..649de224e 100644 --- a/server/tests/api/moderation/abuses.ts +++ b/packages/tests/src/api/moderation/abuses.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { AbuseMessage, AbusePredefinedReasonsString, AbuseState, AdminAbuse, UserAbuse } from '@shared/models' +import { AbuseMessage, AbusePredefinedReasonsString, AbuseState, AdminAbuse, UserAbuse } from '@peertube/peertube-models' import { AbusesCommand, cleanupTests, @@ -12,7 +12,7 @@ import { setDefaultAccountAvatar, setDefaultChannelAvatar, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test abuses', function () { let servers: PeerTubeServer[] = [] diff --git a/server/tests/api/moderation/blocklist-notification.ts b/packages/tests/src/api/moderation/blocklist-notification.ts similarity index 97% rename from server/tests/api/moderation/blocklist-notification.ts rename to packages/tests/src/api/moderation/blocklist-notification.ts index 9c2863a58..abf36313b 100644 --- a/server/tests/api/moderation/blocklist-notification.ts +++ b/packages/tests/src/api/moderation/blocklist-notification.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { UserNotificationType } from '@shared/models' +import { UserNotificationType, UserNotificationType_Type } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -9,9 +9,9 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' -async function checkNotifications (server: PeerTubeServer, token: string, expected: UserNotificationType[]) { +async function checkNotifications (server: PeerTubeServer, token: string, expected: UserNotificationType_Type[]) { const { data } = await server.notifications.list({ token, start: 0, count: 10, unread: true }) expect(data).to.have.lengthOf(expected.length) diff --git a/server/tests/api/moderation/blocklist.ts b/packages/tests/src/api/moderation/blocklist.ts similarity index 99% rename from server/tests/api/moderation/blocklist.ts rename to packages/tests/src/api/moderation/blocklist.ts index b90d8c16c..a84515241 100644 --- a/server/tests/api/moderation/blocklist.ts +++ b/packages/tests/src/api/moderation/blocklist.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { UserNotificationType } from '@shared/models' +import { UserNotificationType } from '@peertube/peertube-models' import { BlocklistCommand, cleanupTests, @@ -12,7 +12,7 @@ import { setAccessTokensToServers, setDefaultAccountAvatar, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' async function checkAllVideos (server: PeerTubeServer, token: string) { { diff --git a/packages/tests/src/api/moderation/index.ts b/packages/tests/src/api/moderation/index.ts new file mode 100644 index 000000000..e3794d01e --- /dev/null +++ b/packages/tests/src/api/moderation/index.ts @@ -0,0 +1,4 @@ +export * from './abuses.js' +export * from './blocklist-notification.js' +export * from './blocklist.js' +export * from './video-blacklist.js' diff --git a/server/tests/api/moderation/video-blacklist.ts b/packages/tests/src/api/moderation/video-blacklist.ts similarity index 98% rename from server/tests/api/moderation/video-blacklist.ts rename to packages/tests/src/api/moderation/video-blacklist.ts index ef087a93b..341dadad0 100644 --- a/server/tests/api/moderation/video-blacklist.ts +++ b/packages/tests/src/api/moderation/video-blacklist.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { FIXTURE_URLS } from '@server/tests/shared' -import { sortObjectComparator } from '@shared/core-utils' -import { UserAdminFlag, UserRole, VideoBlacklist, VideoBlacklistType } from '@shared/models' +import { FIXTURE_URLS } from '@tests/shared/tests.js' +import { sortObjectComparator } from '@peertube/peertube-core-utils' +import { UserAdminFlag, UserRole, VideoBlacklist, VideoBlacklistType } from '@peertube/peertube-models' import { BlacklistCommand, cleanupTests, @@ -14,7 +14,7 @@ import { setAccessTokensToServers, setDefaultChannelAvatar, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test video blacklist', function () { let servers: PeerTubeServer[] = [] diff --git a/server/tests/api/notifications/admin-notifications.ts b/packages/tests/src/api/notifications/admin-notifications.ts similarity index 90% rename from server/tests/api/notifications/admin-notifications.ts rename to packages/tests/src/api/notifications/admin-notifications.ts index 4824542c9..2186dc55a 100644 --- a/server/tests/api/notifications/admin-notifications.ts +++ b/packages/tests/src/api/notifications/admin-notifications.ts @@ -1,18 +1,13 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { - CheckerBaseParams, - checkNewPeerTubeVersion, - checkNewPluginVersion, - MockJoinPeerTubeVersions, - MockSmtpServer, - prepareNotificationsTest, - SQLCommand -} from '@server/tests/shared' -import { wait } from '@shared/core-utils' -import { PluginType, UserNotification, UserNotificationType } from '@shared/models' -import { cleanupTests, PeerTubeServer } from '@shared/server-commands' +import { wait } from '@peertube/peertube-core-utils' +import { PluginType, UserNotification, UserNotificationType } from '@peertube/peertube-models' +import { cleanupTests, PeerTubeServer } from '@peertube/peertube-server-commands' +import { MockSmtpServer } from '@tests/shared/mock-servers/mock-email.js' +import { MockJoinPeerTubeVersions } from '@tests/shared/mock-servers/mock-joinpeertube-versions.js' +import { CheckerBaseParams, prepareNotificationsTest, checkNewPeerTubeVersion, checkNewPluginVersion } from '@tests/shared/notifications.js' +import { SQLCommand } from '@tests/shared/sql-command.js' describe('Test admin notifications', function () { let server: PeerTubeServer diff --git a/server/tests/api/notifications/comments-notifications.ts b/packages/tests/src/api/notifications/comments-notifications.ts similarity index 97% rename from server/tests/api/notifications/comments-notifications.ts rename to packages/tests/src/api/notifications/comments-notifications.ts index 0a4bfc5e4..5647d1286 100644 --- a/server/tests/api/notifications/comments-notifications.ts +++ b/packages/tests/src/api/notifications/comments-notifications.ts @@ -1,15 +1,10 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { - checkCommentMention, - CheckerBaseParams, - checkNewCommentOnMyVideo, - MockSmtpServer, - prepareNotificationsTest -} from '@server/tests/shared' -import { UserNotification } from '@shared/models' -import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands' +import { UserNotification } from '@peertube/peertube-models' +import { cleanupTests, PeerTubeServer, waitJobs } from '@peertube/peertube-server-commands' +import { MockSmtpServer } from '@tests/shared/mock-servers/mock-email.js' +import { prepareNotificationsTest, CheckerBaseParams, checkNewCommentOnMyVideo, checkCommentMention } from '@tests/shared/notifications.js' describe('Test comments notifications', function () { let servers: PeerTubeServer[] = [] diff --git a/packages/tests/src/api/notifications/index.ts b/packages/tests/src/api/notifications/index.ts new file mode 100644 index 000000000..d63d94182 --- /dev/null +++ b/packages/tests/src/api/notifications/index.ts @@ -0,0 +1,6 @@ +import './admin-notifications.js' +import './comments-notifications.js' +import './moderation-notifications.js' +import './notifications-api.js' +import './registrations-notifications.js' +import './user-notifications.js' diff --git a/server/tests/api/notifications/moderation-notifications.ts b/packages/tests/src/api/notifications/moderation-notifications.ts similarity index 97% rename from server/tests/api/notifications/moderation-notifications.ts rename to packages/tests/src/api/notifications/moderation-notifications.ts index e7a5c47e9..493764882 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/packages/tests/src/api/notifications/moderation-notifications.ts @@ -1,26 +1,26 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ +import { wait } from '@peertube/peertube-core-utils' +import { AbuseState, CustomConfig, UserNotification, UserRole, VideoPrivacy } from '@peertube/peertube-models' +import { buildUUID } from '@peertube/peertube-node-utils' +import { cleanupTests, PeerTubeServer, waitJobs } from '@peertube/peertube-server-commands' +import { MockSmtpServer } from '@tests/shared/mock-servers/mock-email.js' +import { MockInstancesIndex } from '@tests/shared/mock-servers/mock-instances-index.js' import { - checkAbuseStateChange, - checkAutoInstanceFollowing, + prepareNotificationsTest, CheckerBaseParams, - checkNewAbuseMessage, - checkNewAccountAbuseForModerators, - checkNewBlacklistOnMyVideo, - checkNewCommentAbuseForModerators, - checkNewInstanceFollower, checkNewVideoAbuseForModerators, - checkNewVideoFromSubscription, + checkNewCommentAbuseForModerators, + checkNewAccountAbuseForModerators, + checkAbuseStateChange, + checkNewAbuseMessage, + checkNewBlacklistOnMyVideo, + checkNewInstanceFollower, + checkAutoInstanceFollowing, checkVideoAutoBlacklistForModerators, checkVideoIsPublished, - MockInstancesIndex, - MockSmtpServer, - prepareNotificationsTest -} from '@server/tests/shared' -import { wait } from '@shared/core-utils' -import { buildUUID } from '@shared/extra-utils' -import { AbuseState, CustomConfig, UserNotification, UserRole, VideoPrivacy } from '@shared/models' -import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands' + checkNewVideoFromSubscription +} from '@tests/shared/notifications.js' describe('Test moderation notifications', function () { let servers: PeerTubeServer[] = [] @@ -537,7 +537,7 @@ describe('Test moderation notifications', function () { privacy: VideoPrivacy.PRIVATE, scheduleUpdate: { updateAt: updateAt.toISOString(), - privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC + privacy: VideoPrivacy.PUBLIC } } @@ -569,7 +569,7 @@ describe('Test moderation notifications', function () { privacy: VideoPrivacy.PRIVATE, scheduleUpdate: { updateAt: updateAt.toISOString(), - privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC + privacy: VideoPrivacy.PUBLIC } } diff --git a/server/tests/api/notifications/notifications-api.ts b/packages/tests/src/api/notifications/notifications-api.ts similarity index 95% rename from server/tests/api/notifications/notifications-api.ts rename to packages/tests/src/api/notifications/notifications-api.ts index 1fc861160..1c7461553 100644 --- a/server/tests/api/notifications/notifications-api.ts +++ b/packages/tests/src/api/notifications/notifications-api.ts @@ -1,15 +1,15 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' +import { UserNotification, UserNotificationSettingValue } from '@peertube/peertube-models' +import { cleanupTests, PeerTubeServer, waitJobs } from '@peertube/peertube-server-commands' +import { MockSmtpServer } from '@tests/shared/mock-servers/mock-email.js' import { + prepareNotificationsTest, CheckerBaseParams, - checkNewVideoFromSubscription, getAllNotificationsSettings, - MockSmtpServer, - prepareNotificationsTest -} from '@server/tests/shared' -import { UserNotification, UserNotificationSettingValue } from '@shared/models' -import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands' + checkNewVideoFromSubscription +} from '@tests/shared/notifications.js' describe('Test notifications API', function () { let server: PeerTubeServer @@ -104,7 +104,7 @@ describe('Test notifications API', function () { }) it('Should not have notifications', async function () { - this.timeout(20000) + this.timeout(40000) await server.notifications.updateMySettings({ token: userToken, diff --git a/server/tests/api/notifications/registrations-notifications.ts b/packages/tests/src/api/notifications/registrations-notifications.ts similarity index 87% rename from server/tests/api/notifications/registrations-notifications.ts rename to packages/tests/src/api/notifications/registrations-notifications.ts index d20fc8df3..1f166cb36 100644 --- a/server/tests/api/notifications/registrations-notifications.ts +++ b/packages/tests/src/api/notifications/registrations-notifications.ts @@ -1,14 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { - CheckerBaseParams, - checkRegistrationRequest, - checkUserRegistered, - MockSmtpServer, - prepareNotificationsTest -} from '@server/tests/shared' -import { UserNotification } from '@shared/models' -import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands' +import { UserNotification } from '@peertube/peertube-models' +import { cleanupTests, PeerTubeServer, waitJobs } from '@peertube/peertube-server-commands' +import { MockSmtpServer } from '@tests/shared/mock-servers/mock-email.js' +import { CheckerBaseParams, prepareNotificationsTest, checkUserRegistered, checkRegistrationRequest } from '@tests/shared/notifications.js' describe('Test registrations notifications', function () { let server: PeerTubeServer diff --git a/server/tests/api/notifications/user-notifications.ts b/packages/tests/src/api/notifications/user-notifications.ts similarity index 96% rename from server/tests/api/notifications/user-notifications.ts rename to packages/tests/src/api/notifications/user-notifications.ts index 55da10265..4c03cdb47 100644 --- a/server/tests/api/notifications/user-notifications.ts +++ b/packages/tests/src/api/notifications/user-notifications.ts @@ -1,22 +1,22 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' +import { wait } from '@peertube/peertube-core-utils' +import { UserNotification, UserNotificationType, VideoPrivacy, VideoStudioTask } from '@peertube/peertube-models' +import { buildUUID } from '@peertube/peertube-node-utils' +import { cleanupTests, findExternalSavedVideo, PeerTubeServer, stopFfmpeg, waitJobs } from '@peertube/peertube-server-commands' +import { MockSmtpServer } from '@tests/shared/mock-servers/mock-email.js' import { + prepareNotificationsTest, CheckerBaseParams, - checkMyVideoImportIsFinished, - checkNewActorFollow, checkNewVideoFromSubscription, checkVideoIsPublished, checkVideoStudioEditionIsFinished, - FIXTURE_URLS, - MockSmtpServer, - prepareNotificationsTest, - uploadRandomVideoOnServers -} from '@server/tests/shared' -import { wait } from '@shared/core-utils' -import { buildUUID } from '@shared/extra-utils' -import { UserNotification, UserNotificationType, VideoPrivacy, VideoStudioTask } from '@shared/models' -import { cleanupTests, findExternalSavedVideo, PeerTubeServer, stopFfmpeg, waitJobs } from '@shared/server-commands' + checkMyVideoImportIsFinished, + checkNewActorFollow +} from '@tests/shared/notifications.js' +import { FIXTURE_URLS } from '@tests/shared/tests.js' +import { uploadRandomVideoOnServers } from '@tests/shared/videos.js' describe('Test user notifications', function () { let servers: PeerTubeServer[] = [] @@ -96,7 +96,7 @@ describe('Test user notifications', function () { privacy: VideoPrivacy.PRIVATE, scheduleUpdate: { updateAt: updateAt.toISOString(), - privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC + privacy: VideoPrivacy.PUBLIC } } const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 1, data) @@ -115,7 +115,7 @@ describe('Test user notifications', function () { privacy: VideoPrivacy.PRIVATE, scheduleUpdate: { updateAt: updateAt.toISOString(), - privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC + privacy: VideoPrivacy.PUBLIC } } const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 2, data) @@ -134,7 +134,7 @@ describe('Test user notifications', function () { privacy: VideoPrivacy.PRIVATE, scheduleUpdate: { updateAt: updateAt.toISOString(), - privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC + privacy: VideoPrivacy.PUBLIC } } const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 1, data) @@ -292,7 +292,7 @@ describe('Test user notifications', function () { privacy: VideoPrivacy.PRIVATE, scheduleUpdate: { updateAt: updateAt.toISOString(), - privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC + privacy: VideoPrivacy.PUBLIC } } const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 2, data) @@ -310,7 +310,7 @@ describe('Test user notifications', function () { privacy: VideoPrivacy.PRIVATE, scheduleUpdate: { updateAt: updateAt.toISOString(), - privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC + privacy: VideoPrivacy.PUBLIC } } const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 2, data) diff --git a/packages/tests/src/api/object-storage/index.ts b/packages/tests/src/api/object-storage/index.ts new file mode 100644 index 000000000..51d2a29a0 --- /dev/null +++ b/packages/tests/src/api/object-storage/index.ts @@ -0,0 +1,4 @@ +export * from './live.js' +export * from './video-imports.js' +export * from './video-static-file-privacy.js' +export * from './videos.js' diff --git a/server/tests/api/object-storage/live.ts b/packages/tests/src/api/object-storage/live.ts similarity index 95% rename from server/tests/api/object-storage/live.ts rename to packages/tests/src/api/object-storage/live.ts index 07ff4763b..c8c214af5 100644 --- a/server/tests/api/object-storage/live.ts +++ b/packages/tests/src/api/object-storage/live.ts @@ -1,9 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { expectStartWith, MockObjectStorageProxy, SQLCommand, testLiveVideoResolutions } from '@server/tests/shared' -import { areMockObjectStorageTestsDisabled } from '@shared/core-utils' -import { HttpStatusCode, LiveVideoCreate, VideoPrivacy } from '@shared/models' +import { areMockObjectStorageTestsDisabled } from '@peertube/peertube-node-utils' +import { HttpStatusCode, LiveVideoCreate, VideoPrivacy } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -19,7 +18,11 @@ import { waitUntilLivePublishedOnAllServers, waitUntilLiveReplacedByReplayOnAllServers, waitUntilLiveWaitingOnAllServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' +import { expectStartWith } from '@tests/shared/checks.js' +import { testLiveVideoResolutions } from '@tests/shared/live.js' +import { MockObjectStorageProxy } from '@tests/shared/mock-servers/mock-object-storage.js' +import { SQLCommand } from '@tests/shared/sql-command.js' async function createLive (server: PeerTubeServer, permanent: boolean) { const attributes: LiveVideoCreate = { diff --git a/server/tests/api/object-storage/video-imports.ts b/packages/tests/src/api/object-storage/video-imports.ts similarity index 90% rename from server/tests/api/object-storage/video-imports.ts rename to packages/tests/src/api/object-storage/video-imports.ts index 57150e5a6..43f769842 100644 --- a/server/tests/api/object-storage/video-imports.ts +++ b/packages/tests/src/api/object-storage/video-imports.ts @@ -1,9 +1,10 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { expectStartWith, FIXTURE_URLS } from '@server/tests/shared' -import { areMockObjectStorageTestsDisabled } from '@shared/core-utils' -import { HttpStatusCode, VideoPrivacy } from '@shared/models' +import { expectStartWith } from '@tests/shared/checks.js' +import { FIXTURE_URLS } from '@tests/shared/tests.js' +import { areMockObjectStorageTestsDisabled } from '@peertube/peertube-node-utils' +import { HttpStatusCode, VideoPrivacy } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -13,7 +14,7 @@ import { setAccessTokensToServers, setDefaultVideoChannel, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' async function importVideo (server: PeerTubeServer) { const attributes = { diff --git a/server/tests/api/object-storage/video-static-file-privacy.ts b/packages/tests/src/api/object-storage/video-static-file-privacy.ts similarity index 98% rename from server/tests/api/object-storage/video-static-file-privacy.ts rename to packages/tests/src/api/object-storage/video-static-file-privacy.ts index 64ab542a5..cf6e9b4b9 100644 --- a/server/tests/api/object-storage/video-static-file-privacy.ts +++ b/packages/tests/src/api/object-storage/video-static-file-privacy.ts @@ -2,9 +2,9 @@ import { expect } from 'chai' import { basename } from 'path' -import { checkVideoFileTokenReinjection, expectStartWith, SQLCommand } from '@server/tests/shared' -import { areScalewayObjectStorageTestsDisabled, getAllFiles, getHLS } from '@shared/core-utils' -import { HttpStatusCode, LiveVideo, VideoDetails, VideoPrivacy } from '@shared/models' +import { getAllFiles, getHLS } from '@peertube/peertube-core-utils' +import { HttpStatusCode, LiveVideo, VideoDetails, VideoPrivacy } from '@peertube/peertube-models' +import { areScalewayObjectStorageTestsDisabled } from '@peertube/peertube-node-utils' import { cleanupTests, createSingleServer, @@ -17,7 +17,10 @@ import { setDefaultVideoChannel, stopFfmpeg, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' +import { expectStartWith } from '@tests/shared/checks.js' +import { SQLCommand } from '@tests/shared/sql-command.js' +import { checkVideoFileTokenReinjection } from '@tests/shared/streaming-playlists.js' function extractFilenameFromUrl (url: string) { const parts = basename(url).split(':') diff --git a/server/tests/api/object-storage/videos.ts b/packages/tests/src/api/object-storage/videos.ts similarity index 94% rename from server/tests/api/object-storage/videos.ts rename to packages/tests/src/api/object-storage/videos.ts index dcc52ef06..66bca5cc8 100644 --- a/server/tests/api/object-storage/videos.ts +++ b/packages/tests/src/api/object-storage/videos.ts @@ -2,20 +2,10 @@ import bytes from 'bytes' import { expect } from 'chai' -import { stat } from 'fs-extra' -import { merge } from 'lodash' -import { - checkTmpIsEmpty, - checkWebTorrentWorks, - expectLogDoesNotContain, - expectStartWith, - generateHighBitrateVideo, - MockObjectStorageProxy, - SQLCommand -} from '@server/tests/shared' -import { areMockObjectStorageTestsDisabled } from '@shared/core-utils' -import { sha1 } from '@shared/extra-utils' -import { HttpStatusCode, VideoDetails } from '@shared/models' +import { stat } from 'fs/promises' +import merge from 'lodash-es/merge.js' +import { HttpStatusCode, VideoDetails } from '@peertube/peertube-models' +import { areMockObjectStorageTestsDisabled, sha1 } from '@peertube/peertube-node-utils' import { cleanupTests, createMultipleServers, @@ -27,7 +17,13 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' +import { expectStartWith, expectLogDoesNotContain } from '@tests/shared/checks.js' +import { checkTmpIsEmpty } from '@tests/shared/directories.js' +import { generateHighBitrateVideo } from '@tests/shared/generate.js' +import { MockObjectStorageProxy } from '@tests/shared/mock-servers/mock-object-storage.js' +import { SQLCommand } from '@tests/shared/sql-command.js' +import { checkWebTorrentWorks } from '@tests/shared/webtorrent.js' async function checkFiles (options: { server: PeerTubeServer diff --git a/packages/tests/src/api/redundancy/index.ts b/packages/tests/src/api/redundancy/index.ts new file mode 100644 index 000000000..f6b70c8af --- /dev/null +++ b/packages/tests/src/api/redundancy/index.ts @@ -0,0 +1,3 @@ +import './redundancy-constraints.js' +import './redundancy.js' +import './manage-redundancy.js' diff --git a/server/tests/api/redundancy/manage-redundancy.ts b/packages/tests/src/api/redundancy/manage-redundancy.ts similarity index 98% rename from server/tests/api/redundancy/manage-redundancy.ts rename to packages/tests/src/api/redundancy/manage-redundancy.ts index 404b65a99..14556e26c 100644 --- a/server/tests/api/redundancy/manage-redundancy.ts +++ b/packages/tests/src/api/redundancy/manage-redundancy.ts @@ -9,8 +9,8 @@ import { RedundancyCommand, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' -import { VideoPrivacy, VideoRedundanciesTarget } from '@shared/models' +} from '@peertube/peertube-server-commands' +import { VideoPrivacy, VideoRedundanciesTarget } from '@peertube/peertube-models' describe('Test manage videos redundancy', function () { const targets: VideoRedundanciesTarget[] = [ 'my-videos', 'remote-videos' ] diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/packages/tests/src/api/redundancy/redundancy-constraints.ts similarity index 97% rename from server/tests/api/redundancy/redundancy-constraints.ts rename to packages/tests/src/api/redundancy/redundancy-constraints.ts index c86573168..24966b270 100644 --- a/server/tests/api/redundancy/redundancy-constraints.ts +++ b/packages/tests/src/api/redundancy/redundancy-constraints.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { VideoPrivacy } from '@shared/models' +import { VideoPrivacy } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -9,7 +9,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test redundancy constraints', function () { let remoteServer: PeerTubeServer diff --git a/server/tests/api/redundancy/redundancy.ts b/packages/tests/src/api/redundancy/redundancy.ts similarity index 98% rename from server/tests/api/redundancy/redundancy.ts rename to packages/tests/src/api/redundancy/redundancy.ts index 0c5c27225..69afae037 100644 --- a/server/tests/api/redundancy/redundancy.ts +++ b/packages/tests/src/api/redundancy/redundancy.ts @@ -1,11 +1,10 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { readdir } from 'fs-extra' +import { readdir } from 'fs/promises' import { decode as magnetUriDecode } from 'magnet-uri' import { basename, join } from 'path' -import { checkSegmentHash, checkVideoFilesWereRemoved, saveVideoInServers } from '@server/tests/shared' -import { wait } from '@shared/core-utils' +import { wait } from '@peertube/peertube-core-utils' import { HttpStatusCode, VideoDetails, @@ -13,7 +12,7 @@ import { VideoPrivacy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManual -} from '@shared/models' +} from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -23,7 +22,9 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' +import { checkSegmentHash } from '@tests/shared/streaming-playlists.js' +import { checkVideoFilesWereRemoved, saveVideoInServers } from '@tests/shared/videos.js' let servers: PeerTubeServer[] = [] let video1Server2: VideoDetails diff --git a/packages/tests/src/api/runners/index.ts b/packages/tests/src/api/runners/index.ts new file mode 100644 index 000000000..441ddc874 --- /dev/null +++ b/packages/tests/src/api/runners/index.ts @@ -0,0 +1,5 @@ +export * from './runner-common.js' +export * from './runner-live-transcoding.js' +export * from './runner-socket.js' +export * from './runner-studio-transcoding.js' +export * from './runner-vod-transcoding.js' diff --git a/server/tests/api/runners/runner-common.ts b/packages/tests/src/api/runners/runner-common.ts similarity index 98% rename from server/tests/api/runners/runner-common.ts rename to packages/tests/src/api/runners/runner-common.ts index 9b2eb8b27..53ea321d0 100644 --- a/server/tests/api/runners/runner-common.ts +++ b/packages/tests/src/api/runners/runner-common.ts @@ -1,24 +1,25 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { expect } from 'chai' -import { wait } from '@shared/core-utils' +import { wait } from '@peertube/peertube-core-utils' import { HttpStatusCode, Runner, RunnerJob, RunnerJobAdmin, RunnerJobState, + RunnerJobStateType, RunnerJobVODWebVideoTranscodingPayload, RunnerRegistrationToken -} from '@shared/models' +} from '@peertube/peertube-models' import { + PeerTubeServer, cleanupTests, createSingleServer, - PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' +import { expect } from 'chai' describe('Test runner common actions', function () { let server: PeerTubeServer @@ -224,8 +225,8 @@ describe('Test runner common actions', function () { let failedJob: RunnerJob async function checkMainJobState ( - mainJobState: RunnerJobState, - otherJobStates: RunnerJobState[] = [ RunnerJobState.PENDING, RunnerJobState.WAITING_FOR_PARENT_JOB ] + mainJobState: RunnerJobStateType, + otherJobStates: RunnerJobStateType[] = [ RunnerJobState.PENDING, RunnerJobState.WAITING_FOR_PARENT_JOB ] ) { const { data } = await server.runnerJobs.list({ count: 10, sort: '-updatedAt' }) diff --git a/server/tests/api/runners/runner-live-transcoding.ts b/packages/tests/src/api/runners/runner-live-transcoding.ts similarity index 96% rename from server/tests/api/runners/runner-live-transcoding.ts rename to packages/tests/src/api/runners/runner-live-transcoding.ts index b11d54039..20c1e5c2a 100644 --- a/server/tests/api/runners/runner-live-transcoding.ts +++ b/packages/tests/src/api/runners/runner-live-transcoding.ts @@ -2,19 +2,21 @@ import { expect } from 'chai' import { FfmpegCommand } from 'fluent-ffmpeg' -import { readFile } from 'fs-extra' -import { buildAbsoluteFixturePath, wait } from '@shared/core-utils' +import { readFile } from 'fs/promises' +import { wait } from '@peertube/peertube-core-utils' import { HttpStatusCode, LiveRTMPHLSTranscodingUpdatePayload, LiveVideo, LiveVideoError, + LiveVideoErrorType, RunnerJob, RunnerJobLiveRTMPHLSTranscodingPayload, Video, VideoPrivacy, VideoState -} from '@shared/models' +} from '@peertube/peertube-models' +import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils' import { cleanupTests, createSingleServer, @@ -26,7 +28,7 @@ import { stopFfmpeg, testFfmpegStreamError, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test runner live transcoding', function () { let server: PeerTubeServer @@ -263,7 +265,7 @@ describe('Test runner live transcoding', function () { return job } - async function checkSessionError (error: LiveVideoError) { + async function checkSessionError (error: LiveVideoErrorType) { await wait(1500) await waitJobs([ server ]) diff --git a/server/tests/api/runners/runner-socket.ts b/packages/tests/src/api/runners/runner-socket.ts similarity index 97% rename from server/tests/api/runners/runner-socket.ts rename to packages/tests/src/api/runners/runner-socket.ts index 215164e48..726ef084f 100644 --- a/server/tests/api/runners/runner-socket.ts +++ b/packages/tests/src/api/runners/runner-socket.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { wait } from '@shared/core-utils' +import { wait } from '@peertube/peertube-core-utils' import { cleanupTests, createSingleServer, @@ -9,7 +9,7 @@ import { setAccessTokensToServers, setDefaultVideoChannel, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test runner socket', function () { let server: PeerTubeServer diff --git a/server/tests/api/runners/runner-studio-transcoding.ts b/packages/tests/src/api/runners/runner-studio-transcoding.ts similarity index 93% rename from server/tests/api/runners/runner-studio-transcoding.ts rename to packages/tests/src/api/runners/runner-studio-transcoding.ts index f5cea6cea..adf6941c3 100644 --- a/server/tests/api/runners/runner-studio-transcoding.ts +++ b/packages/tests/src/api/runners/runner-studio-transcoding.ts @@ -1,16 +1,15 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { readFile } from 'fs-extra' -import { checkPersistentTmpIsEmpty, checkVideoDuration } from '@server/tests/shared' -import { buildAbsoluteFixturePath } from '@shared/core-utils' +import { readFile } from 'fs/promises' +import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils' import { RunnerJobStudioTranscodingPayload, VideoStudioTranscodingSuccess, VideoState, VideoStudioTask, VideoStudioTaskIntro -} from '@shared/models' +} from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -20,7 +19,9 @@ import { setDefaultVideoChannel, VideoStudioCommand, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' +import { checkVideoDuration } from '@tests/shared/checks.js' +import { checkPersistentTmpIsEmpty } from '@tests/shared/directories.js' describe('Test runner video studio transcoding', function () { let servers: PeerTubeServer[] = [] diff --git a/server/tests/api/runners/runner-vod-transcoding.ts b/packages/tests/src/api/runners/runner-vod-transcoding.ts similarity index 98% rename from server/tests/api/runners/runner-vod-transcoding.ts rename to packages/tests/src/api/runners/runner-vod-transcoding.ts index ee6be4ee9..fe1c8f0b2 100644 --- a/server/tests/api/runners/runner-vod-transcoding.ts +++ b/packages/tests/src/api/runners/runner-vod-transcoding.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { readFile } from 'fs-extra' -import { completeCheckHlsPlaylist } from '@server/tests/shared' -import { buildAbsoluteFixturePath } from '@shared/core-utils' +import { readFile } from 'fs/promises' +import { completeCheckHlsPlaylist } from '@tests/shared/streaming-playlists.js' +import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils' import { HttpStatusCode, RunnerJobSuccessPayload, @@ -15,7 +15,7 @@ import { VODAudioMergeTranscodingSuccess, VODHLSTranscodingSuccess, VODWebVideoTranscodingSuccess -} from '@shared/models' +} from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -26,7 +26,7 @@ import { setAccessTokensToServers, setDefaultVideoChannel, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' async function processAllJobs (server: PeerTubeServer, runnerToken: string) { do { diff --git a/packages/tests/src/api/search/index.ts b/packages/tests/src/api/search/index.ts new file mode 100644 index 000000000..f4420261d --- /dev/null +++ b/packages/tests/src/api/search/index.ts @@ -0,0 +1,7 @@ +import './search-activitypub-video-playlists.js' +import './search-activitypub-video-channels.js' +import './search-activitypub-videos.js' +import './search-channels.js' +import './search-index.js' +import './search-playlists.js' +import './search-videos.js' diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/packages/tests/src/api/search/search-activitypub-video-channels.ts similarity index 98% rename from server/tests/api/search/search-activitypub-video-channels.ts rename to packages/tests/src/api/search/search-activitypub-video-channels.ts index 003bd34d0..b63f45b18 100644 --- a/server/tests/api/search/search-activitypub-video-channels.ts +++ b/packages/tests/src/api/search/search-activitypub-video-channels.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { wait } from '@shared/core-utils' -import { VideoChannel } from '@shared/models' +import { wait } from '@peertube/peertube-core-utils' +import { VideoChannel } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -12,7 +12,7 @@ import { setDefaultAccountAvatar, setDefaultVideoChannel, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test ActivityPub video channels search', function () { let servers: PeerTubeServer[] diff --git a/server/tests/api/search/search-activitypub-video-playlists.ts b/packages/tests/src/api/search/search-activitypub-video-playlists.ts similarity index 97% rename from server/tests/api/search/search-activitypub-video-playlists.ts rename to packages/tests/src/api/search/search-activitypub-video-playlists.ts index 2bb5d869a..33ecfd8e7 100644 --- a/server/tests/api/search/search-activitypub-video-playlists.ts +++ b/packages/tests/src/api/search/search-activitypub-video-playlists.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { wait } from '@shared/core-utils' -import { VideoPlaylistPrivacy } from '@shared/models' +import { wait } from '@peertube/peertube-core-utils' +import { VideoPlaylistPrivacy } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -12,7 +12,7 @@ import { setDefaultAccountAvatar, setDefaultVideoChannel, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test ActivityPub playlists search', function () { let servers: PeerTubeServer[] diff --git a/server/tests/api/search/search-activitypub-videos.ts b/packages/tests/src/api/search/search-activitypub-videos.ts similarity index 97% rename from server/tests/api/search/search-activitypub-videos.ts rename to packages/tests/src/api/search/search-activitypub-videos.ts index 4c7118422..72759f21e 100644 --- a/server/tests/api/search/search-activitypub-videos.ts +++ b/packages/tests/src/api/search/search-activitypub-videos.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { wait } from '@shared/core-utils' -import { VideoPrivacy } from '@shared/models' +import { wait } from '@peertube/peertube-core-utils' +import { VideoPrivacy } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -12,7 +12,7 @@ import { setDefaultAccountAvatar, setDefaultVideoChannel, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test ActivityPub videos search', function () { let servers: PeerTubeServer[] diff --git a/server/tests/api/search/search-channels.ts b/packages/tests/src/api/search/search-channels.ts similarity index 97% rename from server/tests/api/search/search-channels.ts rename to packages/tests/src/api/search/search-channels.ts index c6b098a93..36596e036 100644 --- a/server/tests/api/search/search-channels.ts +++ b/packages/tests/src/api/search/search-channels.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { VideoChannel } from '@shared/models' +import { VideoChannel } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -11,7 +11,7 @@ import { setAccessTokensToServers, setDefaultAccountAvatar, setDefaultChannelAvatar -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test channels search', function () { let server: PeerTubeServer diff --git a/server/tests/api/search/search-index.ts b/packages/tests/src/api/search/search-index.ts similarity index 98% rename from server/tests/api/search/search-index.ts rename to packages/tests/src/api/search/search-index.ts index cbe628ccc..4bac7ea94 100644 --- a/server/tests/api/search/search-index.ts +++ b/packages/tests/src/api/search/search-index.ts @@ -8,8 +8,14 @@ import { VideoPlaylistsSearchQuery, VideoPlaylistType, VideosSearchQuery -} from '@shared/models' -import { cleanupTests, createSingleServer, PeerTubeServer, SearchCommand, setAccessTokensToServers } from '@shared/server-commands' +} from '@peertube/peertube-models' +import { + cleanupTests, + createSingleServer, + PeerTubeServer, + SearchCommand, + setAccessTokensToServers +} from '@peertube/peertube-server-commands' describe('Test index search', function () { const localVideoName = 'local video' + new Date().toISOString() diff --git a/server/tests/api/search/search-playlists.ts b/packages/tests/src/api/search/search-playlists.ts similarity index 97% rename from server/tests/api/search/search-playlists.ts rename to packages/tests/src/api/search/search-playlists.ts index a357674c2..cd16e202e 100644 --- a/server/tests/api/search/search-playlists.ts +++ b/packages/tests/src/api/search/search-playlists.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { VideoPlaylistPrivacy } from '@shared/models' +import { VideoPlaylistPrivacy } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -12,7 +12,7 @@ import { setDefaultAccountAvatar, setDefaultChannelAvatar, setDefaultVideoChannel -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test playlists search', function () { let server: PeerTubeServer diff --git a/server/tests/api/search/search-videos.ts b/packages/tests/src/api/search/search-videos.ts similarity index 99% rename from server/tests/api/search/search-videos.ts rename to packages/tests/src/api/search/search-videos.ts index f7f50147d..0739f0886 100644 --- a/server/tests/api/search/search-videos.ts +++ b/packages/tests/src/api/search/search-videos.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { wait } from '@shared/core-utils' -import { VideoPrivacy } from '@shared/models' +import { wait } from '@peertube/peertube-core-utils' +import { VideoPrivacy } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -14,7 +14,7 @@ import { setDefaultChannelAvatar, setDefaultVideoChannel, stopFfmpeg -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test videos search', function () { let server: PeerTubeServer diff --git a/server/tests/api/server/auto-follows.ts b/packages/tests/src/api/server/auto-follows.ts similarity index 96% rename from server/tests/api/server/auto-follows.ts rename to packages/tests/src/api/server/auto-follows.ts index 6ce1a3799..aa272ebcc 100644 --- a/server/tests/api/server/auto-follows.ts +++ b/packages/tests/src/api/server/auto-follows.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { MockInstancesIndex } from '@server/tests/shared' -import { wait } from '@shared/core-utils' -import { cleanupTests, createMultipleServers, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' +import { MockInstancesIndex } from '@tests/shared/mock-servers/index.js' +import { wait } from '@peertube/peertube-core-utils' +import { cleanupTests, createMultipleServers, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@peertube/peertube-server-commands' async function checkFollow (follower: PeerTubeServer, following: PeerTubeServer, exists: boolean) { { diff --git a/server/tests/api/server/bulk.ts b/packages/tests/src/api/server/bulk.ts similarity index 99% rename from server/tests/api/server/bulk.ts rename to packages/tests/src/api/server/bulk.ts index 66d791a0f..725bcfef2 100644 --- a/server/tests/api/server/bulk.ts +++ b/packages/tests/src/api/server/bulk.ts @@ -9,7 +9,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test bulk actions', function () { const commentsUser3: { videoId: number, commentId: number }[] = [] diff --git a/server/tests/api/server/config-defaults.ts b/packages/tests/src/api/server/config-defaults.ts similarity index 96% rename from server/tests/api/server/config-defaults.ts rename to packages/tests/src/api/server/config-defaults.ts index 041032f2b..e874af012 100644 --- a/server/tests/api/server/config-defaults.ts +++ b/packages/tests/src/api/server/config-defaults.ts @@ -1,9 +1,15 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { FIXTURE_URLS } from '@server/tests/shared' -import { VideoDetails, VideoPrivacy } from '@shared/models' -import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel } from '@shared/server-commands' +import { VideoDetails, VideoPrivacy } from '@peertube/peertube-models' +import { + cleanupTests, + createSingleServer, + PeerTubeServer, + setAccessTokensToServers, + setDefaultVideoChannel +} from '@peertube/peertube-server-commands' +import { FIXTURE_URLS } from '@tests/shared/tests.js' describe('Test config defaults', function () { let server: PeerTubeServer diff --git a/server/tests/api/server/config.ts b/packages/tests/src/api/server/config.ts similarity index 99% rename from server/tests/api/server/config.ts rename to packages/tests/src/api/server/config.ts index a614d92d2..ce64668f8 100644 --- a/server/tests/api/server/config.ts +++ b/packages/tests/src/api/server/config.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { parallelTests } from '@shared/core-utils' -import { CustomConfig, HttpStatusCode } from '@shared/models' +import { parallelTests } from '@peertube/peertube-node-utils' +import { CustomConfig, HttpStatusCode } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -10,7 +10,7 @@ import { makeGetRequest, PeerTubeServer, setAccessTokensToServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' function checkInitialConfig (server: PeerTubeServer, data: CustomConfig) { expect(data.instance.name).to.equal('PeerTube') diff --git a/server/tests/api/server/contact-form.ts b/packages/tests/src/api/server/contact-form.ts similarity index 92% rename from server/tests/api/server/contact-form.ts rename to packages/tests/src/api/server/contact-form.ts index 0256cc193..03389aa64 100644 --- a/server/tests/api/server/contact-form.ts +++ b/packages/tests/src/api/server/contact-form.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { MockSmtpServer } from '@server/tests/shared' -import { wait } from '@shared/core-utils' -import { HttpStatusCode } from '@shared/models' +import { MockSmtpServer } from '@tests/shared/mock-servers/index.js' +import { wait } from '@peertube/peertube-core-utils' +import { HttpStatusCode } from '@peertube/peertube-models' import { cleanupTests, ConfigCommand, @@ -12,7 +12,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test contact form', function () { let server: PeerTubeServer diff --git a/server/tests/api/server/email.ts b/packages/tests/src/api/server/email.ts similarity index 98% rename from server/tests/api/server/email.ts rename to packages/tests/src/api/server/email.ts index 9141cc697..6d3f3f3bb 100644 --- a/server/tests/api/server/email.ts +++ b/packages/tests/src/api/server/email.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { MockSmtpServer } from '@server/tests/shared' -import { HttpStatusCode } from '@shared/models' +import { MockSmtpServer } from '@tests/shared/mock-servers/index.js' +import { HttpStatusCode } from '@peertube/peertube-models' import { cleanupTests, ConfigCommand, @@ -10,7 +10,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test emails', function () { let server: PeerTubeServer diff --git a/server/tests/api/server/follow-constraints.ts b/packages/tests/src/api/server/follow-constraints.ts similarity index 99% rename from server/tests/api/server/follow-constraints.ts rename to packages/tests/src/api/server/follow-constraints.ts index ff5332858..8d277c906 100644 --- a/server/tests/api/server/follow-constraints.ts +++ b/packages/tests/src/api/server/follow-constraints.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { HttpStatusCode, PeerTubeProblemDocument, ServerErrorCode } from '@shared/models' +import { HttpStatusCode, PeerTubeProblemDocument, ServerErrorCode } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -9,7 +9,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test follow constraints', function () { let servers: PeerTubeServer[] = [] diff --git a/server/tests/api/server/follows-moderation.ts b/packages/tests/src/api/server/follows-moderation.ts similarity index 98% rename from server/tests/api/server/follows-moderation.ts rename to packages/tests/src/api/server/follows-moderation.ts index d145dd9d2..811dd5c22 100644 --- a/server/tests/api/server/follows-moderation.ts +++ b/packages/tests/src/api/server/follows-moderation.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { expectStartWith } from '@server/tests/shared' -import { ActorFollow, FollowState } from '@shared/models' +import { expectStartWith } from '@tests/shared/checks.js' +import { ActorFollow, FollowState } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -10,7 +10,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' async function checkServer1And2HasFollowers (servers: PeerTubeServer[], state = 'accepted') { const fns = [ diff --git a/server/tests/api/server/follows.ts b/packages/tests/src/api/server/follows.ts similarity index 98% rename from server/tests/api/server/follows.ts rename to packages/tests/src/api/server/follows.ts index e3e4605ee..fbe2e87da 100644 --- a/server/tests/api/server/follows.ts +++ b/packages/tests/src/api/server/follows.ts @@ -1,9 +1,12 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { completeVideoCheck, dateIsValid, expectAccountFollows, expectChannelsFollows, testCaptionFile } from '@server/tests/shared' -import { Video, VideoPrivacy } from '@shared/models' -import { cleanupTests, createMultipleServers, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' +import { Video, VideoPrivacy } from '@peertube/peertube-models' +import { cleanupTests, createMultipleServers, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@peertube/peertube-server-commands' +import { expectAccountFollows, expectChannelsFollows } from '@tests/shared/actors.js' +import { testCaptionFile } from '@tests/shared/captions.js' +import { dateIsValid } from '@tests/shared/checks.js' +import { completeVideoCheck } from '@tests/shared/videos.js' describe('Test follows', function () { diff --git a/server/tests/api/server/handle-down.ts b/packages/tests/src/api/server/handle-down.ts similarity index 97% rename from server/tests/api/server/handle-down.ts rename to packages/tests/src/api/server/handle-down.ts index 1d524aa93..604df129f 100644 --- a/server/tests/api/server/handle-down.ts +++ b/packages/tests/src/api/server/handle-down.ts @@ -1,9 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { completeVideoCheck, SQLCommand } from '@server/tests/shared' -import { wait } from '@shared/core-utils' -import { HttpStatusCode, JobState, VideoCreateResult, VideoPrivacy } from '@shared/models' +import { wait } from '@peertube/peertube-core-utils' +import { HttpStatusCode, JobState, VideoCreateResult, VideoPrivacy } from '@peertube/peertube-models' import { cleanupTests, CommentsCommand, @@ -12,7 +11,9 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' +import { SQLCommand } from '@tests/shared/sql-command.js' +import { completeVideoCheck } from '@tests/shared/videos.js' describe('Test handle downs', function () { let servers: PeerTubeServer[] = [] diff --git a/server/tests/api/server/homepage.ts b/packages/tests/src/api/server/homepage.ts similarity index 95% rename from server/tests/api/server/homepage.ts rename to packages/tests/src/api/server/homepage.ts index 9c45800f2..082a2fb91 100644 --- a/server/tests/api/server/homepage.ts +++ b/packages/tests/src/api/server/homepage.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -11,7 +11,7 @@ import { setAccessTokensToServers, setDefaultAccountAvatar, setDefaultChannelAvatar -} from '../../../../shared/server-commands/index' +} from '@peertube/peertube-server-commands' async function getHomepageState (server: PeerTubeServer) { const config = await server.config.getConfig() diff --git a/packages/tests/src/api/server/index.ts b/packages/tests/src/api/server/index.ts new file mode 100644 index 000000000..5c80a5a37 --- /dev/null +++ b/packages/tests/src/api/server/index.ts @@ -0,0 +1,22 @@ +import './auto-follows.js' +import './bulk.js' +import './config-defaults.js' +import './config.js' +import './contact-form.js' +import './email.js' +import './follow-constraints.js' +import './follows.js' +import './follows-moderation.js' +import './homepage.js' +import './handle-down.js' +import './jobs.js' +import './logs.js' +import './reverse-proxy.js' +import './services.js' +import './slow-follows.js' +import './stats.js' +import './tracker.js' +import './no-client.js' +import './open-telemetry.js' +import './plugins.js' +import './proxy.js' diff --git a/server/tests/api/server/jobs.ts b/packages/tests/src/api/server/jobs.ts similarity index 95% rename from server/tests/api/server/jobs.ts rename to packages/tests/src/api/server/jobs.ts index d0e6df719..3d60b1431 100644 --- a/server/tests/api/server/jobs.ts +++ b/packages/tests/src/api/server/jobs.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { dateIsValid } from '@server/tests/shared' -import { wait } from '@shared/core-utils' +import { dateIsValid } from '@tests/shared/checks.js' +import { wait } from '@peertube/peertube-core-utils' import { cleanupTests, createMultipleServers, @@ -10,7 +10,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test jobs', function () { let servers: PeerTubeServer[] diff --git a/server/tests/api/server/logs.ts b/packages/tests/src/api/server/logs.ts similarity index 98% rename from server/tests/api/server/logs.ts rename to packages/tests/src/api/server/logs.ts index 9cf04c501..11c86d694 100644 --- a/server/tests/api/server/logs.ts +++ b/packages/tests/src/api/server/logs.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -10,7 +10,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test logs', function () { let server: PeerTubeServer diff --git a/server/tests/api/server/no-client.ts b/packages/tests/src/api/server/no-client.ts similarity index 85% rename from server/tests/api/server/no-client.ts rename to packages/tests/src/api/server/no-client.ts index 193f6c987..0f097d50b 100644 --- a/server/tests/api/server/no-client.ts +++ b/packages/tests/src/api/server/no-client.ts @@ -1,6 +1,6 @@ import request from 'supertest' -import { HttpStatusCode } from '@shared/models' -import { cleanupTests, createSingleServer, PeerTubeServer } from '@shared/server-commands' +import { HttpStatusCode } from '@peertube/peertube-models' +import { cleanupTests, createSingleServer, PeerTubeServer } from '@peertube/peertube-server-commands' describe('Start and stop server without web client routes', function () { let server: PeerTubeServer diff --git a/server/tests/api/server/open-telemetry.ts b/packages/tests/src/api/server/open-telemetry.ts similarity index 93% rename from server/tests/api/server/open-telemetry.ts rename to packages/tests/src/api/server/open-telemetry.ts index 508e9d649..8ed3801db 100644 --- a/server/tests/api/server/open-telemetry.ts +++ b/packages/tests/src/api/server/open-telemetry.ts @@ -1,9 +1,16 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { expectLogContain, expectLogDoesNotContain, MockHTTP } from '@server/tests/shared' -import { HttpStatusCode, PlaybackMetricCreate, VideoPrivacy, VideoResolution } from '@shared/models' -import { cleanupTests, createSingleServer, makeRawRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' +import { HttpStatusCode, PlaybackMetricCreate, VideoPrivacy, VideoResolution } from '@peertube/peertube-models' +import { + cleanupTests, + createSingleServer, + makeRawRequest, + PeerTubeServer, + setAccessTokensToServers +} from '@peertube/peertube-server-commands' +import { expectLogDoesNotContain, expectLogContain } from '@tests/shared/checks.js' +import { MockHTTP } from '@tests/shared/mock-servers/mock-http.js' describe('Open Telemetry', function () { let server: PeerTubeServer diff --git a/server/tests/api/server/plugins.ts b/packages/tests/src/api/server/plugins.ts similarity index 97% rename from server/tests/api/server/plugins.ts rename to packages/tests/src/api/server/plugins.ts index a0e9db1d3..a78cea025 100644 --- a/server/tests/api/server/plugins.ts +++ b/packages/tests/src/api/server/plugins.ts @@ -1,11 +1,10 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { pathExists, remove } from 'fs-extra' +import { pathExists, remove } from 'fs-extra/esm' import { join } from 'path' -import { SQLCommand, testHelloWorldRegisteredSettings } from '@server/tests/shared' -import { wait } from '@shared/core-utils' -import { HttpStatusCode, PluginType } from '@shared/models' +import { wait } from '@peertube/peertube-core-utils' +import { HttpStatusCode, PluginType } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -14,7 +13,9 @@ import { PeerTubeServer, PluginsCommand, setAccessTokensToServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' +import { SQLCommand } from '@tests/shared/sql-command.js' +import { testHelloWorldRegisteredSettings } from '@tests/shared/plugins.js' describe('Test plugins', function () { let server: PeerTubeServer diff --git a/server/tests/api/server/proxy.ts b/packages/tests/src/api/server/proxy.ts similarity index 89% rename from server/tests/api/server/proxy.ts rename to packages/tests/src/api/server/proxy.ts index 9337468d5..c7d13f4ab 100644 --- a/server/tests/api/server/proxy.ts +++ b/packages/tests/src/api/server/proxy.ts @@ -1,9 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { expectNotStartWith, expectStartWith, FIXTURE_URLS, MockProxy } from '@server/tests/shared' -import { areMockObjectStorageTestsDisabled } from '@shared/core-utils' -import { HttpStatusCode, VideoPrivacy } from '@shared/models' +import { HttpStatusCode, HttpStatusCodeType, VideoPrivacy } from '@peertube/peertube-models' +import { areMockObjectStorageTestsDisabled } from '@peertube/peertube-node-utils' import { cleanupTests, createMultipleServers, @@ -13,7 +12,10 @@ import { setAccessTokensToServers, setDefaultVideoChannel, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' +import { FIXTURE_URLS } from '@tests/shared/tests.js' +import { expectStartWith, expectNotStartWith } from '@tests/shared/checks.js' +import { MockProxy } from '@tests/shared/mock-servers/mock-proxy.js' describe('Test proxy', function () { let servers: PeerTubeServer[] = [] @@ -82,7 +84,7 @@ describe('Test proxy', function () { describe('Videos import', async function () { - function quickImport (expectedStatus: HttpStatusCode = HttpStatusCode.OK_200) { + function quickImport (expectedStatus: HttpStatusCodeType = HttpStatusCode.OK_200) { return servers[0].imports.importVideo({ attributes: { name: 'video import', diff --git a/server/tests/api/server/reverse-proxy.ts b/packages/tests/src/api/server/reverse-proxy.ts similarity index 96% rename from server/tests/api/server/reverse-proxy.ts rename to packages/tests/src/api/server/reverse-proxy.ts index 11c96c4b5..7e334cc3e 100644 --- a/server/tests/api/server/reverse-proxy.ts +++ b/packages/tests/src/api/server/reverse-proxy.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { wait } from '@shared/core-utils' -import { HttpStatusCode } from '@shared/models' -import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' +import { wait } from '@peertube/peertube-core-utils' +import { HttpStatusCode } from '@peertube/peertube-models' +import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@peertube/peertube-server-commands' describe('Test application behind a reverse proxy', function () { let server: PeerTubeServer diff --git a/server/tests/api/server/services.ts b/packages/tests/src/api/server/services.ts similarity index 95% rename from server/tests/api/server/services.ts rename to packages/tests/src/api/server/services.ts index a10e9baed..349d29a58 100644 --- a/server/tests/api/server/services.ts +++ b/packages/tests/src/api/server/services.ts @@ -1,8 +1,14 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel } from '@shared/server-commands' -import { Video, VideoPlaylistPrivacy } from '@shared/models' +import { Video, VideoPlaylistPrivacy } from '@peertube/peertube-models' +import { + cleanupTests, + createSingleServer, + PeerTubeServer, + setAccessTokensToServers, + setDefaultVideoChannel +} from '@peertube/peertube-server-commands' describe('Test services', function () { let server: PeerTubeServer = null diff --git a/server/tests/api/server/slow-follows.ts b/packages/tests/src/api/server/slow-follows.ts similarity index 96% rename from server/tests/api/server/slow-follows.ts rename to packages/tests/src/api/server/slow-follows.ts index a967fa724..d03109001 100644 --- a/server/tests/api/server/slow-follows.ts +++ b/packages/tests/src/api/server/slow-follows.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { Job } from '@shared/models' +import { Job } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -9,7 +9,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test slow follows', function () { let servers: PeerTubeServer[] = [] diff --git a/server/tests/api/server/stats.ts b/packages/tests/src/api/server/stats.ts similarity index 97% rename from server/tests/api/server/stats.ts rename to packages/tests/src/api/server/stats.ts index a1bf189fa..32ab323ce 100644 --- a/server/tests/api/server/stats.ts +++ b/packages/tests/src/api/server/stats.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { wait } from '@shared/core-utils' -import { ActivityType, VideoPlaylistPrivacy } from '@shared/models' +import { wait } from '@peertube/peertube-core-utils' +import { ActivityType, VideoPlaylistPrivacy } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -12,7 +12,7 @@ import { setDefaultAccountAvatar, setDefaultChannelAvatar, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test stats (excluding redundancy)', function () { let servers: PeerTubeServer[] = [] diff --git a/server/tests/api/server/tracker.ts b/packages/tests/src/api/server/tracker.ts similarity index 95% rename from server/tests/api/server/tracker.ts rename to packages/tests/src/api/server/tracker.ts index a0ce2ca35..4df4e4613 100644 --- a/server/tests/api/server/tracker.ts +++ b/packages/tests/src/api/server/tracker.ts @@ -2,7 +2,13 @@ import { decode as magnetUriDecode, encode as magnetUriEncode } from 'magnet-uri' import WebTorrent from 'webtorrent' -import { cleanupTests, createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' +import { + cleanupTests, + createSingleServer, + killallServers, + PeerTubeServer, + setAccessTokensToServers +} from '@peertube/peertube-server-commands' describe('Test tracker', function () { let server: PeerTubeServer diff --git a/server/tests/api/transcoding/audio-only.ts b/packages/tests/src/api/transcoding/audio-only.ts similarity index 95% rename from server/tests/api/transcoding/audio-only.ts rename to packages/tests/src/api/transcoding/audio-only.ts index f4cc012ef..6d0410348 100644 --- a/server/tests/api/transcoding/audio-only.ts +++ b/packages/tests/src/api/transcoding/audio-only.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { getAudioStream, getVideoStreamDimensionsInfo } from '@shared/ffmpeg' +import { getAudioStream, getVideoStreamDimensionsInfo } from '@peertube/peertube-ffmpeg' import { cleanupTests, createMultipleServers, @@ -9,7 +9,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test audio only video transcoding', function () { let servers: PeerTubeServer[] = [] diff --git a/server/tests/api/transcoding/create-transcoding.ts b/packages/tests/src/api/transcoding/create-transcoding.ts similarity index 95% rename from server/tests/api/transcoding/create-transcoding.ts rename to packages/tests/src/api/transcoding/create-transcoding.ts index 9a891043c..b0a9c7556 100644 --- a/server/tests/api/transcoding/create-transcoding.ts +++ b/packages/tests/src/api/transcoding/create-transcoding.ts @@ -1,9 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { checkResolutionsInMasterPlaylist, expectStartWith } from '@server/tests/shared' -import { areMockObjectStorageTestsDisabled } from '@shared/core-utils' -import { HttpStatusCode, VideoDetails } from '@shared/models' +import { areMockObjectStorageTestsDisabled } from '@peertube/peertube-node-utils' +import { HttpStatusCode, VideoDetails } from '@peertube/peertube-models' import { cleanupTests, ConfigCommand, @@ -15,7 +14,9 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' +import { expectStartWith } from '@tests/shared/checks.js' +import { checkResolutionsInMasterPlaylist } from '@tests/shared/streaming-playlists.js' async function checkFilesInObjectStorage (objectStorage: ObjectStorageCommand, video: VideoDetails) { for (const file of video.files) { diff --git a/server/tests/api/transcoding/hls.ts b/packages/tests/src/api/transcoding/hls.ts similarity index 91% rename from server/tests/api/transcoding/hls.ts rename to packages/tests/src/api/transcoding/hls.ts index d67043c2a..884f98e87 100644 --- a/server/tests/api/transcoding/hls.ts +++ b/packages/tests/src/api/transcoding/hls.ts @@ -1,9 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { join } from 'path' -import { checkDirectoryIsEmpty, checkTmpIsEmpty, completeCheckHlsPlaylist } from '@server/tests/shared' -import { areMockObjectStorageTestsDisabled } from '@shared/core-utils' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode } from '@peertube/peertube-models' +import { areMockObjectStorageTestsDisabled } from '@peertube/peertube-node-utils' import { cleanupTests, createMultipleServers, @@ -12,8 +11,10 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' -import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants' +} from '@peertube/peertube-server-commands' +import { DEFAULT_AUDIO_RESOLUTION } from '@peertube/peertube-server/server/initializers/constants.js' +import { checkDirectoryIsEmpty, checkTmpIsEmpty } from '@tests/shared/directories.js' +import { completeCheckHlsPlaylist } from '@tests/shared/streaming-playlists.js' describe('Test HLS videos', function () { let servers: PeerTubeServer[] = [] diff --git a/packages/tests/src/api/transcoding/index.ts b/packages/tests/src/api/transcoding/index.ts new file mode 100644 index 000000000..c25cd51c3 --- /dev/null +++ b/packages/tests/src/api/transcoding/index.ts @@ -0,0 +1,6 @@ +export * from './audio-only.js' +export * from './create-transcoding.js' +export * from './hls.js' +export * from './transcoder.js' +export * from './update-while-transcoding.js' +export * from './video-studio.js' diff --git a/server/tests/api/transcoding/transcoder.ts b/packages/tests/src/api/transcoding/transcoder.ts similarity index 97% rename from server/tests/api/transcoding/transcoder.ts rename to packages/tests/src/api/transcoding/transcoder.ts index 5386d236f..8900491f5 100644 --- a/server/tests/api/transcoding/transcoder.ts +++ b/packages/tests/src/api/transcoding/transcoder.ts @@ -1,9 +1,10 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { canDoQuickTranscode } from '@server/lib/transcoding/transcoding-quick-transcode' -import { checkWebTorrentWorks, generateHighBitrateVideo, generateVideoWithFramerate } from '@server/tests/shared' -import { buildAbsoluteFixturePath, getAllFiles, getMaxTheoreticalBitrate, getMinTheoreticalBitrate, omit } from '@shared/core-utils' +import { getAllFiles, getMaxTheoreticalBitrate, getMinTheoreticalBitrate, omit } from '@peertube/peertube-core-utils' +import { HttpStatusCode, VideoFileMetadata, VideoState } from '@peertube/peertube-models' +import { canDoQuickTranscode } from '@peertube/peertube-server/server/lib/transcoding/transcoding-quick-transcode.js' +import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils' import { ffprobePromise, getAudioStream, @@ -11,8 +12,7 @@ import { getVideoStreamDimensionsInfo, getVideoStreamFPS, hasAudioStream -} from '@shared/ffmpeg' -import { HttpStatusCode, VideoFileMetadata, VideoState } from '@shared/models' +} from '@peertube/peertube-ffmpeg' import { cleanupTests, createMultipleServers, @@ -21,7 +21,9 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' +import { generateVideoWithFramerate, generateHighBitrateVideo } from '@tests/shared/generate.js' +import { checkWebTorrentWorks } from '@tests/shared/webtorrent.js' function updateConfigForTranscoding (server: PeerTubeServer) { return server.config.updateCustomSubConfig({ diff --git a/server/tests/api/transcoding/update-while-transcoding.ts b/packages/tests/src/api/transcoding/update-while-transcoding.ts similarity index 93% rename from server/tests/api/transcoding/update-while-transcoding.ts rename to packages/tests/src/api/transcoding/update-while-transcoding.ts index cfb4fa0cc..9990bc745 100644 --- a/server/tests/api/transcoding/update-while-transcoding.ts +++ b/packages/tests/src/api/transcoding/update-while-transcoding.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { completeCheckHlsPlaylist } from '@server/tests/shared' -import { areMockObjectStorageTestsDisabled, wait } from '@shared/core-utils' -import { VideoPrivacy } from '@shared/models' +import { wait } from '@peertube/peertube-core-utils' +import { VideoPrivacy } from '@peertube/peertube-models' +import { areMockObjectStorageTestsDisabled } from '@peertube/peertube-node-utils' import { cleanupTests, createMultipleServers, @@ -11,7 +11,8 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' +import { completeCheckHlsPlaylist } from '@tests/shared/streaming-playlists.js' describe('Test update video privacy while transcoding', function () { let servers: PeerTubeServer[] = [] diff --git a/server/tests/api/transcoding/video-studio.ts b/packages/tests/src/api/transcoding/video-studio.ts similarity index 95% rename from server/tests/api/transcoding/video-studio.ts rename to packages/tests/src/api/transcoding/video-studio.ts index ba68f8e24..8a3788aa6 100644 --- a/server/tests/api/transcoding/video-studio.ts +++ b/packages/tests/src/api/transcoding/video-studio.ts @@ -1,7 +1,7 @@ import { expect } from 'chai' -import { checkPersistentTmpIsEmpty, checkVideoDuration, expectStartWith } from '@server/tests/shared' -import { areMockObjectStorageTestsDisabled, getAllFiles } from '@shared/core-utils' -import { VideoStudioTask } from '@shared/models' +import { getAllFiles } from '@peertube/peertube-core-utils' +import { VideoStudioTask } from '@peertube/peertube-models' +import { areMockObjectStorageTestsDisabled } from '@peertube/peertube-node-utils' import { cleanupTests, createMultipleServers, @@ -12,7 +12,9 @@ import { setDefaultVideoChannel, VideoStudioCommand, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' +import { checkVideoDuration, expectStartWith } from '@tests/shared/checks.js' +import { checkPersistentTmpIsEmpty } from '@tests/shared/directories.js' describe('Test video studio', function () { let servers: PeerTubeServer[] = [] diff --git a/packages/tests/src/api/users/index.ts b/packages/tests/src/api/users/index.ts new file mode 100644 index 000000000..830d4da62 --- /dev/null +++ b/packages/tests/src/api/users/index.ts @@ -0,0 +1,8 @@ +import './oauth.js' +import './registrations`.js' +import './two-factor.js' +import './user-subscriptions.js' +import './user-videos.js' +import './users.js' +import './users-multiple-servers.js' +import './users-email-verification.js' diff --git a/server/tests/api/users/oauth.ts b/packages/tests/src/api/users/oauth.ts similarity index 95% rename from server/tests/api/users/oauth.ts rename to packages/tests/src/api/users/oauth.ts index 153615875..fe50872cb 100644 --- a/server/tests/api/users/oauth.ts +++ b/packages/tests/src/api/users/oauth.ts @@ -1,10 +1,16 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { SQLCommand } from '@server/tests/shared' -import { wait } from '@shared/core-utils' -import { HttpStatusCode, OAuth2ErrorCode, PeerTubeProblemDocument } from '@shared/models' -import { cleanupTests, createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' +import { wait } from '@peertube/peertube-core-utils' +import { HttpStatusCode, OAuth2ErrorCode, PeerTubeProblemDocument } from '@peertube/peertube-models' +import { SQLCommand } from '@tests/shared/sql-command.js' +import { + cleanupTests, + createSingleServer, + killallServers, + PeerTubeServer, + setAccessTokensToServers +} from '@peertube/peertube-server-commands' describe('Test oauth', function () { let server: PeerTubeServer diff --git a/server/tests/api/users/registrations.ts b/packages/tests/src/api/users/registrations.ts similarity index 98% rename from server/tests/api/users/registrations.ts rename to packages/tests/src/api/users/registrations.ts index e6524f07d..dbe1bc4f5 100644 --- a/server/tests/api/users/registrations.ts +++ b/packages/tests/src/api/users/registrations.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { MockSmtpServer } from '@server/tests/shared' -import { UserRegistrationState, UserRole } from '@shared/models' +import { MockSmtpServer } from '@tests/shared/mock-servers/index.js' +import { UserRegistrationState, UserRole } from '@peertube/peertube-models' import { cleanupTests, ConfigCommand, @@ -10,7 +10,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test registrations', function () { let server: PeerTubeServer diff --git a/server/tests/api/users/two-factor.ts b/packages/tests/src/api/users/two-factor.ts similarity index 95% rename from server/tests/api/users/two-factor.ts rename to packages/tests/src/api/users/two-factor.ts index 0dcab9e17..fda125d20 100644 --- a/server/tests/api/users/two-factor.ts +++ b/packages/tests/src/api/users/two-factor.ts @@ -1,16 +1,22 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { expectStartWith } from '@server/tests/shared' -import { HttpStatusCode } from '@shared/models' -import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, TwoFactorCommand } from '@shared/server-commands' +import { HttpStatusCode, HttpStatusCodeType } from '@peertube/peertube-models' +import { expectStartWith } from '@tests/shared/checks.js' +import { + cleanupTests, + createSingleServer, + PeerTubeServer, + setAccessTokensToServers, + TwoFactorCommand +} from '@peertube/peertube-server-commands' async function login (options: { server: PeerTubeServer username: string password: string otpToken?: string - expectedStatus?: HttpStatusCode + expectedStatus?: HttpStatusCodeType }) { const { server, username, password, otpToken, expectedStatus } = options diff --git a/server/tests/api/users/user-subscriptions.ts b/packages/tests/src/api/users/user-subscriptions.ts similarity index 99% rename from server/tests/api/users/user-subscriptions.ts rename to packages/tests/src/api/users/user-subscriptions.ts index ad2b82a4a..eb4ea9539 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/packages/tests/src/api/users/user-subscriptions.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { VideoPrivacy } from '@shared/models' +import { VideoPrivacy } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -12,7 +12,7 @@ import { setDefaultChannelAvatar, SubscriptionsCommand, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test users subscriptions', function () { let servers: PeerTubeServer[] = [] diff --git a/server/tests/api/users/user-videos.ts b/packages/tests/src/api/users/user-videos.ts similarity index 98% rename from server/tests/api/users/user-videos.ts rename to packages/tests/src/api/users/user-videos.ts index 77226e48e..7b075d040 100644 --- a/server/tests/api/users/user-videos.ts +++ b/packages/tests/src/api/users/user-videos.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -10,7 +10,7 @@ import { setDefaultAccountAvatar, setDefaultChannelAvatar, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test user videos', function () { let server: PeerTubeServer diff --git a/server/tests/api/users/users-email-verification.ts b/packages/tests/src/api/users/users-email-verification.ts similarity index 96% rename from server/tests/api/users/users-email-verification.ts rename to packages/tests/src/api/users/users-email-verification.ts index 909226311..689e3c4bb 100644 --- a/server/tests/api/users/users-email-verification.ts +++ b/packages/tests/src/api/users/users-email-verification.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { MockSmtpServer } from '@server/tests/shared' -import { HttpStatusCode } from '@shared/models' +import { MockSmtpServer } from '@tests/shared/mock-servers/index.js' +import { HttpStatusCode } from '@peertube/peertube-models' import { cleanupTests, ConfigCommand, @@ -10,7 +10,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test users email verification', function () { let server: PeerTubeServer diff --git a/server/tests/api/users/users-multiple-servers.ts b/packages/tests/src/api/users/users-multiple-servers.ts similarity index 94% rename from server/tests/api/users/users-multiple-servers.ts rename to packages/tests/src/api/users/users-multiple-servers.ts index 3823b74ef..61e3aa001 100644 --- a/server/tests/api/users/users-multiple-servers.ts +++ b/packages/tests/src/api/users/users-multiple-servers.ts @@ -1,14 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { - checkActorFilesWereRemoved, - checkTmpIsEmpty, - checkVideoFilesWereRemoved, - saveVideoInServers, - testImage -} from '@server/tests/shared' -import { MyUser } from '@shared/models' +import { MyUser } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -17,7 +10,11 @@ import { setAccessTokensToServers, setDefaultChannelAvatar, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' +import { checkActorFilesWereRemoved } from '@tests/shared/actors.js' +import { testImage } from '@tests/shared/checks.js' +import { checkTmpIsEmpty } from '@tests/shared/directories.js' +import { saveVideoInServers, checkVideoFilesWereRemoved } from '@tests/shared/videos.js' describe('Test users with multiple servers', function () { let servers: PeerTubeServer[] = [] diff --git a/server/tests/api/users/users.ts b/packages/tests/src/api/users/users.ts similarity index 99% rename from server/tests/api/users/users.ts rename to packages/tests/src/api/users/users.ts index 67ade1d0d..a0090a463 100644 --- a/server/tests/api/users/users.ts +++ b/packages/tests/src/api/users/users.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { testImageSize } from '@server/tests/shared' -import { AbuseState, HttpStatusCode, UserAdminFlag, UserRole, VideoPlaylistType } from '@shared/models' -import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' +import { testImageSize } from '@tests/shared/checks.js' +import { AbuseState, HttpStatusCode, UserAdminFlag, UserRole, VideoPlaylistType } from '@peertube/peertube-models' +import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@peertube/peertube-server-commands' describe('Test users', function () { let server: PeerTubeServer diff --git a/server/tests/api/videos/channel-import-videos.ts b/packages/tests/src/api/videos/channel-import-videos.ts similarity index 96% rename from server/tests/api/videos/channel-import-videos.ts rename to packages/tests/src/api/videos/channel-import-videos.ts index a66f88a0e..d0e47fe95 100644 --- a/server/tests/api/videos/channel-import-videos.ts +++ b/packages/tests/src/api/videos/channel-import-videos.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { FIXTURE_URLS } from '@server/tests/shared' -import { areHttpImportTestsDisabled } from '@shared/core-utils' +import { FIXTURE_URLS } from '@tests/shared/tests.js' +import { areHttpImportTestsDisabled } from '@peertube/peertube-node-utils' import { createSingleServer, getServerImportConfig, @@ -10,7 +10,7 @@ import { setAccessTokensToServers, setDefaultVideoChannel, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test videos import in a channel', function () { if (areHttpImportTestsDisabled()) return diff --git a/packages/tests/src/api/videos/index.ts b/packages/tests/src/api/videos/index.ts new file mode 100644 index 000000000..fcb1d5a81 --- /dev/null +++ b/packages/tests/src/api/videos/index.ts @@ -0,0 +1,23 @@ +import './multiple-servers.js' +import './resumable-upload.js' +import './single-server.js' +import './video-captions.js' +import './video-change-ownership.js' +import './video-channels.js' +import './channel-import-videos.js' +import './video-channel-syncs.js' +import './video-comments.js' +import './video-description.js' +import './video-files.js' +import './video-imports.js' +import './video-nsfw.js' +import './video-playlists.js' +import './video-playlist-thumbnails.js' +import './video-source.js' +import './video-privacy.js' +import './video-schedule-update.js' +import './videos-common-filters.js' +import './videos-history.js' +import './videos-overview.js' +import './video-static-file-privacy.js' +import './video-storyboard.js' diff --git a/server/tests/api/videos/multiple-servers.ts b/packages/tests/src/api/videos/multiple-servers.ts similarity index 98% rename from server/tests/api/videos/multiple-servers.ts rename to packages/tests/src/api/videos/multiple-servers.ts index e9aa0e3a1..03afd7cbb 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/packages/tests/src/api/videos/multiple-servers.ts @@ -2,17 +2,9 @@ import { expect } from 'chai' import request from 'supertest' -import { - checkTmpIsEmpty, - checkVideoFilesWereRemoved, - checkWebTorrentWorks, - completeVideoCheck, - dateIsValid, - saveVideoInServers, - testImageGeneratedByFFmpeg -} from '@server/tests/shared' -import { buildAbsoluteFixturePath, wait } from '@shared/core-utils' -import { HttpStatusCode, VideoCommentThreadTree, VideoPrivacy } from '@shared/models' +import { wait } from '@peertube/peertube-core-utils' +import { HttpStatusCode, VideoCommentThreadTree, VideoPrivacy } from '@peertube/peertube-models' +import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils' import { cleanupTests, createMultipleServers, @@ -23,7 +15,11 @@ import { setDefaultAccountAvatar, setDefaultChannelAvatar, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' +import { testImageGeneratedByFFmpeg, dateIsValid } from '@tests/shared/checks.js' +import { checkTmpIsEmpty } from '@tests/shared/directories.js' +import { completeVideoCheck, saveVideoInServers, checkVideoFilesWereRemoved } from '@tests/shared/videos.js' +import { checkWebTorrentWorks } from '@tests/shared/webtorrent.js' describe('Test multiple servers', function () { let servers: PeerTubeServer[] = [] diff --git a/server/tests/api/videos/resumable-upload.ts b/packages/tests/src/api/videos/resumable-upload.ts similarity index 95% rename from server/tests/api/videos/resumable-upload.ts rename to packages/tests/src/api/videos/resumable-upload.ts index cac1201e9..628e0298c 100644 --- a/server/tests/api/videos/resumable-upload.ts +++ b/packages/tests/src/api/videos/resumable-upload.ts @@ -1,12 +1,18 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { pathExists, readdir, stat } from 'fs-extra' +import { pathExists } from 'fs-extra/esm' +import { readdir, stat } from 'fs/promises' import { join } from 'path' -import { buildAbsoluteFixturePath } from '@shared/core-utils' -import { sha1 } from '@shared/extra-utils' -import { HttpStatusCode, VideoPrivacy } from '@shared/models' -import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel } from '@shared/server-commands' +import { HttpStatusCode, HttpStatusCodeType, VideoPrivacy } from '@peertube/peertube-models' +import { buildAbsoluteFixturePath, sha1 } from '@peertube/peertube-node-utils' +import { + cleanupTests, + createSingleServer, + PeerTubeServer, + setAccessTokensToServers, + setDefaultVideoChannel +} from '@peertube/peertube-server-commands' // Most classic resumable upload tests are done in other test suites @@ -54,7 +60,7 @@ describe('Test resumable upload', function () { token?: string pathUploadId: string size?: number - expectedStatus?: HttpStatusCode + expectedStatus?: HttpStatusCodeType contentLength?: number contentRange?: string contentRangeBuilder?: (start: number, chunk: any) => string diff --git a/server/tests/api/videos/single-server.ts b/packages/tests/src/api/videos/single-server.ts similarity index 97% rename from server/tests/api/videos/single-server.ts rename to packages/tests/src/api/videos/single-server.ts index 66414aa5b..b87192a57 100644 --- a/server/tests/api/videos/single-server.ts +++ b/packages/tests/src/api/videos/single-server.ts @@ -1,9 +1,10 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { checkVideoFilesWereRemoved, completeVideoCheck, testImageGeneratedByFFmpeg } from '@server/tests/shared' -import { wait } from '@shared/core-utils' -import { Video, VideoPrivacy } from '@shared/models' +import { wait } from '@peertube/peertube-core-utils' +import { Video, VideoPrivacy } from '@peertube/peertube-models' +import { checkVideoFilesWereRemoved, completeVideoCheck } from '@tests/shared/videos.js' +import { testImageGeneratedByFFmpeg } from '@tests/shared/checks.js' import { cleanupTests, createSingleServer, @@ -12,7 +13,7 @@ import { setDefaultAccountAvatar, setDefaultChannelAvatar, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test a single server', function () { @@ -92,7 +93,7 @@ describe('Test a single server', function () { before(async function () { this.timeout(30000) - server = await createSingleServer(1) + server = await createSingleServer(1, {}) await setAccessTokensToServers([ server ]) await setDefaultChannelAvatar(server) diff --git a/server/tests/api/videos/video-captions.ts b/packages/tests/src/api/videos/video-captions.ts similarity index 96% rename from server/tests/api/videos/video-captions.ts rename to packages/tests/src/api/videos/video-captions.ts index 0630c9d3a..027022549 100644 --- a/server/tests/api/videos/video-captions.ts +++ b/packages/tests/src/api/videos/video-captions.ts @@ -1,8 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { checkVideoFilesWereRemoved, testCaptionFile } from '@server/tests/shared' -import { wait } from '@shared/core-utils' +import { wait } from '@peertube/peertube-core-utils' import { cleanupTests, createMultipleServers, @@ -10,7 +9,9 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' +import { testCaptionFile } from '@tests/shared/captions.js' +import { checkVideoFilesWereRemoved } from '@tests/shared/videos.js' describe('Test video captions', function () { const uuidRegex = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}' diff --git a/server/tests/api/videos/video-change-ownership.ts b/packages/tests/src/api/videos/video-change-ownership.ts similarity index 98% rename from server/tests/api/videos/video-change-ownership.ts rename to packages/tests/src/api/videos/video-change-ownership.ts index 99d774c2b..717c37469 100644 --- a/server/tests/api/videos/video-change-ownership.ts +++ b/packages/tests/src/api/videos/video-change-ownership.ts @@ -11,8 +11,8 @@ import { setAccessTokensToServers, setDefaultVideoChannel, waitJobs -} from '@shared/server-commands' -import { HttpStatusCode, VideoPrivacy } from '@shared/models' +} from '@peertube/peertube-server-commands' +import { HttpStatusCode, VideoPrivacy } from '@peertube/peertube-models' describe('Test video change ownership - nominal', function () { let servers: PeerTubeServer[] = [] @@ -33,7 +33,7 @@ describe('Test video change ownership - nominal', function () { let command: ChangeOwnershipCommand before(async function () { - this.timeout(50000) + this.timeout(240000) servers = await createMultipleServers(2) await setAccessTokensToServers(servers) diff --git a/server/tests/api/videos/video-channel-syncs.ts b/packages/tests/src/api/videos/video-channel-syncs.ts similarity index 97% rename from server/tests/api/videos/video-channel-syncs.ts rename to packages/tests/src/api/videos/video-channel-syncs.ts index 7f688c7d6..54212bcb5 100644 --- a/server/tests/api/videos/video-channel-syncs.ts +++ b/packages/tests/src/api/videos/video-channel-syncs.ts @@ -1,9 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { FIXTURE_URLS, SQLCommand } from '@server/tests/shared' -import { areHttpImportTestsDisabled } from '@shared/core-utils' -import { VideoChannelSyncState, VideoInclude, VideoPrivacy } from '@shared/models' +import { areHttpImportTestsDisabled } from '@peertube/peertube-node-utils' +import { VideoChannelSyncState, VideoInclude, VideoPrivacy } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -14,7 +13,9 @@ import { setDefaultChannelAvatar, setDefaultVideoChannel, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' +import { SQLCommand } from '@tests/shared/sql-command.js' +import { FIXTURE_URLS } from '@tests/shared/tests.js' describe('Test channel synchronizations', function () { if (areHttpImportTestsDisabled()) return diff --git a/server/tests/api/videos/video-channels.ts b/packages/tests/src/api/videos/video-channels.ts similarity index 97% rename from server/tests/api/videos/video-channels.ts rename to packages/tests/src/api/videos/video-channels.ts index f7cf84618..64b1b9315 100644 --- a/server/tests/api/videos/video-channels.ts +++ b/packages/tests/src/api/videos/video-channels.ts @@ -2,10 +2,11 @@ import { expect } from 'chai' import { basename } from 'path' -import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants' -import { SQLCommand, testFileExistsOrNot, testImage } from '@server/tests/shared' -import { wait } from '@shared/core-utils' -import { ActorImageType, User, VideoChannel } from '@shared/models' +import { ACTOR_IMAGES_SIZE } from '@peertube/peertube-server/server/initializers/constants.js' +import { testFileExistsOrNot, testImage } from '@tests/shared/checks.js' +import { SQLCommand } from '@tests/shared/sql-command.js' +import { wait } from '@peertube/peertube-core-utils' +import { ActorImageType, User, VideoChannel } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -15,7 +16,7 @@ import { setDefaultAccountAvatar, setDefaultVideoChannel, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' async function findChannel (server: PeerTubeServer, channelId: number) { const body = await server.channels.list({ sort: '-name' }) diff --git a/server/tests/api/videos/video-comments.ts b/packages/tests/src/api/videos/video-comments.ts similarity index 99% rename from server/tests/api/videos/video-comments.ts rename to packages/tests/src/api/videos/video-comments.ts index b7d5624a6..f17db9979 100644 --- a/server/tests/api/videos/video-comments.ts +++ b/packages/tests/src/api/videos/video-comments.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { dateIsValid, testImage } from '@server/tests/shared' +import { dateIsValid, testImage } from '@tests/shared/checks.js' import { cleanupTests, CommentsCommand, @@ -10,7 +10,7 @@ import { setAccessTokensToServers, setDefaultAccountAvatar, setDefaultChannelAvatar -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test video comments', function () { let server: PeerTubeServer diff --git a/server/tests/api/videos/video-description.ts b/packages/tests/src/api/videos/video-description.ts similarity index 98% rename from server/tests/api/videos/video-description.ts rename to packages/tests/src/api/videos/video-description.ts index 1f3d4adbb..eb41cd71c 100644 --- a/server/tests/api/videos/video-description.ts +++ b/packages/tests/src/api/videos/video-description.ts @@ -8,7 +8,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test video description', function () { let servers: PeerTubeServer[] = [] diff --git a/server/tests/api/videos/video-files.ts b/packages/tests/src/api/videos/video-files.ts similarity index 98% rename from server/tests/api/videos/video-files.ts rename to packages/tests/src/api/videos/video-files.ts index 4f75cd106..1d7c218a4 100644 --- a/server/tests/api/videos/video-files.ts +++ b/packages/tests/src/api/videos/video-files.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -10,7 +10,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test videos files', function () { let servers: PeerTubeServer[] diff --git a/server/tests/api/videos/video-imports.ts b/packages/tests/src/api/videos/video-imports.ts similarity index 97% rename from server/tests/api/videos/video-imports.ts rename to packages/tests/src/api/videos/video-imports.ts index b78b4f344..09efe9931 100644 --- a/server/tests/api/videos/video-imports.ts +++ b/packages/tests/src/api/videos/video-imports.ts @@ -1,11 +1,11 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { pathExists, readdir, remove } from 'fs-extra' +import { pathExists, remove } from 'fs-extra/esm' +import { readdir } from 'fs/promises' import { join } from 'path' -import { FIXTURE_URLS, testCaptionFile, testImageGeneratedByFFmpeg } from '@server/tests/shared' -import { areHttpImportTestsDisabled } from '@shared/core-utils' -import { CustomConfig, HttpStatusCode, Video, VideoImportState, VideoPrivacy, VideoResolution, VideoState } from '@shared/models' +import { areHttpImportTestsDisabled } from '@peertube/peertube-node-utils' +import { CustomConfig, HttpStatusCode, Video, VideoImportState, VideoPrivacy, VideoResolution, VideoState } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -16,8 +16,11 @@ import { setAccessTokensToServers, setDefaultVideoChannel, waitJobs -} from '@shared/server-commands' -import { DeepPartial } from '@shared/typescript-utils' +} from '@peertube/peertube-server-commands' +import { DeepPartial } from '@peertube/peertube-typescript-utils' +import { testCaptionFile } from '@tests/shared/captions.js' +import { testImageGeneratedByFFmpeg } from '@tests/shared/checks.js' +import { FIXTURE_URLS } from '@tests/shared/tests.js' async function checkVideosServer1 (server: PeerTubeServer, idHttp: string, idMagnet: string, idTorrent: string) { const videoHttp = await server.videos.get({ id: idHttp }) diff --git a/server/tests/api/videos/video-nsfw.ts b/packages/tests/src/api/videos/video-nsfw.ts similarity index 98% rename from server/tests/api/videos/video-nsfw.ts rename to packages/tests/src/api/videos/video-nsfw.ts index 65e9c8730..fc5225dd2 100644 --- a/server/tests/api/videos/video-nsfw.ts +++ b/packages/tests/src/api/videos/video-nsfw.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' -import { BooleanBothQuery, CustomConfig, ResultList, Video, VideosOverview } from '@shared/models' +import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@peertube/peertube-server-commands' +import { BooleanBothQuery, CustomConfig, ResultList, Video, VideosOverview } from '@peertube/peertube-models' function createOverviewRes (overview: VideosOverview) { const videos = overview.categories[0].videos diff --git a/server/tests/api/videos/video-passwords.ts b/packages/tests/src/api/videos/video-passwords.ts similarity index 96% rename from server/tests/api/videos/video-passwords.ts rename to packages/tests/src/api/videos/video-passwords.ts index e01a93a4d..60e0e28bd 100644 --- a/server/tests/api/videos/video-passwords.ts +++ b/packages/tests/src/api/videos/video-passwords.ts @@ -9,8 +9,8 @@ import { setAccessTokensToServers, setDefaultAccountAvatar, setDefaultChannelAvatar -} from '@shared/server-commands' -import { VideoPrivacy } from '@shared/models' +} from '@peertube/peertube-server-commands' +import { VideoPrivacy } from '@peertube/peertube-models' describe('Test video passwords', function () { let server: PeerTubeServer diff --git a/server/tests/api/videos/video-playlist-thumbnails.ts b/packages/tests/src/api/videos/video-playlist-thumbnails.ts similarity index 97% rename from server/tests/api/videos/video-playlist-thumbnails.ts rename to packages/tests/src/api/videos/video-playlist-thumbnails.ts index c274c20bf..d79c92f72 100644 --- a/server/tests/api/videos/video-playlist-thumbnails.ts +++ b/packages/tests/src/api/videos/video-playlist-thumbnails.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { testImageGeneratedByFFmpeg } from '@server/tests/shared' -import { VideoPlaylistPrivacy } from '@shared/models' +import { testImageGeneratedByFFmpeg } from '@tests/shared/checks.js' +import { VideoPlaylistPrivacy } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -11,7 +11,7 @@ import { setAccessTokensToServers, setDefaultVideoChannel, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Playlist thumbnail', function () { let servers: PeerTubeServer[] = [] diff --git a/server/tests/api/videos/video-playlists.ts b/packages/tests/src/api/videos/video-playlists.ts similarity index 99% rename from server/tests/api/videos/video-playlists.ts rename to packages/tests/src/api/videos/video-playlists.ts index 3bfa874cb..578d01093 100644 --- a/server/tests/api/videos/video-playlists.ts +++ b/packages/tests/src/api/videos/video-playlists.ts @@ -1,18 +1,18 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { checkPlaylistFilesWereRemoved, testImageGeneratedByFFmpeg } from '@server/tests/shared' -import { wait } from '@shared/core-utils' -import { uuidToShort } from '@shared/extra-utils' +import { wait } from '@peertube/peertube-core-utils' import { HttpStatusCode, VideoPlaylist, VideoPlaylistCreateResult, VideoPlaylistElementType, + VideoPlaylistElementType_Type, VideoPlaylistPrivacy, VideoPlaylistType, VideoPrivacy -} from '@shared/models' +} from '@peertube/peertube-models' +import { uuidToShort } from '@peertube/peertube-node-utils' import { cleanupTests, createMultipleServers, @@ -23,12 +23,14 @@ import { setDefaultAccountAvatar, setDefaultVideoChannel, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' +import { testImageGeneratedByFFmpeg } from '@tests/shared/checks.js' +import { checkPlaylistFilesWereRemoved } from '@tests/shared/video-playlists.js' async function checkPlaylistElementType ( servers: PeerTubeServer[], playlistId: string, - type: VideoPlaylistElementType, + type: VideoPlaylistElementType_Type, position: number, name: string, total: number diff --git a/server/tests/api/videos/video-privacy.ts b/packages/tests/src/api/videos/video-privacy.ts similarity index 97% rename from server/tests/api/videos/video-privacy.ts rename to packages/tests/src/api/videos/video-privacy.ts index de96bcfcc..9171463a4 100644 --- a/server/tests/api/videos/video-privacy.ts +++ b/packages/tests/src/api/videos/video-privacy.ts @@ -1,9 +1,16 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { wait } from '@shared/core-utils' -import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models' -import { cleanupTests, createSingleServer, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' +import { wait } from '@peertube/peertube-core-utils' +import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@peertube/peertube-models' +import { + cleanupTests, + createSingleServer, + doubleFollow, + PeerTubeServer, + setAccessTokensToServers, + waitJobs +} from '@peertube/peertube-server-commands' describe('Test video privacy', function () { const servers: PeerTubeServer[] = [] diff --git a/server/tests/api/videos/video-schedule-update.ts b/packages/tests/src/api/videos/video-schedule-update.ts similarity index 94% rename from server/tests/api/videos/video-schedule-update.ts rename to packages/tests/src/api/videos/video-schedule-update.ts index bf341c648..96d71933e 100644 --- a/server/tests/api/videos/video-schedule-update.ts +++ b/packages/tests/src/api/videos/video-schedule-update.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { wait } from '@shared/core-utils' -import { VideoPrivacy } from '@shared/models' +import { wait } from '@peertube/peertube-core-utils' +import { VideoPrivacy } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -10,7 +10,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' function in10Seconds () { const now = new Date() @@ -40,7 +40,7 @@ describe('Test video update scheduler', function () { privacy: VideoPrivacy.PRIVATE, scheduleUpdate: { updateAt: in10Seconds().toISOString(), - privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC + privacy: VideoPrivacy.PUBLIC } } @@ -103,7 +103,7 @@ describe('Test video update scheduler', function () { name: 'video 2 updated', scheduleUpdate: { updateAt: in10Seconds().toISOString(), - privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC + privacy: VideoPrivacy.PUBLIC } } diff --git a/server/tests/api/videos/video-source.ts b/packages/tests/src/api/videos/video-source.ts similarity index 98% rename from server/tests/api/videos/video-source.ts rename to packages/tests/src/api/videos/video-source.ts index 1f394f904..efe8c3802 100644 --- a/server/tests/api/videos/video-source.ts +++ b/packages/tests/src/api/videos/video-source.ts @@ -1,8 +1,9 @@ -import { expect } from 'chai' -import { expectStartWith } from '@server/tests/shared' /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { areMockObjectStorageTestsDisabled, getAllFiles } from '@shared/core-utils' -import { HttpStatusCode } from '@shared/models' +import { expect } from 'chai' +import { getAllFiles } from '@peertube/peertube-core-utils' +import { HttpStatusCode } from '@peertube/peertube-models' +import { expectStartWith } from '@tests/shared/checks.js' +import { areMockObjectStorageTestsDisabled } from '@peertube/peertube-node-utils' import { cleanupTests, createMultipleServers, @@ -15,7 +16,7 @@ import { setDefaultAccountAvatar, setDefaultVideoChannel, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test a video file replacement', function () { let servers: PeerTubeServer[] = [] diff --git a/server/tests/api/videos/video-static-file-privacy.ts b/packages/tests/src/api/videos/video-static-file-privacy.ts similarity index 97% rename from server/tests/api/videos/video-static-file-privacy.ts rename to packages/tests/src/api/videos/video-static-file-privacy.ts index 0a9864134..7c8d14815 100644 --- a/server/tests/api/videos/video-static-file-privacy.ts +++ b/packages/tests/src/api/videos/video-static-file-privacy.ts @@ -2,9 +2,8 @@ import { expect } from 'chai' import { decode } from 'magnet-uri' -import { checkVideoFileTokenReinjection, expectStartWith, parseTorrentVideo } from '@server/tests/shared' -import { getAllFiles, wait } from '@shared/core-utils' -import { HttpStatusCode, LiveVideo, VideoDetails, VideoPrivacy } from '@shared/models' +import { getAllFiles, wait } from '@peertube/peertube-core-utils' +import { HttpStatusCode, HttpStatusCodeType, LiveVideo, VideoDetails, VideoPrivacy } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -16,7 +15,10 @@ import { setDefaultVideoChannel, stopFfmpeg, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' +import { expectStartWith } from '@tests/shared/checks.js' +import { checkVideoFileTokenReinjection } from '@tests/shared/streaming-playlists.js' +import { parseTorrentVideo } from '@tests/shared/webtorrent.js' describe('Test video static file privacy', function () { let server: PeerTubeServer @@ -156,7 +158,7 @@ describe('Test video static file privacy', function () { privacy: VideoPrivacy.PRIVATE, scheduleUpdate: { updateAt: new Date(Date.now() + 1000).toISOString(), - privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC + privacy: VideoPrivacy.PUBLIC } } @@ -191,7 +193,7 @@ describe('Test video static file privacy', function () { async function checkVideoFiles (options: { id: string - expectedStatus: HttpStatusCode + expectedStatus: HttpStatusCodeType token: string videoFileToken: string videoPassword?: string diff --git a/server/tests/api/videos/video-storyboard.ts b/packages/tests/src/api/videos/video-storyboard.ts similarity index 95% rename from server/tests/api/videos/video-storyboard.ts rename to packages/tests/src/api/videos/video-storyboard.ts index 07f371cad..7d156aa7f 100644 --- a/server/tests/api/videos/video-storyboard.ts +++ b/packages/tests/src/api/videos/video-storyboard.ts @@ -1,11 +1,11 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { readdir } from 'fs-extra' +import { readdir } from 'fs/promises' import { basename } from 'path' -import { FIXTURE_URLS } from '@server/tests/shared' -import { areHttpImportTestsDisabled } from '@shared/core-utils' -import { HttpStatusCode, VideoPrivacy } from '@shared/models' +import { FIXTURE_URLS } from '@tests/shared/tests.js' +import { areHttpImportTestsDisabled } from '@peertube/peertube-node-utils' +import { HttpStatusCode, VideoPrivacy } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -17,7 +17,7 @@ import { setDefaultVideoChannel, stopFfmpeg, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' async function checkStoryboard (options: { server: PeerTubeServer diff --git a/server/tests/api/videos/videos-common-filters.ts b/packages/tests/src/api/videos/videos-common-filters.ts similarity index 96% rename from server/tests/api/videos/videos-common-filters.ts rename to packages/tests/src/api/videos/videos-common-filters.ts index 48de7c537..9e75bd6ca 100644 --- a/server/tests/api/videos/videos-common-filters.ts +++ b/packages/tests/src/api/videos/videos-common-filters.ts @@ -1,8 +1,18 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { pick } from '@shared/core-utils' -import { HttpStatusCode, UserRole, Video, VideoDetails, VideoInclude, VideoPrivacy } from '@shared/models' +import { pick } from '@peertube/peertube-core-utils' +import { + HttpStatusCode, + HttpStatusCodeType, + UserRole, + Video, + VideoDetails, + VideoInclude, + VideoIncludeType, + VideoPrivacy, + VideoPrivacyType +} from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -13,7 +23,7 @@ import { setDefaultAccountAvatar, setDefaultVideoChannel, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test videos filter', function () { let servers: PeerTubeServer[] @@ -82,12 +92,12 @@ describe('Test videos filter', function () { isLocal?: boolean hasWebVideoFiles?: boolean hasHLSFiles?: boolean - include?: VideoInclude - privacyOneOf?: VideoPrivacy[] + include?: VideoIncludeType + privacyOneOf?: VideoPrivacyType[] category?: number tagsAllOf?: string[] token?: string - expectedStatus?: HttpStatusCode + expectedStatus?: HttpStatusCodeType excludeAlreadyWatched?: boolean }) { const res = await makeGetRequest({ @@ -118,10 +128,10 @@ describe('Test videos filter', function () { options: { server: PeerTubeServer isLocal?: boolean - include?: VideoInclude - privacyOneOf?: VideoPrivacy[] + include?: VideoIncludeType + privacyOneOf?: VideoPrivacyType[] token?: string - expectedStatus?: HttpStatusCode + expectedStatus?: HttpStatusCodeType skipSubscription?: boolean excludeAlreadyWatched?: boolean } diff --git a/server/tests/api/videos/videos-history.ts b/packages/tests/src/api/videos/videos-history.ts similarity index 96% rename from server/tests/api/videos/videos-history.ts rename to packages/tests/src/api/videos/videos-history.ts index 6df26ab7d..75c0fcebd 100644 --- a/server/tests/api/videos/videos-history.ts +++ b/packages/tests/src/api/videos/videos-history.ts @@ -1,9 +1,15 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { wait } from '@shared/core-utils' -import { Video } from '@shared/models' -import { cleanupTests, createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' +import { wait } from '@peertube/peertube-core-utils' +import { Video } from '@peertube/peertube-models' +import { + cleanupTests, + createSingleServer, + killallServers, + PeerTubeServer, + setAccessTokensToServers +} from '@peertube/peertube-server-commands' describe('Test videos history', function () { let server: PeerTubeServer = null diff --git a/server/tests/api/videos/videos-overview.ts b/packages/tests/src/api/videos/videos-overview.ts similarity index 95% rename from server/tests/api/videos/videos-overview.ts rename to packages/tests/src/api/videos/videos-overview.ts index f2496e35e..7d74d6db2 100644 --- a/server/tests/api/videos/videos-overview.ts +++ b/packages/tests/src/api/videos/videos-overview.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { wait } from '@shared/core-utils' -import { VideosOverview } from '@shared/models' -import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' +import { wait } from '@peertube/peertube-core-utils' +import { VideosOverview } from '@peertube/peertube-models' +import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@peertube/peertube-server-commands' describe('Test a videos overview', function () { let server: PeerTubeServer = null diff --git a/packages/tests/src/api/views/index.ts b/packages/tests/src/api/views/index.ts new file mode 100644 index 000000000..2b7334d1a --- /dev/null +++ b/packages/tests/src/api/views/index.ts @@ -0,0 +1,5 @@ +export * from './video-views-counter.js' +export * from './video-views-overall-stats.js' +export * from './video-views-retention-stats.js' +export * from './video-views-timeserie-stats.js' +export * from './videos-views-cleaner.js' diff --git a/server/tests/api/views/video-views-counter.ts b/packages/tests/src/api/views/video-views-counter.ts similarity index 97% rename from server/tests/api/views/video-views-counter.ts rename to packages/tests/src/api/views/video-views-counter.ts index 0c1b7859c..d9afb0f18 100644 --- a/server/tests/api/views/video-views-counter.ts +++ b/packages/tests/src/api/views/video-views-counter.ts @@ -2,9 +2,9 @@ import { expect } from 'chai' import { FfmpegCommand } from 'fluent-ffmpeg' -import { prepareViewsServers, prepareViewsVideos, processViewsBuffer } from '@server/tests/shared' -import { wait } from '@shared/core-utils' -import { cleanupTests, PeerTubeServer, stopFfmpeg, waitJobs } from '@shared/server-commands' +import { prepareViewsServers, prepareViewsVideos, processViewsBuffer } from '@tests/shared/views.js' +import { wait } from '@peertube/peertube-core-utils' +import { cleanupTests, PeerTubeServer, stopFfmpeg, waitJobs } from '@peertube/peertube-server-commands' describe('Test video views/viewers counters', function () { let servers: PeerTubeServer[] diff --git a/server/tests/api/views/video-views-overall-stats.ts b/packages/tests/src/api/views/video-views-overall-stats.ts similarity index 98% rename from server/tests/api/views/video-views-overall-stats.ts rename to packages/tests/src/api/views/video-views-overall-stats.ts index ac636961e..6ea0da2d9 100644 --- a/server/tests/api/views/video-views-overall-stats.ts +++ b/packages/tests/src/api/views/video-views-overall-stats.ts @@ -2,10 +2,10 @@ import { expect } from 'chai' import { FfmpegCommand } from 'fluent-ffmpeg' -import { prepareViewsServers, prepareViewsVideos, processViewersStats } from '@server/tests/shared' -import { cleanupTests, PeerTubeServer, stopFfmpeg, waitJobs } from '@shared/server-commands' -import { wait } from '@shared/core-utils' -import { VideoStatsOverall } from '@shared/models' +import { prepareViewsServers, prepareViewsVideos, processViewersStats } from '@tests/shared/views.js' +import { cleanupTests, PeerTubeServer, stopFfmpeg, waitJobs } from '@peertube/peertube-server-commands' +import { wait } from '@peertube/peertube-core-utils' +import { VideoStatsOverall } from '@peertube/peertube-models' /** * diff --git a/server/tests/api/views/video-views-retention-stats.ts b/packages/tests/src/api/views/video-views-retention-stats.ts similarity index 94% rename from server/tests/api/views/video-views-retention-stats.ts rename to packages/tests/src/api/views/video-views-retention-stats.ts index 5b9ce4c92..4cd0c7da9 100644 --- a/server/tests/api/views/video-views-retention-stats.ts +++ b/packages/tests/src/api/views/video-views-retention-stats.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { prepareViewsServers, prepareViewsVideos, processViewersStats } from '@server/tests/shared' -import { cleanupTests, PeerTubeServer } from '@shared/server-commands' +import { prepareViewsServers, prepareViewsVideos, processViewersStats } from '@tests/shared/views.js' +import { cleanupTests, PeerTubeServer } from '@peertube/peertube-server-commands' describe('Test views retention stats', function () { let servers: PeerTubeServer[] diff --git a/server/tests/api/views/video-views-timeserie-stats.ts b/packages/tests/src/api/views/video-views-timeserie-stats.ts similarity index 98% rename from server/tests/api/views/video-views-timeserie-stats.ts rename to packages/tests/src/api/views/video-views-timeserie-stats.ts index 2d991d7ea..44fccb644 100644 --- a/server/tests/api/views/video-views-timeserie-stats.ts +++ b/packages/tests/src/api/views/video-views-timeserie-stats.ts @@ -2,9 +2,9 @@ import { expect } from 'chai' import { FfmpegCommand } from 'fluent-ffmpeg' -import { prepareViewsServers, prepareViewsVideos, processViewersStats } from '@server/tests/shared' -import { VideoStatsTimeserie, VideoStatsTimeserieMetric } from '@shared/models' -import { cleanupTests, PeerTubeServer, stopFfmpeg } from '@shared/server-commands' +import { prepareViewsServers, prepareViewsVideos, processViewersStats } from '@tests/shared/views.js' +import { VideoStatsTimeserie, VideoStatsTimeserieMetric } from '@peertube/peertube-models' +import { cleanupTests, PeerTubeServer, stopFfmpeg } from '@peertube/peertube-server-commands' function buildOneMonthAgo () { const monthAgo = new Date() diff --git a/server/tests/api/views/videos-views-cleaner.ts b/packages/tests/src/api/views/videos-views-cleaner.ts similarity index 93% rename from server/tests/api/views/videos-views-cleaner.ts rename to packages/tests/src/api/views/videos-views-cleaner.ts index a84cd43c7..521dd9b5e 100644 --- a/server/tests/api/views/videos-views-cleaner.ts +++ b/packages/tests/src/api/views/videos-views-cleaner.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { SQLCommand } from '@server/tests/shared' -import { wait } from '@shared/core-utils' +import { SQLCommand } from '@tests/shared/sql-command.js' +import { wait } from '@peertube/peertube-core-utils' import { cleanupTests, createMultipleServers, @@ -11,7 +11,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test video views cleaner', function () { let servers: PeerTubeServer[] @@ -21,7 +21,7 @@ describe('Test video views cleaner', function () { let videoIdServer2: string before(async function () { - this.timeout(120000) + this.timeout(240000) servers = await createMultipleServers(2) await setAccessTokensToServers(servers) diff --git a/server/tests/cli/create-generate-storyboard-job.ts b/packages/tests/src/cli/create-generate-storyboard-job.ts similarity index 93% rename from server/tests/cli/create-generate-storyboard-job.ts rename to packages/tests/src/cli/create-generate-storyboard-job.ts index 02a4be8ae..5a1c61ef1 100644 --- a/server/tests/cli/create-generate-storyboard-job.ts +++ b/packages/tests/src/cli/create-generate-storyboard-job.ts @@ -1,9 +1,10 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { readdir, remove } from 'fs-extra' +import { remove } from 'fs-extra/esm' +import { readdir } from 'fs/promises' import { join } from 'path' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -12,8 +13,8 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' -import { SQLCommand } from '../shared' +} from '@peertube/peertube-server-commands' +import { SQLCommand } from '../shared/sql-command.js' function listStoryboardFiles (server: PeerTubeServer) { const storage = server.getDirectoryPath('storyboards') diff --git a/server/tests/cli/create-import-video-file-job.ts b/packages/tests/src/cli/create-import-video-file-job.ts similarity index 92% rename from server/tests/cli/create-import-video-file-job.ts rename to packages/tests/src/cli/create-import-video-file-job.ts index edd727967..fa934510c 100644 --- a/server/tests/cli/create-import-video-file-job.ts +++ b/packages/tests/src/cli/create-import-video-file-job.ts @@ -1,19 +1,19 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { expect } from 'chai' -import { areMockObjectStorageTestsDisabled } from '@shared/core-utils' -import { HttpStatusCode, VideoDetails, VideoFile, VideoInclude } from '@shared/models' +import { HttpStatusCode, VideoDetails, VideoFile, VideoInclude } from '@peertube/peertube-models' +import { areMockObjectStorageTestsDisabled, buildAbsoluteFixturePath } from '@peertube/peertube-node-utils' import { + ObjectStorageCommand, + PeerTubeServer, cleanupTests, createMultipleServers, doubleFollow, makeRawRequest, - ObjectStorageCommand, - PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' -import { expectStartWith } from '../shared' +} from '@peertube/peertube-server-commands' +import { expect } from 'chai' +import { expectStartWith } from '../shared/checks.js' function assertVideoProperties (video: VideoFile, resolution: number, extname: string, size?: number) { expect(video).to.have.nested.property('resolution.id', resolution) @@ -75,7 +75,7 @@ function runTests (enableObjectStorage: boolean) { }) it('Should run a import job on video 1 with a lower resolution', async function () { - const command = `npm run create-import-video-file-job -- -v ${video1ShortId} -i server/tests/fixtures/video_short_480.webm` + const command = `npm run create-import-video-file-job -- -v ${video1ShortId} -i ${buildAbsoluteFixturePath('video_short_480.webm')}` await servers[0].cli.execWithEnv(command) await waitJobs(servers) @@ -97,7 +97,7 @@ function runTests (enableObjectStorage: boolean) { }) it('Should run a import job on video 2 with the same resolution and a different extension', async function () { - const command = `npm run create-import-video-file-job -- -v ${video2UUID} -i server/tests/fixtures/video_short.ogv` + const command = `npm run create-import-video-file-job -- -v ${video2UUID} -i ${buildAbsoluteFixturePath('video_short.ogv')}` await servers[1].cli.execWithEnv(command) await waitJobs(servers) @@ -121,7 +121,7 @@ function runTests (enableObjectStorage: boolean) { }) it('Should run a import job on video 2 with the same resolution and the same extension', async function () { - const command = `npm run create-import-video-file-job -- -v ${video1ShortId} -i server/tests/fixtures/video_short2.webm` + const command = `npm run create-import-video-file-job -- -v ${video1ShortId} -i ${buildAbsoluteFixturePath('video_short2.webm')}` await servers[0].cli.execWithEnv(command) await waitJobs(servers) diff --git a/server/tests/cli/create-move-video-storage-job.ts b/packages/tests/src/cli/create-move-video-storage-job.ts similarity index 91% rename from server/tests/cli/create-move-video-storage-job.ts rename to packages/tests/src/cli/create-move-video-storage-job.ts index fc6a8e648..1bee7414f 100644 --- a/server/tests/cli/create-move-video-storage-job.ts +++ b/packages/tests/src/cli/create-move-video-storage-job.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { join } from 'path' -import { areMockObjectStorageTestsDisabled } from '@shared/core-utils' -import { HttpStatusCode, VideoDetails } from '@shared/models' +import { areMockObjectStorageTestsDisabled } from '@peertube/peertube-node-utils' +import { HttpStatusCode, VideoDetails } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -12,8 +12,9 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' -import { checkDirectoryIsEmpty, expectStartWith } from '../shared' +} from '@peertube/peertube-server-commands' +import { expectStartWith } from '../shared/checks.js' +import { checkDirectoryIsEmpty } from '@tests/shared/directories.js' async function checkFiles (origin: PeerTubeServer, video: VideoDetails, objectStorage?: ObjectStorageCommand) { for (const file of video.files) { diff --git a/server/tests/cli/index.ts b/packages/tests/src/cli/index.ts similarity index 100% rename from server/tests/cli/index.ts rename to packages/tests/src/cli/index.ts diff --git a/server/tests/cli/peertube.ts b/packages/tests/src/cli/peertube.ts similarity index 73% rename from server/tests/cli/peertube.ts rename to packages/tests/src/cli/peertube.ts index ad14fde91..2c66b7a18 100644 --- a/server/tests/cli/peertube.ts +++ b/packages/tests/src/cli/peertube.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { areHttpImportTestsDisabled, buildAbsoluteFixturePath } from '@shared/core-utils' +import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils' import { cleanupTests, CLICommand, @@ -10,8 +10,8 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' -import { FIXTURE_URLS, testHelloWorldRegisteredSettings } from '../shared' +} from '@peertube/peertube-server-commands' +import { testHelloWorldRegisteredSettings } from '../shared/plugins.js' describe('Test CLI wrapper', function () { let server: PeerTubeServer @@ -19,7 +19,7 @@ describe('Test CLI wrapper', function () { let cliCommand: CLICommand - const cmd = 'node ./dist/server/tools/peertube.js' + const cmd = 'node ./apps/peertube-cli/dist/peertube.js' before(async function () { this.timeout(30000) @@ -94,7 +94,7 @@ describe('Test CLI wrapper', function () { }) }) - describe('Video upload/import', function () { + describe('Video upload', function () { it('Should upload a video', async function () { this.timeout(60000) @@ -114,80 +114,6 @@ describe('Test CLI wrapper', function () { expect(video.support).to.equal('support_text') expect(video.channel.name).to.equal('user_channel') }) - - it('Should import a video', async function () { - if (areHttpImportTestsDisabled()) return - - this.timeout(60000) - - const params = `--target-url ${FIXTURE_URLS.youtube} --channel-name user_channel` - await cliCommand.execWithEnv(`${cmd} import ${params}`) - }) - - it('Should have imported the video', async function () { - if (areHttpImportTestsDisabled()) return - - this.timeout(60000) - - await waitJobs([ server ]) - - const { total, data } = await server.videos.list() - expect(total).to.equal(2) - - const video = data.find(v => v.name === 'small video - youtube') - expect(video).to.not.be.undefined - - const videoDetails = await server.videos.get({ id: video.id }) - expect(videoDetails.channel.name).to.equal('user_channel') - expect(videoDetails.support).to.equal('super support text') - expect(videoDetails.nsfw).to.be.false - }) - - it('Should not import again the same video', async function () { - if (areHttpImportTestsDisabled()) return - - this.timeout(60000) - - const params = `--target-url ${FIXTURE_URLS.youtube} --channel-name user_channel` - await cliCommand.execWithEnv(`${cmd} import ${params}`) - - await waitJobs([ server ]) - - const { total, data } = await server.videos.list() - expect(total).to.equal(2) - - const videos = data.filter(v => v.name === 'small video - youtube') - expect(videos).to.have.lengthOf(1) - - // So we can reimport it - await server.videos.remove({ token: userAccessToken, id: videos[0].id }) - }) - - it('Should import and override some imported attributes', async function () { - if (areHttpImportTestsDisabled()) return - - this.timeout(60000) - - const params = `--target-url ${FIXTURE_URLS.youtube} ` + - `--channel-name user_channel --video-name toto --nsfw --support support` - await cliCommand.execWithEnv(`${cmd} import ${params}`) - - await waitJobs([ server ]) - - { - const { total, data } = await server.videos.list() - expect(total).to.equal(2) - - const video = data.find(v => v.name === 'toto') - expect(video).to.not.be.undefined - - const videoDetails = await server.videos.get({ id: video.id }) - expect(videoDetails.channel.name).to.equal('user_channel') - expect(videoDetails.support).to.equal('support') - expect(videoDetails.nsfw).to.be.true - expect(videoDetails.commentsEnabled).to.be.true - } - }) }) describe('Admin auth', function () { diff --git a/server/tests/cli/plugins.ts b/packages/tests/src/cli/plugins.ts similarity index 97% rename from server/tests/cli/plugins.ts rename to packages/tests/src/cli/plugins.ts index c646e20d9..ab7f7dd85 100644 --- a/server/tests/cli/plugins.ts +++ b/packages/tests/src/cli/plugins.ts @@ -8,7 +8,7 @@ import { PeerTubeServer, PluginsCommand, setAccessTokensToServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test plugin scripts', function () { let server: PeerTubeServer diff --git a/server/tests/cli/prune-storage.ts b/packages/tests/src/cli/prune-storage.ts similarity index 96% rename from server/tests/cli/prune-storage.ts rename to packages/tests/src/cli/prune-storage.ts index 72a4b1332..c07a2a975 100644 --- a/server/tests/cli/prune-storage.ts +++ b/packages/tests/src/cli/prune-storage.ts @@ -1,11 +1,12 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { createFile, readdir } from 'fs-extra' +import { createFile } from 'fs-extra/esm' +import { readdir } from 'fs/promises' import { join } from 'path' -import { wait } from '@shared/core-utils' -import { buildUUID } from '@shared/extra-utils' -import { HttpStatusCode, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' +import { wait } from '@peertube/peertube-core-utils' +import { buildUUID } from '@peertube/peertube-node-utils' +import { HttpStatusCode, VideoPlaylistPrivacy, VideoPrivacy } from '@peertube/peertube-models' import { cleanupTests, CLICommand, @@ -17,7 +18,7 @@ import { setAccessTokensToServers, setDefaultVideoChannel, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' async function assertNotExists (server: PeerTubeServer, directory: string, substring: string) { const files = await readdir(server.servers.buildDirectory(directory)) diff --git a/server/tests/cli/regenerate-thumbnails.ts b/packages/tests/src/cli/regenerate-thumbnails.ts similarity index 96% rename from server/tests/cli/regenerate-thumbnails.ts rename to packages/tests/src/cli/regenerate-thumbnails.ts index 66de7f79c..1448e5cfc 100644 --- a/server/tests/cli/regenerate-thumbnails.ts +++ b/packages/tests/src/cli/regenerate-thumbnails.ts @@ -1,7 +1,7 @@ import { expect } from 'chai' -import { writeFile } from 'fs-extra' +import { writeFile } from 'fs/promises' import { basename, join } from 'path' -import { HttpStatusCode, Video } from '@shared/models' +import { HttpStatusCode, Video } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -10,7 +10,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '../../../shared/server-commands' +} from '@peertube/peertube-server-commands' async function testThumbnail (server: PeerTubeServer, videoId: number | string) { const video = await server.videos.get({ id: videoId }) diff --git a/server/tests/cli/reset-password.ts b/packages/tests/src/cli/reset-password.ts similarity index 90% rename from server/tests/cli/reset-password.ts rename to packages/tests/src/cli/reset-password.ts index 79892173b..62e1a37a0 100644 --- a/server/tests/cli/reset-password.ts +++ b/packages/tests/src/cli/reset-password.ts @@ -1,4 +1,4 @@ -import { cleanupTests, CLICommand, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' +import { cleanupTests, CLICommand, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@peertube/peertube-server-commands' describe('Test reset password scripts', function () { let server: PeerTubeServer diff --git a/server/tests/cli/update-host.ts b/packages/tests/src/cli/update-host.ts similarity index 96% rename from server/tests/cli/update-host.ts rename to packages/tests/src/cli/update-host.ts index 386c384e6..e5f165e5e 100644 --- a/server/tests/cli/update-host.ts +++ b/packages/tests/src/cli/update-host.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { getAllFiles } from '@shared/core-utils' +import { getAllFiles } from '@peertube/peertube-core-utils' import { cleanupTests, createSingleServer, @@ -10,8 +10,8 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' -import { parseTorrentVideo } from '../shared' +} from '@peertube/peertube-server-commands' +import { parseTorrentVideo } from '@tests/shared/webtorrent.js' describe('Test update host scripts', function () { let server: PeerTubeServer diff --git a/server/tests/client.ts b/packages/tests/src/client.ts similarity index 99% rename from server/tests/client.ts rename to packages/tests/src/client.ts index 68f3a1d14..a16205494 100644 --- a/server/tests/client.ts +++ b/packages/tests/src/client.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { omit } from '@shared/core-utils' +import { omit } from '@peertube/peertube-core-utils' import { Account, HTMLServerConfig, @@ -10,7 +10,7 @@ import { VideoPlaylistCreateResult, VideoPlaylistPrivacy, VideoPrivacy -} from '@shared/models' +} from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -21,7 +21,7 @@ import { setAccessTokensToServers, setDefaultVideoChannel, waitJobs -} from '../../shared/server-commands' +} from '@peertube/peertube-server-commands' function checkIndexTags (html: string, title: string, description: string, css: string, config: ServerConfig) { expect(html).to.contain('' + title + '') diff --git a/server/tests/external-plugins/akismet.ts b/packages/tests/src/external-plugins/akismet.ts similarity index 97% rename from server/tests/external-plugins/akismet.ts rename to packages/tests/src/external-plugins/akismet.ts index e964bf0c2..c6d3b7752 100644 --- a/server/tests/external-plugins/akismet.ts +++ b/packages/tests/src/external-plugins/akismet.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -9,7 +9,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Official plugin Akismet', function () { let servers: PeerTubeServer[] diff --git a/server/tests/external-plugins/auth-ldap.ts b/packages/tests/src/external-plugins/auth-ldap.ts similarity index 97% rename from server/tests/external-plugins/auth-ldap.ts rename to packages/tests/src/external-plugins/auth-ldap.ts index d51d337be..ad058110c 100644 --- a/server/tests/external-plugins/auth-ldap.ts +++ b/packages/tests/src/external-plugins/auth-ldap.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' -import { HttpStatusCode } from '@shared/models' +import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@peertube/peertube-server-commands' +import { HttpStatusCode } from '@peertube/peertube-models' describe('Official plugin auth-ldap', function () { let server: PeerTubeServer diff --git a/server/tests/external-plugins/auto-block-videos.ts b/packages/tests/src/external-plugins/auto-block-videos.ts similarity index 95% rename from server/tests/external-plugins/auto-block-videos.ts rename to packages/tests/src/external-plugins/auto-block-videos.ts index 95d7a4b58..6146c827c 100644 --- a/server/tests/external-plugins/auto-block-videos.ts +++ b/packages/tests/src/external-plugins/auto-block-videos.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { wait } from '@shared/core-utils' -import { Video } from '@shared/models' +import { wait } from '@peertube/peertube-core-utils' +import { Video } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -10,8 +10,8 @@ import { killallServers, PeerTubeServer, setAccessTokensToServers -} from '@shared/server-commands' -import { MockBlocklist } from '../shared' +} from '@peertube/peertube-server-commands' +import { MockBlocklist } from '../shared/mock-servers/index.js' async function check (server: PeerTubeServer, videoUUID: string, exists = true) { const { data } = await server.videos.list() diff --git a/server/tests/external-plugins/auto-mute.ts b/packages/tests/src/external-plugins/auto-mute.ts similarity index 95% rename from server/tests/external-plugins/auto-mute.ts rename to packages/tests/src/external-plugins/auto-mute.ts index a9bf3c173..b4050e236 100644 --- a/server/tests/external-plugins/auto-mute.ts +++ b/packages/tests/src/external-plugins/auto-mute.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { wait } from '@shared/core-utils' -import { HttpStatusCode } from '@shared/models' +import { wait } from '@peertube/peertube-core-utils' +import { HttpStatusCode } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -11,8 +11,8 @@ import { makeGetRequest, PeerTubeServer, setAccessTokensToServers -} from '@shared/server-commands' -import { MockBlocklist } from '../shared' +} from '@peertube/peertube-server-commands' +import { MockBlocklist } from '../shared/mock-servers/index.js' describe('Official plugin auto-mute', function () { const autoMuteListPath = '/plugins/auto-mute/router/api/v1/mute-list' diff --git a/server/tests/external-plugins/index.ts b/packages/tests/src/external-plugins/index.ts similarity index 100% rename from server/tests/external-plugins/index.ts rename to packages/tests/src/external-plugins/index.ts diff --git a/server/tests/feeds/feeds.ts b/packages/tests/src/feeds/feeds.ts similarity index 99% rename from server/tests/feeds/feeds.ts rename to packages/tests/src/feeds/feeds.ts index 1754ac466..7587bb34e 100644 --- a/server/tests/feeds/feeds.ts +++ b/packages/tests/src/feeds/feeds.ts @@ -1,8 +1,10 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import * as chai from 'chai' +import chaiJSONSChema from 'chai-json-schema' +import chaiXML from 'chai-xml' import { XMLParser, XMLValidator } from 'fast-xml-parser' -import { HttpStatusCode, VideoPrivacy } from '@shared/models' +import { HttpStatusCode, VideoPrivacy } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -17,10 +19,10 @@ import { setDefaultVideoChannel, stopFfmpeg, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' -chai.use(require('chai-xml')) -chai.use(require('chai-json-schema')) +chai.use(chaiXML) +chai.use(chaiJSONSChema) chai.config.includeStack = true const expect = chai.expect diff --git a/server/tests/feeds/index.ts b/packages/tests/src/feeds/index.ts similarity index 100% rename from server/tests/feeds/index.ts rename to packages/tests/src/feeds/index.ts diff --git a/server/tests/misc-endpoints.ts b/packages/tests/src/misc-endpoints.ts similarity index 96% rename from server/tests/misc-endpoints.ts rename to packages/tests/src/misc-endpoints.ts index f9cf2b717..0067578ed 100644 --- a/server/tests/misc-endpoints.ts +++ b/packages/tests/src/misc-endpoints.ts @@ -1,11 +1,17 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { writeJson } from 'fs-extra' +import { writeJson } from 'fs-extra/esm' import { join } from 'path' -import { HttpStatusCode, VideoPrivacy } from '@shared/models' -import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' -import { expectLogDoesNotContain } from './shared' +import { HttpStatusCode, VideoPrivacy } from '@peertube/peertube-models' +import { + cleanupTests, + createSingleServer, + makeGetRequest, + PeerTubeServer, + setAccessTokensToServers +} from '@peertube/peertube-server-commands' +import { expectLogDoesNotContain } from './shared/checks.js' describe('Test misc endpoints', function () { let server: PeerTubeServer diff --git a/server/tests/peertube-runner/client-cli.ts b/packages/tests/src/peertube-runner/client-cli.ts similarity index 89% rename from server/tests/peertube-runner/client-cli.ts rename to packages/tests/src/peertube-runner/client-cli.ts index 5cbdc4e77..814b7f13a 100644 --- a/server/tests/peertube-runner/client-cli.ts +++ b/packages/tests/src/peertube-runner/client-cli.ts @@ -1,8 +1,14 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { PeerTubeRunnerProcess } from '@server/tests/shared' -import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel } from '@shared/server-commands' +import { PeerTubeRunnerProcess } from '@tests/shared/peertube-runner-process.js' +import { + cleanupTests, + createSingleServer, + PeerTubeServer, + setAccessTokensToServers, + setDefaultVideoChannel +} from '@peertube/peertube-server-commands' describe('Test peertube-runner program client CLI', function () { let server: PeerTubeServer diff --git a/packages/tests/src/peertube-runner/index.ts b/packages/tests/src/peertube-runner/index.ts new file mode 100644 index 000000000..29f21694f --- /dev/null +++ b/packages/tests/src/peertube-runner/index.ts @@ -0,0 +1,4 @@ +export * from './client-cli.js' +export * from './live-transcoding.js' +export * from './studio-transcoding.js' +export * from './vod-transcoding.js' diff --git a/server/tests/peertube-runner/live-transcoding.ts b/packages/tests/src/peertube-runner/live-transcoding.ts similarity index 91% rename from server/tests/peertube-runner/live-transcoding.ts rename to packages/tests/src/peertube-runner/live-transcoding.ts index 41b01f8d5..9351bc5e2 100644 --- a/server/tests/peertube-runner/live-transcoding.ts +++ b/packages/tests/src/peertube-runner/live-transcoding.ts @@ -1,14 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { - checkPeerTubeRunnerCacheIsEmpty, - expectStartWith, - PeerTubeRunnerProcess, - SQLCommand, - testLiveVideoResolutions -} from '@server/tests/shared' -import { areMockObjectStorageTestsDisabled, wait } from '@shared/core-utils' -import { HttpStatusCode, VideoPrivacy } from '@shared/models' +import { wait } from '@peertube/peertube-core-utils' +import { HttpStatusCode, VideoPrivacy } from '@peertube/peertube-models' +import { areMockObjectStorageTestsDisabled } from '@peertube/peertube-node-utils' import { cleanupTests, createMultipleServers, @@ -23,7 +17,12 @@ import { waitJobs, waitUntilLivePublishedOnAllServers, waitUntilLiveWaitingOnAllServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' +import { expectStartWith } from '@tests/shared/checks.js' +import { checkPeerTubeRunnerCacheIsEmpty } from '@tests/shared/directories.js' +import { testLiveVideoResolutions } from '@tests/shared/live.js' +import { PeerTubeRunnerProcess } from '@tests/shared/peertube-runner-process.js' +import { SQLCommand } from '@tests/shared/sql-command.js' describe('Test Live transcoding in peertube-runner program', function () { let servers: PeerTubeServer[] = [] diff --git a/server/tests/peertube-runner/studio-transcoding.ts b/packages/tests/src/peertube-runner/studio-transcoding.ts similarity index 88% rename from server/tests/peertube-runner/studio-transcoding.ts rename to packages/tests/src/peertube-runner/studio-transcoding.ts index 56bfef897..50e61091a 100644 --- a/server/tests/peertube-runner/studio-transcoding.ts +++ b/packages/tests/src/peertube-runner/studio-transcoding.ts @@ -1,7 +1,7 @@ import { expect } from 'chai' -import { checkPeerTubeRunnerCacheIsEmpty, checkVideoDuration, expectStartWith, PeerTubeRunnerProcess } from '@server/tests/shared' -import { areMockObjectStorageTestsDisabled, getAllFiles, wait } from '@shared/core-utils' +import { getAllFiles, wait } from '@peertube/peertube-core-utils' +import { areMockObjectStorageTestsDisabled } from '@peertube/peertube-node-utils' import { cleanupTests, createMultipleServers, @@ -12,7 +12,10 @@ import { setDefaultVideoChannel, VideoStudioCommand, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' +import { expectStartWith, checkVideoDuration } from '@tests/shared/checks.js' +import { checkPeerTubeRunnerCacheIsEmpty } from '@tests/shared/directories.js' +import { PeerTubeRunnerProcess } from '@tests/shared/peertube-runner-process.js' describe('Test studio transcoding in peertube-runner program', function () { let servers: PeerTubeServer[] = [] diff --git a/server/tests/peertube-runner/vod-transcoding.ts b/packages/tests/src/peertube-runner/vod-transcoding.ts similarity index 94% rename from server/tests/peertube-runner/vod-transcoding.ts rename to packages/tests/src/peertube-runner/vod-transcoding.ts index b3b62e5e0..ff5cefe36 100644 --- a/server/tests/peertube-runner/vod-transcoding.ts +++ b/packages/tests/src/peertube-runner/vod-transcoding.ts @@ -1,13 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { - checkPeerTubeRunnerCacheIsEmpty, - completeCheckHlsPlaylist, - completeWebVideoFilesCheck, - PeerTubeRunnerProcess -} from '@server/tests/shared' -import { areMockObjectStorageTestsDisabled, getAllFiles, wait } from '@shared/core-utils' -import { VideoPrivacy } from '@shared/models' +import { getAllFiles, wait } from '@peertube/peertube-core-utils' +import { VideoPrivacy } from '@peertube/peertube-models' +import { areMockObjectStorageTestsDisabled } from '@peertube/peertube-node-utils' import { cleanupTests, createMultipleServers, @@ -17,7 +12,11 @@ import { setAccessTokensToServers, setDefaultVideoChannel, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' +import { checkPeerTubeRunnerCacheIsEmpty } from '@tests/shared/directories.js' +import { PeerTubeRunnerProcess } from '@tests/shared/peertube-runner-process.js' +import { completeCheckHlsPlaylist } from '@tests/shared/streaming-playlists.js' +import { completeWebVideoFilesCheck } from '@tests/shared/videos.js' describe('Test VOD transcoding in peertube-runner program', function () { let servers: PeerTubeServer[] = [] diff --git a/server/tests/plugins/action-hooks.ts b/packages/tests/src/plugins/action-hooks.ts similarity index 99% rename from server/tests/plugins/action-hooks.ts rename to packages/tests/src/plugins/action-hooks.ts index 773be0d76..136c7671b 100644 --- a/server/tests/plugins/action-hooks.ts +++ b/packages/tests/src/plugins/action-hooks.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { ServerHookName, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' +import { ServerHookName, VideoPlaylistPrivacy, VideoPrivacy } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -12,7 +12,7 @@ import { setDefaultVideoChannel, stopFfmpeg, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test plugin action hooks', function () { let servers: PeerTubeServer[] diff --git a/server/tests/plugins/external-auth.ts b/packages/tests/src/plugins/external-auth.ts similarity index 98% rename from server/tests/plugins/external-auth.ts rename to packages/tests/src/plugins/external-auth.ts index e4015939a..c7fe22185 100644 --- a/server/tests/plugins/external-auth.ts +++ b/packages/tests/src/plugins/external-auth.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { wait } from '@shared/core-utils' -import { HttpStatusCode, UserAdminFlag, UserRole } from '@shared/models' +import { wait } from '@peertube/peertube-core-utils' +import { HttpStatusCode, HttpStatusCodeType, UserAdminFlag, UserRole } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -10,7 +10,7 @@ import { PeerTubeServer, PluginsCommand, setAccessTokensToServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' async function loginExternal (options: { server: PeerTubeServer @@ -18,8 +18,8 @@ async function loginExternal (options: { authName: string username: string query?: any - expectedStatus?: HttpStatusCode - expectedStatusStep2?: HttpStatusCode + expectedStatus?: HttpStatusCodeType + expectedStatusStep2?: HttpStatusCodeType }) { const res = await options.server.plugins.getExternalAuth({ npmName: options.npmName, diff --git a/server/tests/plugins/filter-hooks.ts b/packages/tests/src/plugins/filter-hooks.ts similarity index 99% rename from server/tests/plugins/filter-hooks.ts rename to packages/tests/src/plugins/filter-hooks.ts index 8382b400f..88cfee631 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/packages/tests/src/plugins/filter-hooks.ts @@ -9,7 +9,7 @@ import { VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy -} from '@shared/models' +} from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -22,8 +22,8 @@ import { setAccessTokensToServers, setDefaultVideoChannel, waitJobs -} from '@shared/server-commands' -import { FIXTURE_URLS } from '../shared' +} from '@peertube/peertube-server-commands' +import { FIXTURE_URLS } from '../shared/tests.js' describe('Test plugin filter hooks', function () { let servers: PeerTubeServer[] diff --git a/server/tests/plugins/html-injection.ts b/packages/tests/src/plugins/html-injection.ts similarity index 97% rename from server/tests/plugins/html-injection.ts rename to packages/tests/src/plugins/html-injection.ts index fe16bf1e6..269a45b98 100644 --- a/server/tests/plugins/html-injection.ts +++ b/packages/tests/src/plugins/html-injection.ts @@ -8,7 +8,7 @@ import { PeerTubeServer, PluginsCommand, setAccessTokensToServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' describe('Test plugins HTML injection', function () { let server: PeerTubeServer = null diff --git a/server/tests/plugins/id-and-pass-auth.ts b/packages/tests/src/plugins/id-and-pass-auth.ts similarity index 97% rename from server/tests/plugins/id-and-pass-auth.ts rename to packages/tests/src/plugins/id-and-pass-auth.ts index 127c29cbc..a332f0eec 100644 --- a/server/tests/plugins/id-and-pass-auth.ts +++ b/packages/tests/src/plugins/id-and-pass-auth.ts @@ -1,9 +1,15 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { wait } from '@shared/core-utils' -import { HttpStatusCode, UserRole } from '@shared/models' -import { cleanupTests, createSingleServer, PeerTubeServer, PluginsCommand, setAccessTokensToServers } from '@shared/server-commands' +import { wait } from '@peertube/peertube-core-utils' +import { HttpStatusCode, UserRole } from '@peertube/peertube-models' +import { + cleanupTests, + createSingleServer, + PeerTubeServer, + PluginsCommand, + setAccessTokensToServers +} from '@peertube/peertube-server-commands' describe('Test id and pass auth plugins', function () { let server: PeerTubeServer diff --git a/server/tests/plugins/index.ts b/packages/tests/src/plugins/index.ts similarity index 100% rename from server/tests/plugins/index.ts rename to packages/tests/src/plugins/index.ts diff --git a/server/tests/plugins/plugin-helpers.ts b/packages/tests/src/plugins/plugin-helpers.ts similarity index 98% rename from server/tests/plugins/plugin-helpers.ts rename to packages/tests/src/plugins/plugin-helpers.ts index f5a0cbe85..d2bd8596e 100644 --- a/server/tests/plugins/plugin-helpers.ts +++ b/packages/tests/src/plugins/plugin-helpers.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { pathExists } from 'fs-extra' -import { HttpStatusCode, ThumbnailType } from '@shared/models' +import { pathExists } from 'fs-extra/esm' +import { HttpStatusCode, ThumbnailType } from '@peertube/peertube-models' import { cleanupTests, createMultipleServers, @@ -14,8 +14,8 @@ import { PluginsCommand, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' -import { checkVideoFilesWereRemoved } from '../shared' +} from '@peertube/peertube-server-commands' +import { checkVideoFilesWereRemoved } from '@tests/shared/videos.js' function postCommand (server: PeerTubeServer, command: string, bodyArg?: object) { const body = { command } diff --git a/server/tests/plugins/plugin-router.ts b/packages/tests/src/plugins/plugin-router.ts similarity index 96% rename from server/tests/plugins/plugin-router.ts rename to packages/tests/src/plugins/plugin-router.ts index 40b15eb79..6f3571c05 100644 --- a/server/tests/plugins/plugin-router.ts +++ b/packages/tests/src/plugins/plugin-router.ts @@ -9,8 +9,8 @@ import { PeerTubeServer, PluginsCommand, setAccessTokensToServers -} from '@shared/server-commands' -import { HttpStatusCode } from '@shared/models' +} from '@peertube/peertube-server-commands' +import { HttpStatusCode } from '@peertube/peertube-models' describe('Test plugin helpers', function () { let server: PeerTubeServer diff --git a/server/tests/plugins/plugin-storage.ts b/packages/tests/src/plugins/plugin-storage.ts similarity index 93% rename from server/tests/plugins/plugin-storage.ts rename to packages/tests/src/plugins/plugin-storage.ts index 112652a1f..f9b0ead0c 100644 --- a/server/tests/plugins/plugin-storage.ts +++ b/packages/tests/src/plugins/plugin-storage.ts @@ -1,8 +1,10 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { pathExists, readdir, readFile } from 'fs-extra' +import { pathExists } from 'fs-extra/esm' +import { readdir, readFile } from 'fs/promises' import { join } from 'path' +import { HttpStatusCode } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -10,8 +12,7 @@ import { PeerTubeServer, PluginsCommand, setAccessTokensToServers -} from '@shared/server-commands' -import { HttpStatusCode } from '@shared/models' +} from '@peertube/peertube-server-commands' describe('Test plugin storage', function () { let server: PeerTubeServer diff --git a/server/tests/plugins/plugin-transcoding.ts b/packages/tests/src/plugins/plugin-transcoding.ts similarity index 98% rename from server/tests/plugins/plugin-transcoding.ts rename to packages/tests/src/plugins/plugin-transcoding.ts index 21f82fbac..2f50f65ff 100644 --- a/server/tests/plugins/plugin-transcoding.ts +++ b/packages/tests/src/plugins/plugin-transcoding.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { getAudioStream, getVideoStream, getVideoStreamFPS } from '@shared/ffmpeg' -import { VideoPrivacy } from '@shared/models' +import { getAudioStream, getVideoStream, getVideoStreamFPS } from '@peertube/peertube-ffmpeg' +import { VideoPrivacy } from '@peertube/peertube-models' import { cleanupTests, createSingleServer, @@ -12,7 +12,7 @@ import { setDefaultVideoChannel, testFfmpegStreamError, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' async function createLiveWrapper (server: PeerTubeServer) { const liveAttributes = { diff --git a/server/tests/plugins/plugin-unloading.ts b/packages/tests/src/plugins/plugin-unloading.ts similarity index 95% rename from server/tests/plugins/plugin-unloading.ts rename to packages/tests/src/plugins/plugin-unloading.ts index 5aca1a0c0..70310bc8c 100644 --- a/server/tests/plugins/plugin-unloading.ts +++ b/packages/tests/src/plugins/plugin-unloading.ts @@ -8,8 +8,8 @@ import { PeerTubeServer, PluginsCommand, setAccessTokensToServers -} from '@shared/server-commands' -import { HttpStatusCode } from '@shared/models' +} from '@peertube/peertube-server-commands' +import { HttpStatusCode } from '@peertube/peertube-models' describe('Test plugins module unloading', function () { let server: PeerTubeServer = null diff --git a/server/tests/plugins/plugin-websocket.ts b/packages/tests/src/plugins/plugin-websocket.ts similarity index 92% rename from server/tests/plugins/plugin-websocket.ts rename to packages/tests/src/plugins/plugin-websocket.ts index adaa28b1d..832dcebd0 100644 --- a/server/tests/plugins/plugin-websocket.ts +++ b/packages/tests/src/plugins/plugin-websocket.ts @@ -1,7 +1,13 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import WebSocket from 'ws' -import { cleanupTests, createSingleServer, PeerTubeServer, PluginsCommand, setAccessTokensToServers } from '@shared/server-commands' +import { + cleanupTests, + createSingleServer, + PeerTubeServer, + PluginsCommand, + setAccessTokensToServers +} from '@peertube/peertube-server-commands' function buildWebSocket (server: PeerTubeServer, path: string) { return new WebSocket('ws://' + server.host + path) diff --git a/server/tests/plugins/translations.ts b/packages/tests/src/plugins/translations.ts similarity index 92% rename from server/tests/plugins/translations.ts rename to packages/tests/src/plugins/translations.ts index 67e4683f8..a69e14134 100644 --- a/server/tests/plugins/translations.ts +++ b/packages/tests/src/plugins/translations.ts @@ -1,7 +1,13 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { cleanupTests, createSingleServer, PeerTubeServer, PluginsCommand, setAccessTokensToServers } from '@shared/server-commands' +import { + cleanupTests, + createSingleServer, + PeerTubeServer, + PluginsCommand, + setAccessTokensToServers +} from '@peertube/peertube-server-commands' describe('Test plugin translations', function () { let server: PeerTubeServer diff --git a/server/tests/plugins/video-constants.ts b/packages/tests/src/plugins/video-constants.ts similarity index 96% rename from server/tests/plugins/video-constants.ts rename to packages/tests/src/plugins/video-constants.ts index c388f02d1..b81240a64 100644 --- a/server/tests/plugins/video-constants.ts +++ b/packages/tests/src/plugins/video-constants.ts @@ -8,8 +8,8 @@ import { PeerTubeServer, PluginsCommand, setAccessTokensToServers -} from '@shared/server-commands' -import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models' +} from '@peertube/peertube-server-commands' +import { HttpStatusCode, VideoPlaylistPrivacy, VideoPrivacy } from '@peertube/peertube-models' describe('Test plugin altering video constants', function () { let server: PeerTubeServer @@ -72,7 +72,7 @@ describe('Test plugin altering video constants', function () { }) it('Should not be able to create a video with this privacy', async function () { - const attributes = { name: 'video', privacy: 2 } + const attributes = { name: 'video', privacy: VideoPrivacy.UNLISTED } await server.videos.upload({ attributes, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) }) diff --git a/server/tests/api/activitypub/helpers.ts b/packages/tests/src/server-helpers/activitypub.ts similarity index 62% rename from server/tests/api/activitypub/helpers.ts rename to packages/tests/src/server-helpers/activitypub.ts index bad86ef47..dfcd0389f 100644 --- a/server/tests/api/activitypub/helpers.ts +++ b/packages/tests/src/server-helpers/activitypub.ts @@ -1,19 +1,28 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ +import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils' +import { signAndContextify } from '@peertube/peertube-server/server/helpers/activity-pub-utils.js' +import { + isHTTPSignatureVerified, + isJsonLDSignatureVerified, + parseHTTPSignature +} from '@peertube/peertube-server/server/helpers/peertube-crypto.js' +import { buildRequestStub } from '@tests/shared/tests.js' import { expect } from 'chai' -import { cloneDeep } from 'lodash' -import { signAndContextify } from '@server/lib/activitypub/send' -import { buildRequestStub } from '@server/tests/shared' -import { buildAbsoluteFixturePath } from '@shared/core-utils' -import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../../../helpers/peertube-crypto' +import { readJsonSync } from 'fs-extra/esm' +import cloneDeep from 'lodash-es/cloneDeep.js' + +function fakeFilter () { + return (data: any) => Promise.resolve(data) +} describe('Test activity pub helpers', function () { describe('When checking the Linked Signature', function () { it('Should fail with an invalid Mastodon signature', async function () { - const body = require(buildAbsoluteFixturePath('./ap-json/mastodon/create-bad-signature.json')) - const publicKey = require(buildAbsoluteFixturePath('./ap-json/mastodon/public-key.json')).publicKey + const body = readJsonSync(buildAbsoluteFixturePath('./ap-json/mastodon/create-bad-signature.json')) + const publicKey = readJsonSync(buildAbsoluteFixturePath('./ap-json/mastodon/public-key.json')).publicKey const fromActor = { publicKey, url: 'http://localhost:9002/accounts/peertube' } const result = await isJsonLDSignatureVerified(fromActor as any, body) @@ -22,8 +31,8 @@ describe('Test activity pub helpers', function () { }) it('Should fail with an invalid public key', async function () { - const body = require(buildAbsoluteFixturePath('./ap-json/mastodon/create.json')) - const publicKey = require(buildAbsoluteFixturePath('./ap-json/mastodon/bad-public-key.json')).publicKey + const body = readJsonSync(buildAbsoluteFixturePath('./ap-json/mastodon/create.json')) + const publicKey = readJsonSync(buildAbsoluteFixturePath('./ap-json/mastodon/bad-public-key.json')).publicKey const fromActor = { publicKey, url: 'http://localhost:9002/accounts/peertube' } const result = await isJsonLDSignatureVerified(fromActor as any, body) @@ -32,8 +41,8 @@ describe('Test activity pub helpers', function () { }) it('Should succeed with a valid Mastodon signature', async function () { - const body = require(buildAbsoluteFixturePath('./ap-json/mastodon/create.json')) - const publicKey = require(buildAbsoluteFixturePath('./ap-json/mastodon/public-key.json')).publicKey + const body = readJsonSync(buildAbsoluteFixturePath('./ap-json/mastodon/create.json')) + const publicKey = readJsonSync(buildAbsoluteFixturePath('./ap-json/mastodon/public-key.json')).publicKey const fromActor = { publicKey, url: 'http://localhost:9002/accounts/peertube' } const result = await isJsonLDSignatureVerified(fromActor as any, body) @@ -42,11 +51,11 @@ describe('Test activity pub helpers', function () { }) it('Should fail with an invalid PeerTube signature', async function () { - const keys = require(buildAbsoluteFixturePath('./ap-json/peertube/invalid-keys.json')) - const body = require(buildAbsoluteFixturePath('./ap-json/peertube/announce-without-context.json')) + const keys = readJsonSync(buildAbsoluteFixturePath('./ap-json/peertube/invalid-keys.json')) + const body = readJsonSync(buildAbsoluteFixturePath('./ap-json/peertube/announce-without-context.json')) const actorSignature = { url: 'http://localhost:9002/accounts/peertube', privateKey: keys.privateKey } - const signedBody = await signAndContextify(actorSignature as any, body, 'Announce') + const signedBody = await signAndContextify(actorSignature as any, body, 'Announce', fakeFilter()) const fromActor = { publicKey: keys.publicKey, url: 'http://localhost:9002/accounts/peertube' } const result = await isJsonLDSignatureVerified(fromActor as any, signedBody) @@ -55,11 +64,11 @@ describe('Test activity pub helpers', function () { }) it('Should succeed with a valid PeerTube signature', async function () { - const keys = require(buildAbsoluteFixturePath('./ap-json/peertube/keys.json')) - const body = require(buildAbsoluteFixturePath('./ap-json/peertube/announce-without-context.json')) + const keys = readJsonSync(buildAbsoluteFixturePath('./ap-json/peertube/keys.json')) + const body = readJsonSync(buildAbsoluteFixturePath('./ap-json/peertube/announce-without-context.json')) const actorSignature = { url: 'http://localhost:9002/accounts/peertube', privateKey: keys.privateKey } - const signedBody = await signAndContextify(actorSignature as any, body, 'Announce') + const signedBody = await signAndContextify(actorSignature as any, body, 'Announce', fakeFilter()) const fromActor = { publicKey: keys.publicKey, url: 'http://localhost:9002/accounts/peertube' } const result = await isJsonLDSignatureVerified(fromActor as any, signedBody) @@ -74,12 +83,12 @@ describe('Test activity pub helpers', function () { req.method = 'POST' req.url = '/accounts/ronan/inbox' - const mastodonObject = cloneDeep(require(buildAbsoluteFixturePath('./ap-json/mastodon/bad-http-signature.json'))) + const mastodonObject = cloneDeep(readJsonSync(buildAbsoluteFixturePath('./ap-json/mastodon/bad-http-signature.json'))) req.body = mastodonObject.body req.headers = mastodonObject.headers const parsed = parseHTTPSignature(req, 3600 * 1000 * 365 * 10) - const publicKey = require(buildAbsoluteFixturePath('./ap-json/mastodon/public-key.json')).publicKey + const publicKey = readJsonSync(buildAbsoluteFixturePath('./ap-json/mastodon/public-key.json')).publicKey const actor = { publicKey } const verified = isHTTPSignatureVerified(parsed, actor as any) @@ -92,12 +101,12 @@ describe('Test activity pub helpers', function () { req.method = 'POST' req.url = '/accounts/ronan/inbox' - const mastodonObject = cloneDeep(require(buildAbsoluteFixturePath('./ap-json/mastodon/http-signature.json'))) + const mastodonObject = cloneDeep(readJsonSync(buildAbsoluteFixturePath('./ap-json/mastodon/http-signature.json'))) req.body = mastodonObject.body req.headers = mastodonObject.headers const parsed = parseHTTPSignature(req, 3600 * 1000 * 365 * 10) - const publicKey = require(buildAbsoluteFixturePath('./ap-json/mastodon/bad-public-key.json')).publicKey + const publicKey = readJsonSync(buildAbsoluteFixturePath('./ap-json/mastodon/bad-public-key.json')).publicKey const actor = { publicKey } const verified = isHTTPSignatureVerified(parsed, actor as any) @@ -110,7 +119,7 @@ describe('Test activity pub helpers', function () { req.method = 'POST' req.url = '/accounts/ronan/inbox' - const mastodonObject = cloneDeep(require(buildAbsoluteFixturePath('./ap-json/mastodon/http-signature.json'))) + const mastodonObject = cloneDeep(readJsonSync(buildAbsoluteFixturePath('./ap-json/mastodon/http-signature.json'))) req.body = mastodonObject.body req.headers = mastodonObject.headers @@ -129,7 +138,7 @@ describe('Test activity pub helpers', function () { req.method = 'POST' req.url = '/accounts/ronan/inbox' - const mastodonObject = cloneDeep(require(buildAbsoluteFixturePath('./ap-json/mastodon/http-signature.json'))) + const mastodonObject = cloneDeep(readJsonSync(buildAbsoluteFixturePath('./ap-json/mastodon/http-signature.json'))) req.body = mastodonObject.body req.headers = mastodonObject.headers req.headers = 'Signature ' + mastodonObject.headers @@ -149,12 +158,12 @@ describe('Test activity pub helpers', function () { req.method = 'POST' req.url = '/accounts/ronan/inbox' - const mastodonObject = cloneDeep(require(buildAbsoluteFixturePath('./ap-json/mastodon/http-signature.json'))) + const mastodonObject = cloneDeep(readJsonSync(buildAbsoluteFixturePath('./ap-json/mastodon/http-signature.json'))) req.body = mastodonObject.body req.headers = mastodonObject.headers const parsed = parseHTTPSignature(req, 3600 * 1000 * 365 * 10) - const publicKey = require(buildAbsoluteFixturePath('./ap-json/mastodon/public-key.json')).publicKey + const publicKey = readJsonSync(buildAbsoluteFixturePath('./ap-json/mastodon/public-key.json')).publicKey const actor = { publicKey } const verified = isHTTPSignatureVerified(parsed, actor as any) diff --git a/server/tests/helpers/core-utils.ts b/packages/tests/src/server-helpers/core-utils.ts similarity index 95% rename from server/tests/helpers/core-utils.ts rename to packages/tests/src/server-helpers/core-utils.ts index cd2f07e4a..06c78591e 100644 --- a/server/tests/helpers/core-utils.ts +++ b/packages/tests/src/server-helpers/core-utils.ts @@ -1,11 +1,11 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { snakeCase } from 'lodash' +import snakeCase from 'lodash-es/snakeCase.js' import validator from 'validator' -import { getAverageTheoreticalBitrate, getMaxTheoreticalBitrate } from '@shared/core-utils' -import { VideoResolution } from '@shared/models' -import { objectConverter, parseBytes, parseDurationToMs } from '../../helpers/core-utils' +import { getAverageTheoreticalBitrate, getMaxTheoreticalBitrate } from '@peertube/peertube-core-utils' +import { VideoResolution } from '@peertube/peertube-models' +import { objectConverter, parseBytes, parseDurationToMs } from '@peertube/peertube-server/server/helpers/core-utils.js' describe('Parse Bytes', function () { @@ -72,7 +72,7 @@ describe('Object', function () { } function valueConverter (v: any) { - if (validator.isNumeric(v + '')) return parseInt('' + v, 10) + if (validator.default.isNumeric(v + '')) return parseInt('' + v, 10) return v } diff --git a/server/tests/helpers/crypto.ts b/packages/tests/src/server-helpers/crypto.ts similarity index 89% rename from server/tests/helpers/crypto.ts rename to packages/tests/src/server-helpers/crypto.ts index b508c715b..4bf5b8a45 100644 --- a/server/tests/helpers/crypto.ts +++ b/packages/tests/src/server-helpers/crypto.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { decrypt, encrypt } from '@server/helpers/peertube-crypto' +import { decrypt, encrypt } from '@peertube/peertube-server/server/helpers/peertube-crypto.js' describe('Encrypt/Descrypt', function () { diff --git a/server/tests/helpers/dns.ts b/packages/tests/src/server-helpers/dns.ts similarity index 86% rename from server/tests/helpers/dns.ts rename to packages/tests/src/server-helpers/dns.ts index 49b506e7b..64e3112a2 100644 --- a/server/tests/helpers/dns.ts +++ b/packages/tests/src/server-helpers/dns.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { isResolvingToUnicastOnly } from '@server/helpers/dns' +import { isResolvingToUnicastOnly } from '@peertube/peertube-server/server/helpers/dns.js' describe('DNS helpers', function () { diff --git a/server/tests/helpers/image.ts b/packages/tests/src/server-helpers/image.ts similarity index 91% rename from server/tests/helpers/image.ts rename to packages/tests/src/server-helpers/image.ts index 6021ffc48..34675d385 100644 --- a/server/tests/helpers/image.ts +++ b/packages/tests/src/server-helpers/image.ts @@ -1,11 +1,12 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { readFile, remove } from 'fs-extra' +import { remove } from 'fs-extra/esm' +import { readFile } from 'fs/promises' import { join } from 'path' -import { execPromise } from '@server/helpers/core-utils' -import { buildAbsoluteFixturePath, root } from '@shared/core-utils' -import { processImage } from '../../../server/helpers/image-utils' +import { buildAbsoluteFixturePath, root } from '@peertube/peertube-node-utils' +import { execPromise } from '@peertube/peertube-server/server/helpers/core-utils.js' +import { processImage } from '@peertube/peertube-server/server/helpers/image-utils.js' async function checkBuffers (path1: string, path2: string, equals: boolean) { const [ buf1, buf2 ] = await Promise.all([ diff --git a/packages/tests/src/server-helpers/index.ts b/packages/tests/src/server-helpers/index.ts new file mode 100644 index 000000000..04a26560c --- /dev/null +++ b/packages/tests/src/server-helpers/index.ts @@ -0,0 +1,10 @@ +import './activitypub.js' +import './core-utils.js' +import './crypto.js' +import './dns.js' +import './image.js' +import './markdown.js' +import './mentions.js' +import './request.js' +import './validator.js' +import './version.js' diff --git a/server/tests/helpers/markdown.ts b/packages/tests/src/server-helpers/markdown.ts similarity index 91% rename from server/tests/helpers/markdown.ts rename to packages/tests/src/server-helpers/markdown.ts index 6fab31d6f..96e3c34dc 100644 --- a/server/tests/helpers/markdown.ts +++ b/packages/tests/src/server-helpers/markdown.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { mdToOneLinePlainText } from '@server/helpers/markdown' +import { mdToOneLinePlainText } from '@peertube/peertube-server/server/helpers/markdown.js' import { expect } from 'chai' describe('Markdown helpers', function () { diff --git a/packages/tests/src/server-helpers/mentions.ts b/packages/tests/src/server-helpers/mentions.ts new file mode 100644 index 000000000..153931d60 --- /dev/null +++ b/packages/tests/src/server-helpers/mentions.ts @@ -0,0 +1,17 @@ +/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ + +import { expect } from 'chai' +import { extractMentions } from '@peertube/peertube-server/server/helpers/mentions.js' + +describe('Comment model', function () { + it('Should correctly extract mentions', async function () { + const text = '@florian @jean@localhost:9000 @flo @another@localhost:9000 @flo2@jean.com hello ' + + 'email@localhost:9000 coucou.com no? @chocobozzz @chocobozzz @end' + + const isOwned = true + + const result = extractMentions(text, isOwned).sort((a, b) => a.localeCompare(b)) + + expect(result).to.deep.equal([ 'another', 'chocobozzz', 'end', 'flo', 'florian', 'jean' ]) + }) +}) diff --git a/server/tests/helpers/request.ts b/packages/tests/src/server-helpers/request.ts similarity index 81% rename from server/tests/helpers/request.ts rename to packages/tests/src/server-helpers/request.ts index 363237df5..f4b9af52e 100644 --- a/server/tests/helpers/request.ts +++ b/packages/tests/src/server-helpers/request.ts @@ -1,11 +1,13 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { pathExists, remove } from 'fs-extra' +import { pathExists, remove } from 'fs-extra/esm' import { join } from 'path' -import { root, wait } from '@shared/core-utils' -import { doRequest, doRequestAndSaveToFile } from '../../helpers/requests' -import { FIXTURE_URLS, Mock429 } from '../shared' +import { wait } from '@peertube/peertube-core-utils' +import { root } from '@peertube/peertube-node-utils' +import { doRequest, doRequestAndSaveToFile } from '@peertube/peertube-server/server/helpers/requests.js' +import { Mock429 } from '@tests/shared/mock-servers/mock-429.js' +import { FIXTURE_URLS } from '@tests/shared/tests.js' describe('Request helpers', function () { const destPath1 = join(root(), 'test-output-1.txt') diff --git a/server/tests/helpers/validator.ts b/packages/tests/src/server-helpers/validator.ts similarity index 90% rename from server/tests/helpers/validator.ts rename to packages/tests/src/server-helpers/validator.ts index f40a3aaae..792bd501c 100644 --- a/server/tests/helpers/validator.ts +++ b/packages/tests/src/server-helpers/validator.ts @@ -1,7 +1,10 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { isPluginStableOrUnstableVersionValid, isPluginStableVersionValid } from '@server/helpers/custom-validators/plugins' +import { + isPluginStableOrUnstableVersionValid, + isPluginStableVersionValid +} from '@peertube/peertube-server/server/helpers/custom-validators/plugins.js' describe('Validators', function () { diff --git a/server/tests/helpers/version.ts b/packages/tests/src/server-helpers/version.ts similarity index 96% rename from server/tests/helpers/version.ts rename to packages/tests/src/server-helpers/version.ts index 2a90efba3..76892d1e7 100644 --- a/server/tests/helpers/version.ts +++ b/packages/tests/src/server-helpers/version.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { compareSemVer } from '@shared/core-utils' +import { compareSemVer } from '@peertube/peertube-core-utils' describe('Version', function () { diff --git a/packages/tests/src/server-lib/index.ts b/packages/tests/src/server-lib/index.ts new file mode 100644 index 000000000..873f53e15 --- /dev/null +++ b/packages/tests/src/server-lib/index.ts @@ -0,0 +1 @@ +export * from './video-constant-registry-factory.js' diff --git a/server/tests/lib/video-constant-registry-factory.ts b/packages/tests/src/server-lib/video-constant-registry-factory.ts similarity index 94% rename from server/tests/lib/video-constant-registry-factory.ts rename to packages/tests/src/server-lib/video-constant-registry-factory.ts index c3480dc12..6bf2d1db6 100644 --- a/server/tests/lib/video-constant-registry-factory.ts +++ b/packages/tests/src/server-lib/video-constant-registry-factory.ts @@ -1,17 +1,14 @@ /* eslint-disable @typescript-eslint/no-unused-expressions */ import { expect } from 'chai' -import { VideoConstantManagerFactory } from '@server/lib/plugins/video-constant-manager-factory' +import { VideoPlaylistPrivacyType, VideoPrivacyType } from '@peertube/peertube-models' import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PLAYLIST_PRIVACIES, VIDEO_PRIVACIES -} from '@server/initializers/constants' -import { - VideoPlaylistPrivacy, - VideoPrivacy -} from '@shared/models' +} from '@peertube/peertube-server/server/initializers/constants.js' +import { VideoConstantManagerFactory } from '@peertube/peertube-server/server/lib/plugins/video-constant-manager-factory.js' describe('VideoConstantManagerFactory', function () { const factory = new VideoConstantManagerFactory('peertube-plugin-constants') @@ -74,7 +71,7 @@ describe('VideoConstantManagerFactory', function () { }) describe('PlaylistPrivacyManager', () => { - const playlistPrivacyManager = factory.createVideoConstantManager('playlistPrivacy') + const playlistPrivacyManager = factory.createVideoConstantManager('playlistPrivacy') it('Should be able to list all video playlist privacy constants', () => { const constants = playlistPrivacyManager.getConstants() expect(constants).to.deep.equal(VIDEO_PLAYLIST_PRIVACIES) @@ -100,7 +97,7 @@ describe('VideoConstantManagerFactory', function () { }) describe('VideoPrivacyManager', () => { - const videoPrivacyManager = factory.createVideoConstantManager('privacy') + const videoPrivacyManager = factory.createVideoConstantManager('privacy') it('Should be able to list all video privacy constants', () => { const constants = videoPrivacyManager.getConstants() expect(constants).to.deep.equal(VIDEO_PRIVACIES) diff --git a/server/tests/shared/actors.ts b/packages/tests/src/shared/actors.ts similarity index 89% rename from server/tests/shared/actors.ts rename to packages/tests/src/shared/actors.ts index 41fd72e89..02d507a49 100644 --- a/server/tests/shared/actors.ts +++ b/packages/tests/src/shared/actors.ts @@ -1,9 +1,10 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { pathExists, readdir } from 'fs-extra' -import { Account, VideoChannel } from '@shared/models' -import { PeerTubeServer } from '@shared/server-commands' +import { pathExists } from 'fs-extra/esm' +import { readdir } from 'fs/promises' +import { Account, VideoChannel } from '@peertube/peertube-models' +import { PeerTubeServer } from '@peertube/peertube-server-commands' async function expectChannelsFollows (options: { server: PeerTubeServer diff --git a/server/tests/shared/captions.ts b/packages/tests/src/shared/captions.ts similarity index 89% rename from server/tests/shared/captions.ts rename to packages/tests/src/shared/captions.ts index 35e722408..436cf8dcc 100644 --- a/server/tests/shared/captions.ts +++ b/packages/tests/src/shared/captions.ts @@ -1,6 +1,6 @@ import { expect } from 'chai' import request from 'supertest' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode } from '@peertube/peertube-models' async function testCaptionFile (url: string, captionPath: string, toTest: RegExp | string) { const res = await request(url) diff --git a/server/tests/shared/checks.ts b/packages/tests/src/shared/checks.ts similarity index 89% rename from server/tests/shared/checks.ts rename to packages/tests/src/shared/checks.ts index 90179c6ac..fea618a30 100644 --- a/server/tests/shared/checks.ts +++ b/packages/tests/src/shared/checks.ts @@ -1,14 +1,12 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */ import { expect } from 'chai' -import { pathExists, readFile } from 'fs-extra' -import JPEG from 'jpeg-js' +import { pathExists } from 'fs-extra/esm' +import { readFile } from 'fs/promises' import { join } from 'path' -import pixelmatch from 'pixelmatch' -import { PNG } from 'pngjs' -import { root } from '@shared/core-utils' -import { HttpStatusCode } from '@shared/models' -import { makeGetRequest, PeerTubeServer } from '@shared/server-commands' +import { HttpStatusCode } from '@peertube/peertube-models' +import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils' +import { makeGetRequest, PeerTubeServer } from '@peertube/peertube-server-commands' // Default interval -> 5 minutes function dateIsValid (dateString: string | Date, interval = 300000) { @@ -53,7 +51,7 @@ async function testImageSize (url: string, imageName: string, imageHTTPPath: str const body = res.body - const data = await readFile(join(root(), 'server', 'tests', 'fixtures', imageName + extension)) + const data = await readFile(buildAbsoluteFixturePath(imageName + extension)) const minLength = data.length - ((40 * data.length) / 100) const maxLength = data.length + ((40 * data.length) / 100) @@ -66,6 +64,7 @@ async function testImageGeneratedByFFmpeg (url: string, imageName: string, image console.log( 'Pixel comparison of image generated by ffmpeg is disabled. ' + 'You can enable it using `ENABLE_FFMPEG_THUMBNAIL_PIXEL_COMPARISON_TESTS=true env variable') + return } return testImage(url, imageName, imageHTTPPath, extension) @@ -79,7 +78,11 @@ async function testImage (url: string, imageName: string, imageHTTPPath: string, }) const body = res.body - const data = await readFile(join(root(), 'server', 'tests', 'fixtures', imageName + extension)) + const data = await readFile(buildAbsoluteFixturePath(imageName + extension)) + + const { PNG } = await import('pngjs') + const JPEG = await import('jpeg-js') + const pixelmatch = (await import('pixelmatch')).default const img1 = imageHTTPPath.endsWith('.png') ? PNG.sync.read(body) diff --git a/server/tests/shared/directories.ts b/packages/tests/src/shared/directories.ts similarity index 90% rename from server/tests/shared/directories.ts rename to packages/tests/src/shared/directories.ts index 5ad12d78a..f21e7b7c6 100644 --- a/server/tests/shared/directories.ts +++ b/packages/tests/src/shared/directories.ts @@ -1,11 +1,12 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { pathExists, readdir } from 'fs-extra' +import { pathExists } from 'fs-extra/esm' +import { readdir } from 'fs/promises' import { homedir } from 'os' import { join } from 'path' -import { PeerTubeServer } from '@shared/server-commands' -import { PeerTubeRunnerProcess } from './peertube-runner-process' +import { PeerTubeServer } from '@peertube/peertube-server-commands' +import { PeerTubeRunnerProcess } from './peertube-runner-process.js' export async function checkTmpIsEmpty (server: PeerTubeServer) { await checkDirectoryIsEmpty(server, 'tmp', [ 'plugins-global.css', 'hls', 'resumable-uploads' ]) diff --git a/server/tests/shared/generate.ts b/packages/tests/src/shared/generate.ts similarity index 86% rename from server/tests/shared/generate.ts rename to packages/tests/src/shared/generate.ts index 3788b049f..ab2ecaf40 100644 --- a/server/tests/shared/generate.ts +++ b/packages/tests/src/shared/generate.ts @@ -1,9 +1,9 @@ import { expect } from 'chai' -import ffmpeg from 'fluent-ffmpeg' -import { ensureDir, pathExists } from 'fs-extra' +import { ensureDir, pathExists } from 'fs-extra/esm' import { dirname } from 'path' -import { buildAbsoluteFixturePath, getMaxTheoreticalBitrate } from '@shared/core-utils' -import { getVideoStreamBitrate, getVideoStreamDimensionsInfo, getVideoStreamFPS } from '@shared/ffmpeg' +import { getMaxTheoreticalBitrate } from '@peertube/peertube-core-utils' +import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils' +import { getVideoStreamBitrate, getVideoStreamDimensionsInfo, getVideoStreamFPS } from '@peertube/peertube-ffmpeg' async function ensureHasTooBigBitrate (fixturePath: string) { const bitrate = await getVideoStreamBitrate(fixturePath) @@ -20,7 +20,10 @@ async function generateHighBitrateVideo () { await ensureDir(dirname(tempFixturePath)) const exists = await pathExists(tempFixturePath) + if (!exists) { + const ffmpeg = (await import('fluent-ffmpeg')).default + console.log('Generating high bitrate video.') // Generate a random, high bitrate video on the fly, so we don't have to include @@ -51,6 +54,8 @@ async function generateVideoWithFramerate (fps = 60) { const exists = await pathExists(tempFixturePath) if (!exists) { + const ffmpeg = (await import('fluent-ffmpeg')).default + console.log('Generating video with framerate %d.', fps) return new Promise((res, rej) => { diff --git a/server/tests/shared/live.ts b/packages/tests/src/shared/live.ts similarity index 93% rename from server/tests/shared/live.ts rename to packages/tests/src/shared/live.ts index 9d8c1d941..9c7991b0d 100644 --- a/server/tests/shared/live.ts +++ b/packages/tests/src/shared/live.ts @@ -1,13 +1,14 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { pathExists, readdir } from 'fs-extra' +import { pathExists } from 'fs-extra/esm' +import { readdir } from 'fs/promises' import { join } from 'path' -import { sha1 } from '@shared/extra-utils' -import { LiveVideo, VideoStreamingPlaylistType } from '@shared/models' -import { ObjectStorageCommand, PeerTubeServer } from '@shared/server-commands' -import { SQLCommand } from './sql-command' -import { checkLiveSegmentHash, checkResolutionsInMasterPlaylist } from './streaming-playlists' +import { sha1 } from '@peertube/peertube-node-utils' +import { LiveVideo, VideoStreamingPlaylistType } from '@peertube/peertube-models' +import { ObjectStorageCommand, PeerTubeServer } from '@peertube/peertube-server-commands' +import { SQLCommand } from './sql-command.js' +import { checkLiveSegmentHash, checkResolutionsInMasterPlaylist } from './streaming-playlists.js' async function checkLiveCleanup (options: { server: PeerTubeServer diff --git a/packages/tests/src/shared/mock-servers/index.ts b/packages/tests/src/shared/mock-servers/index.ts new file mode 100644 index 000000000..9d1c63c67 --- /dev/null +++ b/packages/tests/src/shared/mock-servers/index.ts @@ -0,0 +1,8 @@ +export * from './mock-429.js' +export * from './mock-email.js' +export * from './mock-http.js' +export * from './mock-instances-index.js' +export * from './mock-joinpeertube-versions.js' +export * from './mock-object-storage.js' +export * from './mock-plugin-blocklist.js' +export * from './mock-proxy.js' diff --git a/server/tests/shared/mock-servers/mock-429.ts b/packages/tests/src/shared/mock-servers/mock-429.ts similarity index 99% rename from server/tests/shared/mock-servers/mock-429.ts rename to packages/tests/src/shared/mock-servers/mock-429.ts index 1fc20b079..5fcb1447d 100644 --- a/server/tests/shared/mock-servers/mock-429.ts +++ b/packages/tests/src/shared/mock-servers/mock-429.ts @@ -1,6 +1,6 @@ import express from 'express' import { Server } from 'http' -import { getPort, randomListen, terminateServer } from './shared' +import { getPort, randomListen, terminateServer } from './shared.js' export class Mock429 { private server: Server diff --git a/server/tests/shared/mock-servers/mock-email.ts b/packages/tests/src/shared/mock-servers/mock-email.ts similarity index 90% rename from server/tests/shared/mock-servers/mock-email.ts rename to packages/tests/src/shared/mock-servers/mock-email.ts index 6eda2dfda..7c618e57f 100644 --- a/server/tests/shared/mock-servers/mock-email.ts +++ b/packages/tests/src/shared/mock-servers/mock-email.ts @@ -1,5 +1,6 @@ import MailDev from '@peertube/maildev' -import { parallelTests, randomInt } from '@shared/core-utils' +import { randomInt } from '@peertube/peertube-core-utils' +import { parallelTests } from '@peertube/peertube-node-utils' class MockSmtpServer { diff --git a/server/tests/shared/mock-servers/mock-http.ts b/packages/tests/src/shared/mock-servers/mock-http.ts similarity index 99% rename from server/tests/shared/mock-servers/mock-http.ts rename to packages/tests/src/shared/mock-servers/mock-http.ts index b7a019e07..bc1a9ce91 100644 --- a/server/tests/shared/mock-servers/mock-http.ts +++ b/packages/tests/src/shared/mock-servers/mock-http.ts @@ -1,6 +1,6 @@ import express from 'express' import { Server } from 'http' -import { getPort, randomListen, terminateServer } from './shared' +import { getPort, randomListen, terminateServer } from './shared.js' export class MockHTTP { private server: Server diff --git a/server/tests/shared/mock-servers/mock-instances-index.ts b/packages/tests/src/shared/mock-servers/mock-instances-index.ts similarity index 99% rename from server/tests/shared/mock-servers/mock-instances-index.ts rename to packages/tests/src/shared/mock-servers/mock-instances-index.ts index 598b007f1..a21367358 100644 --- a/server/tests/shared/mock-servers/mock-instances-index.ts +++ b/packages/tests/src/shared/mock-servers/mock-instances-index.ts @@ -1,6 +1,6 @@ import express from 'express' import { Server } from 'http' -import { getPort, randomListen, terminateServer } from './shared' +import { getPort, randomListen, terminateServer } from './shared.js' export class MockInstancesIndex { private server: Server diff --git a/server/tests/shared/mock-servers/mock-joinpeertube-versions.ts b/packages/tests/src/shared/mock-servers/mock-joinpeertube-versions.ts similarity index 93% rename from server/tests/shared/mock-servers/mock-joinpeertube-versions.ts rename to packages/tests/src/shared/mock-servers/mock-joinpeertube-versions.ts index 502f4e2f5..0783165e4 100644 --- a/server/tests/shared/mock-servers/mock-joinpeertube-versions.ts +++ b/packages/tests/src/shared/mock-servers/mock-joinpeertube-versions.ts @@ -1,6 +1,6 @@ import express from 'express' import { Server } from 'http' -import { getPort, randomListen } from './shared' +import { getPort, randomListen } from './shared.js' export class MockJoinPeerTubeVersions { private server: Server diff --git a/server/tests/shared/mock-servers/mock-object-storage.ts b/packages/tests/src/shared/mock-servers/mock-object-storage.ts similarity index 93% rename from server/tests/shared/mock-servers/mock-object-storage.ts rename to packages/tests/src/shared/mock-servers/mock-object-storage.ts index ae76c4f3f..f97c57fd7 100644 --- a/server/tests/shared/mock-servers/mock-object-storage.ts +++ b/packages/tests/src/shared/mock-servers/mock-object-storage.ts @@ -2,8 +2,8 @@ import express from 'express' import got, { RequestError } from 'got' import { Server } from 'http' import { pipeline } from 'stream' -import { ObjectStorageCommand } from '@shared/server-commands' -import { getPort, randomListen, terminateServer } from './shared' +import { ObjectStorageCommand } from '@peertube/peertube-server-commands' +import { getPort, randomListen, terminateServer } from './shared.js' export class MockObjectStorageProxy { private server: Server diff --git a/server/tests/shared/mock-servers/mock-plugin-blocklist.ts b/packages/tests/src/shared/mock-servers/mock-plugin-blocklist.ts similarity index 99% rename from server/tests/shared/mock-servers/mock-plugin-blocklist.ts rename to packages/tests/src/shared/mock-servers/mock-plugin-blocklist.ts index 5d6e01816..c0b6518ba 100644 --- a/server/tests/shared/mock-servers/mock-plugin-blocklist.ts +++ b/packages/tests/src/shared/mock-servers/mock-plugin-blocklist.ts @@ -1,6 +1,6 @@ import express, { Request, Response } from 'express' import { Server } from 'http' -import { getPort, randomListen, terminateServer } from './shared' +import { getPort, randomListen, terminateServer } from './shared.js' type BlocklistResponse = { data: { diff --git a/server/tests/shared/mock-servers/mock-proxy.ts b/packages/tests/src/shared/mock-servers/mock-proxy.ts similarity index 89% rename from server/tests/shared/mock-servers/mock-proxy.ts rename to packages/tests/src/shared/mock-servers/mock-proxy.ts index e741d6735..e731670d8 100644 --- a/server/tests/shared/mock-servers/mock-proxy.ts +++ b/packages/tests/src/shared/mock-servers/mock-proxy.ts @@ -1,6 +1,6 @@ import { createServer, Server } from 'http' import { createProxy } from 'proxy' -import { getPort, terminateServer } from './shared' +import { getPort, terminateServer } from './shared.js' class MockProxy { private server: Server diff --git a/server/tests/shared/mock-servers/shared.ts b/packages/tests/src/shared/mock-servers/shared.ts similarity index 100% rename from server/tests/shared/mock-servers/shared.ts rename to packages/tests/src/shared/mock-servers/shared.ts diff --git a/server/tests/shared/notifications.ts b/packages/tests/src/shared/notifications.ts similarity index 99% rename from server/tests/shared/notifications.ts rename to packages/tests/src/shared/notifications.ts index 6c0688d5a..3accd7322 100644 --- a/server/tests/shared/notifications.ts +++ b/packages/tests/src/shared/notifications.ts @@ -1,26 +1,27 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { expect } from 'chai' -import { inspect } from 'util' import { AbuseState, - PluginType, + AbuseStateType, + PluginType_Type, UserNotification, UserNotificationSetting, UserNotificationSettingValue, UserNotificationType -} from '@shared/models' +} from '@peertube/peertube-models' import { ConfigCommand, + PeerTubeServer, createMultipleServers, doubleFollow, - PeerTubeServer, setAccessTokensToServers, setDefaultAccountAvatar, setDefaultChannelAvatar, setDefaultVideoChannel -} from '@shared/server-commands' -import { MockSmtpServer } from './mock-servers' +} from '@peertube/peertube-server-commands' +import { expect } from 'chai' +import { inspect } from 'util' +import { MockSmtpServer } from './mock-servers/index.js' type CheckerBaseParams = { server: PeerTubeServer @@ -483,7 +484,7 @@ async function checkNewAbuseMessage (options: CheckerBaseParams & { async function checkAbuseStateChange (options: CheckerBaseParams & { abuseId: number - state: AbuseState + state: AbuseStateType checkType: CheckerType }) { const { abuseId, state } = options @@ -667,7 +668,7 @@ async function checkNewPeerTubeVersion (options: CheckerBaseParams & { } async function checkNewPluginVersion (options: CheckerBaseParams & { - pluginType: PluginType + pluginType: PluginType_Type pluginName: string checkType: CheckerType }) { @@ -774,10 +775,11 @@ async function prepareNotificationsTest (serversCount = 3, overrideConfigArg: an // --------------------------------------------------------------------------- export { + type CheckerType, + type CheckerBaseParams, + getAllNotificationsSettings, - CheckerBaseParams, - CheckerType, checkMyVideoImportIsFinished, checkUserRegistered, checkAutoInstanceFollowing, diff --git a/server/tests/shared/peertube-runner-process.ts b/packages/tests/src/shared/peertube-runner-process.ts similarity index 72% rename from server/tests/shared/peertube-runner-process.ts rename to packages/tests/src/shared/peertube-runner-process.ts index 9304ebcc8..3d1f299f2 100644 --- a/server/tests/shared/peertube-runner-process.ts +++ b/packages/tests/src/shared/peertube-runner-process.ts @@ -1,8 +1,8 @@ -import { ChildProcess, fork } from 'child_process' +import { ChildProcess, fork, ForkOptions } from 'child_process' import execa from 'execa' import { join } from 'path' -import { root } from '@shared/core-utils' -import { PeerTubeServer } from '@shared/server-commands' +import { root } from '@peertube/peertube-node-utils' +import { PeerTubeServer } from '@peertube/peertube-server-commands' export class PeerTubeRunnerProcess { private app?: ChildProcess @@ -19,10 +19,12 @@ export class PeerTubeRunnerProcess { return new Promise((res, rej) => { const args = [ 'server', '--verbose', ...this.buildIdArg() ] - const forkOptions = { + const forkOptions: ForkOptions = { detached: false, - silent: true + silent: true, + execArgv: [] // Don't inject parent node options } + this.app = fork(this.getRunnerPath(), args, forkOptions) this.app.stdout.on('data', data => { @@ -57,7 +59,7 @@ export class PeerTubeRunnerProcess { args.push(runnerDescription) } - return execa.node(this.getRunnerPath(), args) + return this.runCommand(this.getRunnerPath(), args) } unregisterPeerTubeInstance (options: { @@ -66,12 +68,12 @@ export class PeerTubeRunnerProcess { const { runnerName } = options const args = [ 'unregister', '--url', this.server.url, '--runner-name', runnerName, ...this.buildIdArg() ] - return execa.node(this.getRunnerPath(), args) + return this.runCommand(this.getRunnerPath(), args) } async listRegisteredPeerTubeInstances () { const args = [ 'list-registered', ...this.buildIdArg() ] - const { stdout } = await execa.node(this.getRunnerPath(), args) + const { stdout } = await this.runCommand(this.getRunnerPath(), args) return stdout } @@ -89,10 +91,14 @@ export class PeerTubeRunnerProcess { } private getRunnerPath () { - return join(root(), 'packages', 'peertube-runner', 'dist', 'peertube-runner.js') + return join(root(), 'apps', 'peertube-runner', 'dist', 'peertube-runner.js') } private buildIdArg () { return [ '--id', this.getId() ] } + + private runCommand (path: string, args: string[]) { + return execa.node(path, args, { env: { ...process.env, NODE_OPTIONS: '' } }) + } } diff --git a/server/tests/shared/plugins.ts b/packages/tests/src/shared/plugins.ts similarity index 89% rename from server/tests/shared/plugins.ts rename to packages/tests/src/shared/plugins.ts index 036fce2ff..c2afcbcbf 100644 --- a/server/tests/shared/plugins.ts +++ b/packages/tests/src/shared/plugins.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import { expect } from 'chai' -import { PeerTubeServer } from '@shared/server-commands' +import { PeerTubeServer } from '@peertube/peertube-server-commands' async function testHelloWorldRegisteredSettings (server: PeerTubeServer) { const body = await server.plugins.getRegisteredSettings({ npmName: 'peertube-plugin-hello-world' }) diff --git a/server/tests/shared/requests.ts b/packages/tests/src/shared/requests.ts similarity index 74% rename from server/tests/shared/requests.ts rename to packages/tests/src/shared/requests.ts index 0cfeab7b2..fc70ad6ed 100644 --- a/server/tests/shared/requests.ts +++ b/packages/tests/src/shared/requests.ts @@ -1,4 +1,4 @@ -import { doRequest } from '@server/helpers/requests' +import { doRequest } from '@peertube/peertube-server/server/helpers/requests.js' export function makePOSTAPRequest (url: string, body: any, httpSignature: any, headers: any) { const options = { diff --git a/server/tests/shared/sql-command.ts b/packages/tests/src/shared/sql-command.ts similarity index 97% rename from server/tests/shared/sql-command.ts rename to packages/tests/src/shared/sql-command.ts index 5c53a8ac6..1c4f89351 100644 --- a/server/tests/shared/sql-command.ts +++ b/packages/tests/src/shared/sql-command.ts @@ -1,6 +1,6 @@ import { QueryTypes, Sequelize } from 'sequelize' -import { forceNumber } from '@shared/core-utils' -import { PeerTubeServer } from '@shared/server-commands' +import { forceNumber } from '@peertube/peertube-core-utils' +import { PeerTubeServer } from '@peertube/peertube-server-commands' export class SQLCommand { private sequelize: Sequelize diff --git a/server/tests/shared/streaming-playlists.ts b/packages/tests/src/shared/streaming-playlists.ts similarity index 95% rename from server/tests/shared/streaming-playlists.ts rename to packages/tests/src/shared/streaming-playlists.ts index e4f88bc25..f2f0fbe85 100644 --- a/server/tests/shared/streaming-playlists.ts +++ b/packages/tests/src/shared/streaming-playlists.ts @@ -2,13 +2,19 @@ import { expect } from 'chai' import { basename, dirname, join } from 'path' -import { removeFragmentedMP4Ext, uuidRegex } from '@shared/core-utils' -import { sha256 } from '@shared/extra-utils' -import { HttpStatusCode, VideoPrivacy, VideoResolution, VideoStreamingPlaylist, VideoStreamingPlaylistType } from '@shared/models' -import { makeRawRequest, PeerTubeServer } from '@shared/server-commands' -import { expectStartWith } from './checks' -import { hlsInfohashExist } from './tracker' -import { checkWebTorrentWorks } from './webtorrent' +import { removeFragmentedMP4Ext, uuidRegex } from '@peertube/peertube-core-utils' +import { + HttpStatusCode, + VideoPrivacy, + VideoResolution, + VideoStreamingPlaylist, + VideoStreamingPlaylistType +} from '@peertube/peertube-models' +import { sha256 } from '@peertube/peertube-node-utils' +import { makeRawRequest, PeerTubeServer } from '@peertube/peertube-server-commands' +import { expectStartWith } from './checks.js' +import { hlsInfohashExist } from './tracker.js' +import { checkWebTorrentWorks } from './webtorrent.js' async function checkSegmentHash (options: { server: PeerTubeServer diff --git a/server/tests/shared/tests.ts b/packages/tests/src/shared/tests.ts similarity index 100% rename from server/tests/shared/tests.ts rename to packages/tests/src/shared/tests.ts diff --git a/server/tests/shared/tracker.ts b/packages/tests/src/shared/tracker.ts similarity index 85% rename from server/tests/shared/tracker.ts rename to packages/tests/src/shared/tracker.ts index 9c1f0246a..6ab430456 100644 --- a/server/tests/shared/tracker.ts +++ b/packages/tests/src/shared/tracker.ts @@ -1,6 +1,6 @@ import { expect } from 'chai' -import { sha1 } from '@shared/extra-utils' -import { makeGetRequest } from '@shared/server-commands' +import { sha1 } from '@peertube/peertube-node-utils' +import { makeGetRequest } from '@peertube/peertube-server-commands' async function hlsInfohashExist (serverUrl: string, masterPlaylistUrl: string, fileNumber: number) { const path = '/tracker/announce' diff --git a/server/tests/shared/video-playlists.ts b/packages/tests/src/shared/video-playlists.ts similarity index 80% rename from server/tests/shared/video-playlists.ts rename to packages/tests/src/shared/video-playlists.ts index 8db303fd8..81dc43ed6 100644 --- a/server/tests/shared/video-playlists.ts +++ b/packages/tests/src/shared/video-playlists.ts @@ -1,6 +1,6 @@ import { expect } from 'chai' -import { readdir } from 'fs-extra' -import { PeerTubeServer } from '@shared/server-commands' +import { readdir } from 'fs/promises' +import { PeerTubeServer } from '@peertube/peertube-server-commands' async function checkPlaylistFilesWereRemoved ( playlistUUID: string, diff --git a/server/tests/shared/videos.ts b/packages/tests/src/shared/videos.ts similarity index 93% rename from server/tests/shared/videos.ts rename to packages/tests/src/shared/videos.ts index ac24bb173..9bdcbf058 100644 --- a/server/tests/shared/videos.ts +++ b/packages/tests/src/shared/videos.ts @@ -1,16 +1,22 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */ import { expect } from 'chai' -import { pathExists, readdir } from 'fs-extra' +import { pathExists } from 'fs-extra/esm' +import { readdir } from 'fs/promises' import { basename, join } from 'path' -import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '@server/initializers/constants' -import { getLowercaseExtension, pick, uuidRegex } from '@shared/core-utils' -import { HttpStatusCode, VideoCaption, VideoDetails, VideoPrivacy, VideoResolution } from '@shared/models' -import { makeRawRequest, PeerTubeServer, VideoEdit, waitJobs } from '@shared/server-commands' -import { dateIsValid, expectStartWith, testImageGeneratedByFFmpeg } from './checks' -import { checkWebTorrentWorks } from './webtorrent' - -loadLanguages() +import { pick, uuidRegex } from '@peertube/peertube-core-utils' +import { HttpStatusCode, HttpStatusCodeType, VideoCaption, VideoDetails, VideoPrivacy, VideoResolution } from '@peertube/peertube-models' +import { + loadLanguages, + VIDEO_CATEGORIES, + VIDEO_LANGUAGES, + VIDEO_LICENCES, + VIDEO_PRIVACIES +} from '@peertube/peertube-server/server/initializers/constants.js' +import { getLowercaseExtension } from '@peertube/peertube-node-utils' +import { makeRawRequest, PeerTubeServer, VideoEdit, waitJobs } from '@peertube/peertube-server-commands' +import { dateIsValid, expectStartWith, testImageGeneratedByFFmpeg } from './checks.js' +import { checkWebTorrentWorks } from './webtorrent.js' async function completeWebVideoFilesCheck (options: { server: PeerTubeServer @@ -144,6 +150,8 @@ async function completeVideoCheck (options: { }) { const { attributes, originServer, server, videoUUID } = options + await loadLanguages() + const video = await server.videos.get({ id: videoUUID }) if (!attributes.likes) attributes.likes = 0 @@ -192,7 +200,7 @@ async function completeVideoCheck (options: { expect(video.channel.name).to.equal(attributes.channel.name) expect(video.channel.host).to.equal(attributes.account.host) expect(video.channel.isLocal).to.equal(attributes.channel.isLocal) - expect(dateIsValid(video.channel.createdAt.toString())).to.be.true + expect(video.channel.createdAt).to.exist expect(dateIsValid(video.channel.updatedAt.toString())).to.be.true expect(video.commentsEnabled).to.equal(attributes.commentsEnabled) expect(video.downloadEnabled).to.equal(attributes.downloadEnabled) @@ -272,8 +280,8 @@ function checkUploadVideoParam (options: { server: PeerTubeServer token: string attributes: Partial - expectedStatus?: HttpStatusCode - completedExpectedStatus?: HttpStatusCode + expectedStatus?: HttpStatusCodeType + completedExpectedStatus?: HttpStatusCodeType mode?: 'legacy' | 'resumable' }) { const { server, token, attributes, completedExpectedStatus, expectedStatus, mode = 'legacy' } = options diff --git a/server/tests/shared/views.ts b/packages/tests/src/shared/views.ts similarity index 90% rename from server/tests/shared/views.ts rename to packages/tests/src/shared/views.ts index e6b289715..b791eff25 100644 --- a/server/tests/shared/views.ts +++ b/packages/tests/src/shared/views.ts @@ -1,6 +1,6 @@ -import { FfmpegCommand } from 'fluent-ffmpeg' -import { wait } from '@shared/core-utils' -import { VideoCreateResult, VideoPrivacy } from '@shared/models' +import type { FfmpegCommand } from 'fluent-ffmpeg' +import { wait } from '@peertube/peertube-core-utils' +import { VideoCreateResult, VideoPrivacy } from '@peertube/peertube-models' import { createMultipleServers, doubleFollow, @@ -9,7 +9,7 @@ import { setDefaultVideoChannel, waitJobs, waitUntilLivePublishedOnAllServers -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' async function processViewersStats (servers: PeerTubeServer[]) { await wait(6000) diff --git a/server/tests/shared/webtorrent.ts b/packages/tests/src/shared/webtorrent.ts similarity index 78% rename from server/tests/shared/webtorrent.ts rename to packages/tests/src/shared/webtorrent.ts index d5bd86500..1be54426a 100644 --- a/server/tests/shared/webtorrent.ts +++ b/packages/tests/src/shared/webtorrent.ts @@ -1,12 +1,12 @@ import { expect } from 'chai' -import { readFile } from 'fs-extra' +import { readFile } from 'fs/promises' import parseTorrent from 'parse-torrent' import { basename, join } from 'path' -import * as WebTorrent from 'webtorrent' -import { VideoFile } from '@shared/models' -import { PeerTubeServer } from '@shared/server-commands' +import type { Instance, Torrent } from 'webtorrent' +import { VideoFile } from '@peertube/peertube-models' +import { PeerTubeServer } from '@peertube/peertube-server-commands' -let webtorrent: WebTorrent.Instance +let webtorrent: Instance export async function checkWebTorrentWorks (magnetUri: string, pathMatch?: RegExp) { const torrent = await webtorrentAdd(magnetUri, true) @@ -33,15 +33,15 @@ export async function parseTorrentVideo (server: PeerTubeServer, file: VideoFile // Private // --------------------------------------------------------------------------- -function webtorrentAdd (torrentId: string, refreshWebTorrent = false) { - const WebTorrent = require('webtorrent') +async function webtorrentAdd (torrentId: string, refreshWebTorrent = false) { + const WebTorrent = (await import('webtorrent')).default if (webtorrent && refreshWebTorrent) webtorrent.destroy() if (!webtorrent || refreshWebTorrent) webtorrent = new WebTorrent() webtorrent.on('error', err => console.error('Error in webtorrent', err)) - return new Promise(res => { + return new Promise(res => { const torrent = webtorrent.add(torrentId, res) torrent.on('error', err => console.error('Error in webtorrent torrent', err)) diff --git a/packages/tests/tsconfig.json b/packages/tests/tsconfig.json new file mode 100644 index 000000000..91a74b4be --- /dev/null +++ b/packages/tests/tsconfig.json @@ -0,0 +1,27 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./dist", + "baseUrl": "./", + "rootDir": "src", + "tsBuildInfoFile": "./dist/.tsbuildinfo", + "paths": { + "@tests/*": [ "src/*" ] + } + }, + "references": [ + { "path": "../core-utils" }, + { "path": "../ffmpeg" }, + { "path": "../models" }, + { "path": "../node-utils" }, + { "path": "../typescript-utils" }, + { "path": "../server-commands" }, + { "path": "../../server/tsconfig.lib.json" } + ], + "include": [ + "./src/**/*.ts" + ], + "exclude": [ + "./fixtures" + ] +} diff --git a/packages/types/README.md b/packages/types-generator/README.md similarity index 100% rename from packages/types/README.md rename to packages/types-generator/README.md diff --git a/packages/types/generate-package.ts b/packages/types-generator/generate-package.ts similarity index 84% rename from packages/types/generate-package.ts rename to packages/types-generator/generate-package.ts index 125259bb4..2b2f51623 100644 --- a/packages/types/generate-package.ts +++ b/packages/types-generator/generate-package.ts @@ -1,8 +1,9 @@ import { execSync } from 'child_process' import depcheck, { PackageDependencies } from 'depcheck' -import { copyFile, readJson, remove, writeFile, writeJSON } from 'fs-extra' +import { readJson, remove, writeJSON } from 'fs-extra/esm' +import { copyFile, writeFile } from 'fs/promises' import { join, resolve } from 'path' -import { root } from '../../shared/core-utils' +import { currentDir, root } from '@peertube/peertube-node-utils' if (!process.argv[2]) { console.error('Need version as argument') @@ -20,17 +21,25 @@ run() }) async function run () { - const typesPath = __dirname + const typesPath = currentDir(import.meta.url) const typesDistPath = join(typesPath, 'dist') + + await remove(typesDistPath) + const typesDistPackageJsonPath = join(typesDistPath, 'package.json') const typesDistGitIgnorePath = join(typesDistPath, '.gitignore') + const mainPackageJson = await readJson(join(root(), 'package.json')) + + const typesTsConfigPath = join(typesPath, 'tsconfig.types.json') + const distTsConfigPath = join(typesPath, 'tsconfig.dist.json') const distTsConfig = await readJson(distTsConfigPath) + const clientPackageJson = await readJson(join(root(), 'client', 'package.json')) await remove(typesDistPath) - execSync('npm run tsc -- -b --verbose packages/types', { stdio: 'inherit' }) + execSync(`npm run tsc -- -b ${typesTsConfigPath} --verbose`, { stdio: 'inherit' }) execSync(`npm run resolve-tspaths -- --project ${distTsConfigPath} --src ${typesDistPath} --out ${typesDistPath}`, { stdio: 'inherit' }) const allDependencies = Object.assign( @@ -40,6 +49,8 @@ async function run () { clientPackageJson.devDependencies ) as PackageDependencies + const toIgnore = Object.keys(distTsConfig?.compilerOptions?.paths || []) + // https://github.com/depcheck/depcheck#api const depcheckOptions = { parsers: { '**/*.ts': depcheck.parser.typescript }, @@ -47,7 +58,7 @@ async function run () { depcheck.detector.requireCallExpression, depcheck.detector.importDeclaration ], - ignoreMatches: Object.keys(distTsConfig?.compilerOptions?.paths || []), + ignoreMatches: toIgnore, package: { dependencies: allDependencies } } @@ -68,7 +79,7 @@ async function run () { console.log(`Removing ${Object.keys(unusedDependencies).length} unused dependencies.`) const dependencies = Object .keys(allDependencies) - .filter(dependencyName => !unusedDependencies.includes(dependencyName)) + .filter(dependencyName => !unusedDependencies.includes(dependencyName) && !toIgnore.includes(dependencyName)) .reduce((dependencies, dependencyName) => { dependencies[dependencyName] = allDependencies[dependencyName] return dependencies diff --git a/packages/types-generator/package.json b/packages/types-generator/package.json new file mode 100644 index 000000000..a72235851 --- /dev/null +++ b/packages/types-generator/package.json @@ -0,0 +1,9 @@ +{ + "name": "@peertube/peertube-types-generator", + "private": true, + "version": "0.0.0", + "type": "module", + "dependencies": { + "@peertube/peertube-core-utils": "*" + } +} diff --git a/packages/types-generator/src/client/index.ts b/packages/types-generator/src/client/index.ts new file mode 100644 index 000000000..8868dd5b0 --- /dev/null +++ b/packages/types-generator/src/client/index.ts @@ -0,0 +1 @@ +export * from '@client/types/index.js' diff --git a/packages/types/src/client/tsconfig.json b/packages/types-generator/src/client/tsconfig.types.json similarity index 74% rename from packages/types/src/client/tsconfig.json rename to packages/types-generator/src/client/tsconfig.types.json index bb76fbe21..f60b43f07 100644 --- a/packages/types/src/client/tsconfig.json +++ b/packages/types-generator/src/client/tsconfig.types.json @@ -6,10 +6,14 @@ "emitDeclarationOnly": true, "outDir": "../../dist/client/", "rootDir": "./", - "tsBuildInfoFile": "../../dist/tsconfig.client.types.tsbuildinfo" + "baseUrl": "./", + "tsBuildInfoFile": "../../dist/tsconfig.client.types.tsbuildinfo", + "paths": { + "@client/*": [ "../../../../client/src/*" ] + } }, "references": [ { "path": "../../../../client/tsconfig.types.json" } ], - "files": ["index.ts"] + "files": [ "./index.ts" ] } diff --git a/packages/types-generator/src/index.ts b/packages/types-generator/src/index.ts new file mode 100644 index 000000000..b5669ea24 --- /dev/null +++ b/packages/types-generator/src/index.ts @@ -0,0 +1,3 @@ +export * from '@server/types/index.js' +export * from '@server/types/models/index.js' +export * from '@peertube/peertube-models' diff --git a/packages/types/tests/test.ts b/packages/types-generator/tests/test.ts similarity index 86% rename from packages/types/tests/test.ts rename to packages/types-generator/tests/test.ts index 8c53320a1..bfdcdeed5 100644 --- a/packages/types/tests/test.ts +++ b/packages/types-generator/tests/test.ts @@ -1,5 +1,5 @@ -import { RegisterServerOptions, Video } from '../dist' -import { RegisterClientOptions } from '../dist/client' +import { RegisterServerOptions, Video } from '../dist/index.js' +import { RegisterClientOptions } from '../dist/client/index.js' function register1 ({ registerHook }: RegisterServerOptions) { registerHook({ diff --git a/packages/types-generator/tsconfig.dist.json b/packages/types-generator/tsconfig.dist.json new file mode 100644 index 000000000..6c24a67ba --- /dev/null +++ b/packages/types-generator/tsconfig.dist.json @@ -0,0 +1,17 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "typeRoots": [ + "node_modules/@types", + "client/node_modules/@types" + ], + "baseUrl": "./dist", + "paths": { + "@server/*": [ "server/server/*" ], + "@client/*": [ "client/*" ], + "@peertube/peertube-models": [ "peertube-models" ], + "@peertube/peertube-typescript-utils": [ "peertube-typescript-utils" ] + } + } +} + diff --git a/packages/types-generator/tsconfig.json b/packages/types-generator/tsconfig.json new file mode 100644 index 000000000..fe09d9395 --- /dev/null +++ b/packages/types-generator/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": ".", + "noEmit": true + }, + "files": [ "./generate-package.ts" ], + "references": [ + { "path": "../node-utils" } + ] +} diff --git a/packages/types/tsconfig.json b/packages/types-generator/tsconfig.types.json similarity index 57% rename from packages/types/tsconfig.json rename to packages/types-generator/tsconfig.types.json index f8e16f6b4..a3a1b7c0d 100644 --- a/packages/types/tsconfig.json +++ b/packages/types-generator/tsconfig.types.json @@ -4,20 +4,20 @@ "stripInternal": true, "removeComments": false, "emitDeclarationOnly": true, + "sourceMap": false, "outDir": "./dist/", - "baseUrl": "./src/", - "rootDir": "./src/", + "baseUrl": "./", + "rootDir": "./src", "tsBuildInfoFile": "./dist/tsconfig.server.types.tsbuildinfo", "paths": { - "@server/*": [ "../../../server/*" ], - "@shared/*": [ "../../../shared/*" ], - "@client/*": [ "../../../client/src/*" ] + "@server/*": [ "../../server/server/*" ] } }, "references": [ - { "path": "../../shared/tsconfig.types.json" }, + { "path": "../models/tsconfig.types.json" }, + { "path": "../typescript-utils/tsconfig.types.json" }, { "path": "../../server/tsconfig.types.json" }, - { "path": "./src/client/tsconfig.json" } + { "path": "./src/client/tsconfig.types.json" } ], "files": ["./src/index.ts"] } diff --git a/packages/types/src/client/index.ts b/packages/types/src/client/index.ts deleted file mode 100644 index 5ee10ecb8..000000000 --- a/packages/types/src/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@client/types' diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts deleted file mode 100644 index a8adca287..000000000 --- a/packages/types/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from '@server/types' -export * from '@server/types/models' -export * from '@shared/models' diff --git a/packages/types/tsconfig.dist.json b/packages/types/tsconfig.dist.json deleted file mode 100644 index fbc92712b..000000000 --- a/packages/types/tsconfig.dist.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "typeRoots": [ - "node_modules/@types", - "client/node_modules/@types" - ], - "baseUrl": "./dist", - "paths": { - "@server/*": [ "server/*" ], - "@shared/*": [ "shared/*" ], - "@client/*": [ "client/*" ] - } - } -} - diff --git a/packages/typescript-utils/package.json b/packages/typescript-utils/package.json new file mode 100644 index 000000000..9608bb018 --- /dev/null +++ b/packages/typescript-utils/package.json @@ -0,0 +1,19 @@ +{ + "name": "@peertube/peertube-typescript-utils", + "private": true, + "version": "0.0.0", + "main": "dist/index.js", + "files": [ "dist" ], + "exports": { + "types": "./dist/index.d.ts", + "peertube:tsx": "./src/index.ts", + "default": "./dist/index.js" + }, + "type": "module", + "devDependencies": {}, + "scripts": { + "build": "tsc", + "watch": "tsc -w" + }, + "dependencies": {} +} diff --git a/packages/typescript-utils/src/index.ts b/packages/typescript-utils/src/index.ts new file mode 100644 index 000000000..fdc633235 --- /dev/null +++ b/packages/typescript-utils/src/index.ts @@ -0,0 +1 @@ +export * from './types.js' diff --git a/shared/typescript-utils/types.ts b/packages/typescript-utils/src/types.ts similarity index 100% rename from shared/typescript-utils/types.ts rename to packages/typescript-utils/src/types.ts diff --git a/packages/typescript-utils/tsconfig.json b/packages/typescript-utils/tsconfig.json new file mode 100644 index 000000000..58fa2330b --- /dev/null +++ b/packages/typescript-utils/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./dist", + "rootDir": "src", + "tsBuildInfoFile": "./dist/.tsbuildinfo" + } +} diff --git a/packages/typescript-utils/tsconfig.types.json b/packages/typescript-utils/tsconfig.types.json new file mode 100644 index 000000000..e666b4ca2 --- /dev/null +++ b/packages/typescript-utils/tsconfig.types.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../types-generator/dist/peertube-typescript-utils", + "tsBuildInfoFile": "../types-generator/dist/peertube-typescript-utils/.tsbuildinfo", + "stripInternal": true, + "removeComments": false, + "emitDeclarationOnly": true + } +} diff --git a/scripts/benchmark.ts b/scripts/benchmark.ts index 92fbd5490..c4e4c7275 100644 --- a/scripts/benchmark.ts +++ b/scripts/benchmark.ts @@ -1,8 +1,14 @@ import autocannon, { printResult } from 'autocannon' import { program } from 'commander' -import { writeJson } from 'fs-extra' -import { Video, VideoPrivacy } from '@shared/models' -import { createMultipleServers, doubleFollow, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' +import { writeJson } from 'fs-extra/esm' +import { Video, VideoPrivacy } from '@peertube/peertube-models' +import { + createMultipleServers, + doubleFollow, + killallServers, + PeerTubeServer, + setAccessTokensToServers +} from '@peertube/peertube-server-commands' let servers: PeerTubeServer[] // First server diff --git a/scripts/build/peertube-cli.sh b/scripts/build/peertube-cli.sh new file mode 100644 index 000000000..51886a0db --- /dev/null +++ b/scripts/build/peertube-cli.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -eu + +cd ./apps/peertube-cli +rm -rf ./dist + +../../node_modules/.bin/tsc -b --verbose +rm -rf ./dist +mkdir ./dist + +node ./scripts/build.js diff --git a/scripts/build/peertube-runner.sh b/scripts/build/peertube-runner.sh index 7f6ad5ede..321d10b4b 100755 --- a/scripts/build/peertube-runner.sh +++ b/scripts/build/peertube-runner.sh @@ -2,12 +2,11 @@ set -eu - -cd ./packages/peertube-runner +cd ./apps/peertube-runner rm -rf ./dist ../../node_modules/.bin/tsc -b --verbose rm -rf ./dist mkdir ./dist -./node_modules/.bin/esbuild ./peertube-runner.ts --bundle --platform=node --target=node16 --external:"./lib-cov/fluent-ffmpeg" --external:pg-hstore --outfile=dist/peertube-runner.js +node ./scripts/build.js diff --git a/scripts/build/server.sh b/scripts/build/server.sh index a2dfc3dd9..bbab633a2 100755 --- a/scripts/build/server.sh +++ b/scripts/build/server.sh @@ -2,10 +2,11 @@ set -eu -rm -rf ./dist +rm -rf ./dist ./packages/*/dist -npm run tsc -- -b --verbose +npm run tsc -- -b --verbose server/tsconfig.json npm run resolve-tspaths:server -cp -r "./server/static" "./server/assets" "./dist/server" -cp -r "./server/lib/emails" "./dist/server/lib" +cp -r "./server/server/static" "./server/server/assets" ./dist/server +cp -r "./server/server/lib/emails" "./dist/server/lib" +cp "./server/scripts/upgrade.sh" "./dist/scripts" diff --git a/scripts/build/tests.sh b/scripts/build/tests.sh new file mode 100755 index 000000000..f94dde2a4 --- /dev/null +++ b/scripts/build/tests.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -eu + +rm -rf ./packages/tests/dist + +npm run tsc -- -b --verbose ./packages/tests/tsconfig.json +npm run resolve-tspaths:server-lib +npm run resolve-tspaths:tests diff --git a/scripts/ci.sh b/scripts/ci.sh index 9fb67f634..64968cf94 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -10,7 +10,7 @@ fi retries=3 speedFactor="${2:-1}" -runTest () { +runJSTest () { jobname=$1 shift @@ -24,7 +24,7 @@ runTest () { joblog="$jobname-ci.log" parallel -j $jobs --retries $retries \ - "echo Trying {} >> $joblog; npm run mocha -- -c --timeout 30000 --exit --bail {}" \ + "echo Trying {} >> $joblog; npm run mocha -- --timeout 30000 --no-config -c --exit --bail {}" \ ::: $files cat "$joblog" | sort | uniq -c @@ -32,92 +32,116 @@ runTest () { } findTestFiles () { - exception="-not -name index.js" + exception="-not -name index.js -not -name index.ts -not -name *.d.ts" if [ ! -z ${2+x} ]; then exception="$exception -not -name $2" fi - find $1 -type f -name "*.js" $exception | xargs echo + find $1 -type f \( -name "*.js" -o -name "*.ts" \) $exception | xargs echo } if [ "$1" = "types-package" ]; then npm run generate-types-package 0.0.0 - npm run tsc -- --noEmit --esModuleInterop packages/types/tests/test.ts + + # Test on in independent directory + rm -fr /tmp/types-generator + mkdir -p /tmp/types-generator + cp -r packages/types-generator/tests /tmp/types-generator/tests + cp -r packages/types-generator/dist /tmp/types-generator/dist + (cd /tmp/types-generator/dist && npm install) + + npm run tsc -- --noEmit --esModuleInterop --moduleResolution node16 /tmp/types-generator/tests/test.ts + rm -r /tmp/types-generator elif [ "$1" = "client" ]; then npm run build + npm run build:tests - feedsFiles=$(findTestFiles ./dist/server/tests/feeds) - helperFiles=$(findTestFiles ./dist/server/tests/helpers) - libFiles=$(findTestFiles ./dist/server/tests/lib) - miscFiles="./dist/server/tests/client.js ./dist/server/tests/misc-endpoints.js" + feedsFiles=$(findTestFiles ./packages/tests/dist/feeds) + miscFiles="./packages/tests/dist/client.js ./packages/tests/dist/misc-endpoints.js" # Not in their own task, they need an index.html - pluginFiles="./dist/server/tests/plugins/html-injection.js ./dist/server/tests/api/server/plugins.js" + pluginFiles="./packages/tests/dist/plugins/html-injection.js ./packages/tests/dist/api/server/plugins.js" - MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $feedsFiles $helperFiles $miscFiles $pluginFiles $libFiles + MOCHA_PARALLEL=true runJSTest "$1" $((2*$speedFactor)) $feedsFiles $miscFiles $pluginFiles + + # Use TS tests directly because we import server files + helperFiles=$(findTestFiles ./packages/tests/src/server-helpers) + libFiles=$(findTestFiles ./packages/tests/src/server-lib) + + npm run mocha -- --timeout 30000 -c --exit --bail $libFiles $helperFiles elif [ "$1" = "cli-plugin" ]; then # Simulate HTML mkdir -p "./client/dist/en-US/" cp "./client/src/index.html" "./client/dist/en-US/index.html" npm run build:server - npm run setup:cli + npm run build:tests + npm run build:peertube-cli - pluginsFiles=$(findTestFiles ./dist/server/tests/plugins html-injection.js) - cliFiles=$(findTestFiles ./dist/server/tests/cli) + # html-injection test needs an HTML file + pluginsFiles=$(findTestFiles ./packages/tests/dist/plugins html-injection.js) + cliFiles=$(findTestFiles ./packages/tests/dist/cli) - MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $pluginsFiles - runTest "$1" 1 $cliFiles + MOCHA_PARALLEL=true runJSTest "$1" $((2*$speedFactor)) $pluginsFiles + runJSTest "$1" 1 $cliFiles elif [ "$1" = "api-1" ]; then npm run build:server + npm run build:tests - checkParamFiles=$(findTestFiles ./dist/server/tests/api/check-params) - notificationsFiles=$(findTestFiles ./dist/server/tests/api/notifications) - searchFiles=$(findTestFiles ./dist/server/tests/api/search) + checkParamFiles=$(findTestFiles ./packages/tests/dist/api/check-params) + notificationsFiles=$(findTestFiles ./packages/tests/dist/api/notifications) + searchFiles=$(findTestFiles ./packages/tests/dist/api/search) - MOCHA_PARALLEL=true runTest "$1" $((3*$speedFactor)) $notificationsFiles $searchFiles $checkParamFiles + MOCHA_PARALLEL=true runJSTest "$1" $((3*$speedFactor)) $notificationsFiles $searchFiles $checkParamFiles elif [ "$1" = "api-2" ]; then npm run build:server + npm run build:tests - liveFiles=$(findTestFiles ./dist/server/tests/api/live) - serverFiles=$(findTestFiles ./dist/server/tests/api/server plugins.js) - usersFiles=$(findTestFiles ./dist/server/tests/api/users) + liveFiles=$(findTestFiles ./packages/tests/dist/api/live) + # plugins test needs an HTML file + serverFiles=$(findTestFiles ./packages/tests/dist/api/server plugins.js) + usersFiles=$(findTestFiles ./packages/tests/dist/api/users) - MOCHA_PARALLEL=true runTest "$1" $((3*$speedFactor)) $liveFiles $serverFiles $usersFiles + MOCHA_PARALLEL=true runJSTest "$1" $((3*$speedFactor)) $liveFiles $serverFiles $usersFiles elif [ "$1" = "api-3" ]; then npm run build:server + npm run build:tests - videosFiles=$(findTestFiles ./dist/server/tests/api/videos) - viewsFiles=$(findTestFiles ./dist/server/tests/api/views) + videosFiles=$(findTestFiles ./packages/tests/dist/api/videos) + viewsFiles=$(findTestFiles ./packages/tests/dist/api/views) - MOCHA_PARALLEL=true runTest "$1" $((3*$speedFactor)) $viewsFiles $videosFiles + MOCHA_PARALLEL=true runJSTest "$1" $((3*$speedFactor)) $viewsFiles $videosFiles elif [ "$1" = "api-4" ]; then npm run build:server + npm run build:tests - moderationFiles=$(findTestFiles ./dist/server/tests/api/moderation) - redundancyFiles=$(findTestFiles ./dist/server/tests/api/redundancy) - objectStorageFiles=$(findTestFiles ./dist/server/tests/api/object-storage) - activitypubFiles=$(findTestFiles ./dist/server/tests/api/activitypub) + moderationFiles=$(findTestFiles ./packages/tests/dist/api/moderation) + redundancyFiles=$(findTestFiles ./packages/tests/dist/api/redundancy) + objectStorageFiles=$(findTestFiles ./packages/tests/dist/api/object-storage) + activitypubFiles=$(findTestFiles ./packages/tests/dist/api/activitypub) - MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $moderationFiles $redundancyFiles $activitypubFiles $objectStorageFiles + MOCHA_PARALLEL=true runJSTest "$1" $((2*$speedFactor)) $moderationFiles $redundancyFiles $activitypubFiles $objectStorageFiles elif [ "$1" = "api-5" ]; then npm run build:server + npm run build:tests - transcodingFiles=$(findTestFiles ./dist/server/tests/api/transcoding) - runnersFiles=$(findTestFiles ./dist/server/tests/api/runners) + transcodingFiles=$(findTestFiles ./packages/tests/dist/api/transcoding) + runnersFiles=$(findTestFiles ./packages/tests/dist/api/runners) - MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $transcodingFiles $runnersFiles + MOCHA_PARALLEL=true runJSTest "$1" $((2*$speedFactor)) $transcodingFiles $runnersFiles elif [ "$1" = "external-plugins" ]; then npm run build:server + npm run build:tests npm run build:peertube-runner - externalPluginsFiles=$(findTestFiles ./dist/server/tests/external-plugins) - peertubeRunnerFiles=$(findTestFiles ./dist/server/tests/peertube-runner) + externalPluginsFiles=$(findTestFiles ./packages/tests/dist/external-plugins) + peertubeRunnerFiles=$(findTestFiles ./packages/tests/dist/peertube-runner) - runTest "$1" 1 $externalPluginsFiles - MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $peertubeRunnerFiles + runJSTest "$1" 1 $externalPluginsFiles + MOCHA_PARALLEL=true runJSTest "$1" $((2*$speedFactor)) $peertubeRunnerFiles elif [ "$1" = "lint" ]; then - npm run eslint -- --ext .ts "./server/**/*.ts" "shared/**/*.ts" "scripts/**/*.ts" + npm run eslint -- --ext .ts "server/**/*.ts" "scripts/**/*.ts" "packages/**/*.ts" "apps/**/*.ts" + npm run swagger-cli -- validate support/doc/api/openapi.yaml ( cd client diff --git a/scripts/client-build-stats.ts b/scripts/client-build-stats.ts index d5ecd5fea..3b26aa647 100644 --- a/scripts/client-build-stats.ts +++ b/scripts/client-build-stats.ts @@ -1,6 +1,6 @@ -import { readdir, stat } from 'fs-extra' +import { readdir, stat } from 'fs/promises' import { join } from 'path' -import { root } from '@shared/core-utils' +import { root } from '@peertube/peertube-node-utils' async function run () { const result = { diff --git a/scripts/dev/cli.sh b/scripts/dev/cli.sh deleted file mode 100755 index 39ecaad94..000000000 --- a/scripts/dev/cli.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -set -eu - -rm -rf ./dist/server/tools/ - -( - cd ./server/tools - yarn install --pure-lockfile -) - -mkdir -p "./dist/server/tools" -cp -r "./server/tools/node_modules" "./dist/server/tools" - -cd ./server/tools -../../node_modules/.bin/tsc-watch --build --verbose --onSuccess 'sh -c "cd ../../ && npm run resolve-tspaths:server"' diff --git a/scripts/dev/peertube-cli.sh b/scripts/dev/peertube-cli.sh new file mode 100755 index 000000000..172bf038e --- /dev/null +++ b/scripts/dev/peertube-cli.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -eu + +rm -rf ./apps/peertube-cli/dist + +cd ./apps/peertube-cli + +../../node_modules/.bin/concurrently -k \ + "../../node_modules/.bin/tsc -w --noEmit" \ + "node ./scripts/watch.js" diff --git a/scripts/dev/peertube-runner.sh b/scripts/dev/peertube-runner.sh index e39259372..7bd756123 100755 --- a/scripts/dev/peertube-runner.sh +++ b/scripts/dev/peertube-runner.sh @@ -2,10 +2,10 @@ set -eu -rm -rf ./packages/peertube-runner/dist +rm -rf ./apps/peertube-runner/dist -cd ./packages/peertube-runner +cd ./apps/peertube-runner ../../node_modules/.bin/concurrently -k \ "../../node_modules/.bin/tsc -w --noEmit" \ - "./node_modules/.bin/esbuild ./peertube-runner.ts --bundle --sourcemap --platform=node --external:"./lib-cov/fluent-ffmpeg" --external:pg-hstore --watch --outfile=dist/peertube-runner.js" + "node ./scripts/watch.js" diff --git a/scripts/dev/server.sh b/scripts/dev/server.sh index c52c5124c..4112cb2f8 100755 --- a/scripts/dev/server.sh +++ b/scripts/dev/server.sh @@ -16,10 +16,10 @@ cp -r "./client/src/locale" "./client/dist/locale" mkdir -p "./dist/server/lib" -npm run tsc -- -b -v --incremental +npm run tsc -- -b -v --incremental server/tsconfig.json npm run resolve-tspaths:server -cp -r ./server/static ./server/assets ./dist/server -cp -r "./server/lib/emails" "./dist/server/lib" +cp -r ./server/server/static ./server/server/assets ./dist/server +cp -r "./server/server/lib/emails" "./dist/server/lib" -./node_modules/.bin/tsc-watch --build --preserveWatchOutput --verbose --onSuccess 'sh -c "npm run resolve-tspaths:server && NODE_ENV=dev node dist/server"' +./node_modules/.bin/tsc-watch --build --preserveWatchOutput --verbose --onSuccess 'sh -c "npm run resolve-tspaths:server && NODE_ENV=dev node dist/server"' server/tsconfig.json diff --git a/scripts/generate-code-contributors.ts b/scripts/generate-code-contributors.ts index 2fd0ecdf3..408bbec5d 100755 --- a/scripts/generate-code-contributors.ts +++ b/scripts/generate-code-contributors.ts @@ -1,4 +1,4 @@ -import { CLICommand } from '@shared/server-commands' +import { CLICommand } from '@peertube/peertube-server-commands' run() .then(() => process.exit(0)) diff --git a/scripts/i18n/create-custom-files.ts b/scripts/i18n/create-custom-files.ts index 696a097b1..887ab86af 100755 --- a/scripts/i18n/create-custom-files.ts +++ b/scripts/i18n/create-custom-files.ts @@ -1,6 +1,7 @@ -import { writeJSON } from 'fs-extra' +import { readJsonSync, writeJSON } from 'fs-extra/esm' import { join } from 'path' -import { root, USER_ROLE_LABELS } from '@shared/core-utils' +import { I18N_LOCALES, USER_ROLE_LABELS } from '@peertube/peertube-core-utils' +import { root } from '@peertube/peertube-node-utils' import { ABUSE_STATES, buildLanguages, @@ -14,10 +15,9 @@ import { VIDEO_PLAYLIST_TYPES, VIDEO_PRIVACIES, VIDEO_STATES -} from '../../server/initializers/constants' -import { I18N_LOCALES } from '../../shared/core-utils/i18n' +} from '../../server/initializers/constants.js' -const videojs = require(join(root(), 'client', 'src', 'locale', 'videojs.en-US.json')) +const videojs = readJsonSync(join(root(), 'client', 'src', 'locale', 'videojs.en-US.json')) const playerKeys = { 'Quality': 'Quality', 'Auto': 'Auto', @@ -131,13 +131,13 @@ async function writeAll () { for (const key of Object.keys(I18N_LOCALES)) { const playerJsonPath = join(localePath, `player.${key}.json`) - const translatedPlayer = require(playerJsonPath) + const translatedPlayer = readJsonSync(playerJsonPath) const newTranslatedPlayer = Object.assign({}, playerKeys, translatedPlayer) await writeJSON(playerJsonPath, newTranslatedPlayer, { spaces: 4 }) const serverJsonPath = join(localePath, `server.${key}.json`) - const translatedServer = require(serverJsonPath) + const translatedServer = readJsonSync(serverJsonPath) const newTranslatedServer = Object.assign({}, serverKeys, translatedServer) await writeJSON(serverJsonPath, newTranslatedServer, { spaces: 4 }) diff --git a/scripts/nightly.sh b/scripts/nightly.sh index 572277f9d..e911c549d 100755 --- a/scripts/nightly.sh +++ b/scripts/nightly.sh @@ -20,6 +20,13 @@ tar_name="peertube-nightly-$today.tar.xz" npm run build -- --source-map +# Clean up declaration files +find dist/ packages/core-utils/dist/ \ + packages/ffmpeg/dist/ \ + packages/node-utils/dist/ \ + packages/models/dist/ \ + \( -name '*.d.ts' -o -name '*.d.ts.map' \) -type f -delete + nightly_version="nightly-$today" sed -i 's/"version": "\([^"]\+\)"/"version": "\1-'"$nightly_version"'"/' ./package.json @@ -28,6 +35,10 @@ sed -i 's/"version": "\([^"]\+\)"/"version": "\1-'"$nightly_version"'"/' ./packa # local variables directories_to_archive=("$directory_name/CREDITS.md" "$directory_name/FAQ.md" \ "$directory_name/LICENSE" "$directory_name/README.md" \ + "$directory_name/packages/core-utils/dist/" "$directory_name/packages/core-utils/package.json" \ + "$directory_name/packages/ffmpeg/dist/" "$directory_name/packages/ffmpeg/package.json" \ + "$directory_name/packages/node-utils/dist/" "$directory_name/packages/node-utils/package.json" \ + "$directory_name/packages/models/dist/" "$directory_name/packages/models/package.json" \ "$directory_name/client/dist/" "$directory_name/client/yarn.lock" \ "$directory_name/client/package.json" "$directory_name/config" \ "$directory_name/dist" "$directory_name/package.json" \ diff --git a/scripts/release.sh b/scripts/release.sh index 2b922a749..0df9efa1d 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -69,11 +69,22 @@ npm run build -- --source-map rm -f "./client/dist/en-US/stats.json" rm -f "./client/dist/embed-stats.json" +# Clean up declaration files +find dist/ packages/core-utils/dist/ \ + packages/ffmpeg/dist/ \ + packages/node-utils/dist/ \ + packages/models/dist/ \ + \( -name '*.d.ts' -o -name '*.d.ts.map' \) -type f -delete + # Creating the archives ( # local variables directories_to_archive=("$directory_name/CREDITS.md" "$directory_name/FAQ.md" \ "$directory_name/LICENSE" "$directory_name/README.md" \ + "$directory_name/packages/core-utils/dist/" "$directory_name/packages/core-utils/package.json" \ + "$directory_name/packages/ffmpeg/dist/" "$directory_name/packages/ffmpeg/package.json" \ + "$directory_name/packages/node-utils/dist/" "$directory_name/packages/node-utils/package.json" \ + "$directory_name/packages/models/dist/" "$directory_name/packages/models/package.json" \ "$directory_name/client/dist/" "$directory_name/client/yarn.lock" \ "$directory_name/client/package.json" "$directory_name/config" \ "$directory_name/dist" "$directory_name/package.json" \ @@ -124,7 +135,7 @@ rm -f "./client/dist/embed-stats.json" # Release types package npm run generate-types-package "$version" - cd packages/types/dist + cd packages/types-generator/dist npm publish --access public fi ) diff --git a/scripts/setup/cli.sh b/scripts/setup/cli.sh deleted file mode 100755 index 2e9b8a505..000000000 --- a/scripts/setup/cli.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -set -eu - -NOCLIENT=1 yarn install --pure-lockfile - -rm -rf ./dist/server/tools/ - -( - cd ./server/tools - yarn install --pure-lockfile - ../../node_modules/.bin/tsc --build --verbose -) - -cp -r "./server/tools/node_modules" "./dist/server/tools" - -npm run resolve-tspaths:server diff --git a/scripts/simulate-many-viewers.ts b/scripts/simulate-many-viewers.ts index a993e175a..d6d9fd69e 100644 --- a/scripts/simulate-many-viewers.ts +++ b/scripts/simulate-many-viewers.ts @@ -1,5 +1,5 @@ import Bluebird from 'bluebird' -import { wait } from '@shared/core-utils' +import { wait } from '@peertube/peertube-core-utils' import { createSingleServer, doubleFollow, @@ -7,7 +7,7 @@ import { PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/server-commands' +} from '@peertube/peertube-server-commands' let servers: PeerTubeServer[] const viewers: { xForwardedFor: string }[] = [] diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json index 0cfd927a6..0a7e07599 100644 --- a/scripts/tsconfig.json +++ b/scripts/tsconfig.json @@ -4,7 +4,10 @@ "outDir": "../dist/scripts" }, "references": [ - { "path": "../shared" }, + { "path": "../packages/core-utils" }, + { "path": "../packages/models" }, + { "path": "../packages/node-utils" }, + { "path": "../packages/server-commands" }, { "path": "../server" } ] } diff --git a/server/controllers/api/search/shared/index.ts b/server/controllers/api/search/shared/index.ts deleted file mode 100644 index 9c56149ef..000000000 --- a/server/controllers/api/search/shared/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './utils' diff --git a/server/controllers/feeds/shared/index.ts b/server/controllers/feeds/shared/index.ts deleted file mode 100644 index 0136c8477..000000000 --- a/server/controllers/feeds/shared/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './video-feed-utils' -export * from './common-feed-utils' diff --git a/server/controllers/index.ts b/server/controllers/index.ts deleted file mode 100644 index 8a647aff1..000000000 --- a/server/controllers/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -export * from './activitypub' -export * from './api' -export * from './sitemap' -export * from './client' -export * from './download' -export * from './feeds' -export * from './lazy-static' -export * from './misc' -export * from './object-storage-proxy' -export * from './plugins' -export * from './services' -export * from './static' -export * from './tracker' -export * from './well-known' diff --git a/server/helpers/ffmpeg/index.ts b/server/helpers/ffmpeg/index.ts deleted file mode 100644 index bf1c73fb6..000000000 --- a/server/helpers/ffmpeg/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './codecs' -export * from './ffmpeg-image' -export * from './ffmpeg-options' -export * from './framerate' diff --git a/server/helpers/youtube-dl/index.ts b/server/helpers/youtube-dl/index.ts deleted file mode 100644 index 6afc77dcf..000000000 --- a/server/helpers/youtube-dl/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './youtube-dl-cli' -export * from './youtube-dl-info-builder' -export * from './youtube-dl-wrapper' diff --git a/server/lib/activitypub/actors/index.ts b/server/lib/activitypub/actors/index.ts deleted file mode 100644 index 5ee2a6f1a..000000000 --- a/server/lib/activitypub/actors/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './get' -export * from './image' -export * from './keys' -export * from './refresh' -export * from './updater' -export * from './webfinger' diff --git a/server/lib/activitypub/actors/shared/index.ts b/server/lib/activitypub/actors/shared/index.ts deleted file mode 100644 index 52af1a8e1..000000000 --- a/server/lib/activitypub/actors/shared/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './creator' -export * from './object-to-model-attributes' -export * from './url-to-object' diff --git a/server/lib/activitypub/playlists/index.ts b/server/lib/activitypub/playlists/index.ts deleted file mode 100644 index e2470a674..000000000 --- a/server/lib/activitypub/playlists/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './get' -export * from './create-update' -export * from './refresh' diff --git a/server/lib/activitypub/playlists/shared/index.ts b/server/lib/activitypub/playlists/shared/index.ts deleted file mode 100644 index a217f2291..000000000 --- a/server/lib/activitypub/playlists/shared/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './object-to-model-attributes' -export * from './url-to-object' diff --git a/server/lib/activitypub/process/index.ts b/server/lib/activitypub/process/index.ts deleted file mode 100644 index 5466739c1..000000000 --- a/server/lib/activitypub/process/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './process' diff --git a/server/lib/activitypub/send/index.ts b/server/lib/activitypub/send/index.ts deleted file mode 100644 index 852ea2e74..000000000 --- a/server/lib/activitypub/send/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -export * from './http' -export * from './send-accept' -export * from './send-announce' -export * from './send-create' -export * from './send-delete' -export * from './send-follow' -export * from './send-like' -export * from './send-reject' -export * from './send-undo' -export * from './send-update' diff --git a/server/lib/activitypub/send/shared/index.ts b/server/lib/activitypub/send/shared/index.ts deleted file mode 100644 index bda579115..000000000 --- a/server/lib/activitypub/send/shared/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './audience-utils' -export * from './send-utils' diff --git a/server/lib/activitypub/videos/index.ts b/server/lib/activitypub/videos/index.ts deleted file mode 100644 index b22062598..000000000 --- a/server/lib/activitypub/videos/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './federate' -export * from './get' -export * from './refresh' -export * from './updater' diff --git a/server/lib/activitypub/videos/shared/index.ts b/server/lib/activitypub/videos/shared/index.ts deleted file mode 100644 index 951403493..000000000 --- a/server/lib/activitypub/videos/shared/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './abstract-builder' -export * from './creator' -export * from './object-to-model-attributes' -export * from './trackers' -export * from './url-to-object' -export * from './video-sync-attributes' diff --git a/server/lib/files-cache/index.ts b/server/lib/files-cache/index.ts deleted file mode 100644 index 5630a9b80..000000000 --- a/server/lib/files-cache/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './avatar-permanent-file-cache' -export * from './video-miniature-permanent-file-cache' -export * from './video-captions-simple-file-cache' -export * from './video-previews-simple-file-cache' -export * from './video-storyboards-simple-file-cache' -export * from './video-torrents-simple-file-cache' diff --git a/server/lib/files-cache/shared/index.ts b/server/lib/files-cache/shared/index.ts deleted file mode 100644 index 61c4aacc7..000000000 --- a/server/lib/files-cache/shared/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './abstract-permanent-file-cache' -export * from './abstract-simple-file-cache' diff --git a/server/lib/job-queue/index.ts b/server/lib/job-queue/index.ts deleted file mode 100644 index 57231e649..000000000 --- a/server/lib/job-queue/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './job-queue' diff --git a/server/lib/live/index.ts b/server/lib/live/index.ts deleted file mode 100644 index 8b46800da..000000000 --- a/server/lib/live/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './live-manager' -export * from './live-quota-store' -export * from './live-segment-sha-store' -export * from './live-utils' diff --git a/server/lib/live/shared/index.ts b/server/lib/live/shared/index.ts deleted file mode 100644 index c4d1b59ec..000000000 --- a/server/lib/live/shared/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './muxing-session' diff --git a/server/lib/live/shared/transcoding-wrapper/index.ts b/server/lib/live/shared/transcoding-wrapper/index.ts deleted file mode 100644 index ae28fa1ca..000000000 --- a/server/lib/live/shared/transcoding-wrapper/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './abstract-transcoding-wrapper' -export * from './ffmpeg-transcoding-wrapper' -export * from './remote-transcoding-wrapper' diff --git a/server/lib/model-loaders/index.ts b/server/lib/model-loaders/index.ts deleted file mode 100644 index 9e5152cb2..000000000 --- a/server/lib/model-loaders/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './actor' -export * from './video' diff --git a/server/lib/notifier/index.ts b/server/lib/notifier/index.ts deleted file mode 100644 index 5bc2f5f50..000000000 --- a/server/lib/notifier/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './notifier' diff --git a/server/lib/notifier/shared/abuse/index.ts b/server/lib/notifier/shared/abuse/index.ts deleted file mode 100644 index 7b54c5591..000000000 --- a/server/lib/notifier/shared/abuse/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './abuse-state-change-for-reporter' -export * from './new-abuse-for-moderators' -export * from './new-abuse-message-for-reporter' -export * from './new-abuse-message-for-moderators' diff --git a/server/lib/notifier/shared/blacklist/index.ts b/server/lib/notifier/shared/blacklist/index.ts deleted file mode 100644 index 2f98d88ae..000000000 --- a/server/lib/notifier/shared/blacklist/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './new-auto-blacklist-for-moderators' -export * from './new-blacklist-for-owner' -export * from './unblacklist-for-owner' diff --git a/server/lib/notifier/shared/comment/index.ts b/server/lib/notifier/shared/comment/index.ts deleted file mode 100644 index ae01a9646..000000000 --- a/server/lib/notifier/shared/comment/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './comment-mention' -export * from './new-comment-for-video-owner' diff --git a/server/lib/notifier/shared/common/index.ts b/server/lib/notifier/shared/common/index.ts deleted file mode 100644 index 0b2570278..000000000 --- a/server/lib/notifier/shared/common/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './abstract-notification' diff --git a/server/lib/notifier/shared/follow/index.ts b/server/lib/notifier/shared/follow/index.ts deleted file mode 100644 index 27f5289d9..000000000 --- a/server/lib/notifier/shared/follow/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './auto-follow-for-instance' -export * from './follow-for-instance' -export * from './follow-for-user' diff --git a/server/lib/notifier/shared/index.ts b/server/lib/notifier/shared/index.ts deleted file mode 100644 index cc3ce8c7c..000000000 --- a/server/lib/notifier/shared/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from './abuse' -export * from './blacklist' -export * from './comment' -export * from './common' -export * from './follow' -export * from './instance' -export * from './video-publication' diff --git a/server/lib/notifier/shared/instance/index.ts b/server/lib/notifier/shared/instance/index.ts deleted file mode 100644 index 8c75a8ee9..000000000 --- a/server/lib/notifier/shared/instance/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './new-peertube-version-for-admins' -export * from './new-plugin-version-for-admins' -export * from './direct-registration-for-moderators' -export * from './registration-request-for-moderators' diff --git a/server/lib/notifier/shared/video-publication/index.ts b/server/lib/notifier/shared/video-publication/index.ts deleted file mode 100644 index 5e92cb011..000000000 --- a/server/lib/notifier/shared/video-publication/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './new-video-for-subscribers' -export * from './import-finished-for-owner' -export * from './owned-publication-after-auto-unblacklist' -export * from './owned-publication-after-schedule-update' -export * from './owned-publication-after-transcoding' -export * from './studio-edition-finished-for-owner' diff --git a/server/lib/object-storage/index.ts b/server/lib/object-storage/index.ts deleted file mode 100644 index 3ad6cab63..000000000 --- a/server/lib/object-storage/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './keys' -export * from './proxy' -export * from './pre-signed-urls' -export * from './urls' -export * from './videos' diff --git a/server/lib/object-storage/shared/client.ts b/server/lib/object-storage/shared/client.ts deleted file mode 100644 index d5cb074df..000000000 --- a/server/lib/object-storage/shared/client.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { S3Client } from '@aws-sdk/client-s3' -import { NodeHttpHandler } from '@aws-sdk/node-http-handler' -import { logger } from '@server/helpers/logger' -import { isProxyEnabled } from '@server/helpers/proxy' -import { getAgent } from '@server/helpers/requests' -import { CONFIG } from '@server/initializers/config' -import { lTags } from './logger' - -function getProxyRequestHandler () { - if (!isProxyEnabled()) return null - - const { agent } = getAgent() - - return new NodeHttpHandler({ - httpAgent: agent.http, - httpsAgent: agent.https - }) -} - -let endpointParsed: URL -function getEndpointParsed () { - if (endpointParsed) return endpointParsed - - endpointParsed = new URL(getEndpoint()) - - return endpointParsed -} - -let s3Client: S3Client -function getClient () { - if (s3Client) return s3Client - - const OBJECT_STORAGE = CONFIG.OBJECT_STORAGE - - s3Client = new S3Client({ - endpoint: getEndpoint(), - region: OBJECT_STORAGE.REGION, - credentials: OBJECT_STORAGE.CREDENTIALS.ACCESS_KEY_ID - ? { - accessKeyId: OBJECT_STORAGE.CREDENTIALS.ACCESS_KEY_ID, - secretAccessKey: OBJECT_STORAGE.CREDENTIALS.SECRET_ACCESS_KEY - } - : undefined, - requestHandler: getProxyRequestHandler() - }) - - logger.info('Initialized S3 client %s with region %s.', getEndpoint(), OBJECT_STORAGE.REGION, lTags()) - - return s3Client -} - -// --------------------------------------------------------------------------- - -export { - getEndpointParsed, - getClient -} - -// --------------------------------------------------------------------------- - -let endpoint: string -function getEndpoint () { - if (endpoint) return endpoint - - const endpointConfig = CONFIG.OBJECT_STORAGE.ENDPOINT - endpoint = endpointConfig.startsWith('http://') || endpointConfig.startsWith('https://') - ? CONFIG.OBJECT_STORAGE.ENDPOINT - : 'https://' + CONFIG.OBJECT_STORAGE.ENDPOINT - - return endpoint -} diff --git a/server/lib/object-storage/shared/index.ts b/server/lib/object-storage/shared/index.ts deleted file mode 100644 index 11e10aa9f..000000000 --- a/server/lib/object-storage/shared/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './client' -export * from './logger' -export * from './object-storage-helpers' diff --git a/server/lib/opentelemetry/metric-helpers/index.ts b/server/lib/opentelemetry/metric-helpers/index.ts deleted file mode 100644 index 47b24a54f..000000000 --- a/server/lib/opentelemetry/metric-helpers/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from './bittorrent-tracker-observers-builder' -export * from './lives-observers-builder' -export * from './job-queue-observers-builder' -export * from './nodejs-observers-builder' -export * from './playback-metrics' -export * from './stats-observers-builder' -export * from './viewers-observers-builder' diff --git a/server/lib/opentelemetry/tracing.ts b/server/lib/opentelemetry/tracing.ts deleted file mode 100644 index 9a81680b2..000000000 --- a/server/lib/opentelemetry/tracing.ts +++ /dev/null @@ -1,94 +0,0 @@ -import { SequelizeInstrumentation } from 'opentelemetry-instrumentation-sequelize' -import { context, diag, DiagLogLevel, trace } from '@opentelemetry/api' -import { JaegerExporter } from '@opentelemetry/exporter-jaeger' -import { registerInstrumentations } from '@opentelemetry/instrumentation' -import { DnsInstrumentation } from '@opentelemetry/instrumentation-dns' -import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express' -import FsInstrumentation from '@opentelemetry/instrumentation-fs' -import { HttpInstrumentation } from '@opentelemetry/instrumentation-http' -import { IORedisInstrumentation } from '@opentelemetry/instrumentation-ioredis' -import { PgInstrumentation } from '@opentelemetry/instrumentation-pg' -import { Resource } from '@opentelemetry/resources' -import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base' -import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node' -import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions' -import { logger } from '@server/helpers/logger' -import { CONFIG } from '@server/initializers/config' - -const tracer = trace.getTracer('peertube') - -function registerOpentelemetryTracing () { - if (CONFIG.OPEN_TELEMETRY.TRACING.ENABLED !== true) return - - logger.info('Registering Open Telemetry tracing') - - const customLogger = (level: string) => { - return (message: string, ...args: unknown[]) => { - let fullMessage = message - - for (const arg of args) { - if (typeof arg === 'string') fullMessage += arg - else break - } - - logger[level](fullMessage) - } - } - - diag.setLogger({ - error: customLogger('error'), - warn: customLogger('warn'), - info: customLogger('info'), - debug: customLogger('debug'), - verbose: customLogger('verbose') - }, DiagLogLevel.INFO) - - const tracerProvider = new NodeTracerProvider({ - resource: new Resource({ - [SemanticResourceAttributes.SERVICE_NAME]: 'peertube' - }) - }) - - registerInstrumentations({ - tracerProvider, - instrumentations: [ - new PgInstrumentation({ - enhancedDatabaseReporting: true - }), - new DnsInstrumentation(), - new HttpInstrumentation(), - new ExpressInstrumentation(), - new IORedisInstrumentation({ - dbStatementSerializer: function (cmdName, cmdArgs) { - return [ cmdName, ...cmdArgs ].join(' ') - } - }), - new FsInstrumentation(), - new SequelizeInstrumentation() - ] - }) - - tracerProvider.addSpanProcessor( - new BatchSpanProcessor( - new JaegerExporter({ endpoint: CONFIG.OPEN_TELEMETRY.TRACING.JAEGER_EXPORTER.ENDPOINT }) - ) - ) - - tracerProvider.register() -} - -async function wrapWithSpanAndContext (spanName: string, cb: () => Promise) { - const span = tracer.startSpan(spanName) - const activeContext = trace.setSpan(context.active(), span) - - const result = await context.with(activeContext, () => cb()) - span.end() - - return result -} - -export { - registerOpentelemetryTracing, - tracer, - wrapWithSpanAndContext -} diff --git a/server/lib/runners/index.ts b/server/lib/runners/index.ts deleted file mode 100644 index a737c7b59..000000000 --- a/server/lib/runners/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './job-handlers' -export * from './runner' -export * from './runner-urls' diff --git a/server/lib/runners/job-handlers/index.ts b/server/lib/runners/job-handlers/index.ts deleted file mode 100644 index 40ad2f97a..000000000 --- a/server/lib/runners/job-handlers/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from './abstract-job-handler' -export * from './live-rtmp-hls-transcoding-job-handler' -export * from './runner-job-handlers' -export * from './video-studio-transcoding-job-handler' -export * from './vod-audio-merge-transcoding-job-handler' -export * from './vod-hls-transcoding-job-handler' -export * from './vod-web-video-transcoding-job-handler' diff --git a/server/lib/runners/job-handlers/shared/index.ts b/server/lib/runners/job-handlers/shared/index.ts deleted file mode 100644 index 348273ae2..000000000 --- a/server/lib/runners/job-handlers/shared/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './vod-helpers' diff --git a/server/lib/transcoding/shared/index.ts b/server/lib/transcoding/shared/index.ts deleted file mode 100644 index f0b45bcbb..000000000 --- a/server/lib/transcoding/shared/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './job-builders' -export * from './ffmpeg-builder' diff --git a/server/lib/transcoding/shared/job-builders/index.ts b/server/lib/transcoding/shared/job-builders/index.ts deleted file mode 100644 index 9b1c82adf..000000000 --- a/server/lib/transcoding/shared/job-builders/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './transcoding-job-queue-builder' -export * from './transcoding-runner-job-builder' diff --git a/server/lib/views/shared/index.ts b/server/lib/views/shared/index.ts deleted file mode 100644 index 139471183..000000000 --- a/server/lib/views/shared/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './video-viewer-counters' -export * from './video-viewer-stats' -export * from './video-views' diff --git a/server/lib/worker/workers/image-processor.ts b/server/lib/worker/workers/image-processor.ts deleted file mode 100644 index 0ab41a5a0..000000000 --- a/server/lib/worker/workers/image-processor.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { processImage } from '@server/helpers/image-utils' - -module.exports = processImage - -export { - processImage -} diff --git a/server/middlewares/cache/index.ts b/server/middlewares/cache/index.ts deleted file mode 100644 index 79b512828..000000000 --- a/server/middlewares/cache/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './cache' diff --git a/server/middlewares/cache/shared/index.ts b/server/middlewares/cache/shared/index.ts deleted file mode 100644 index c707eaf7a..000000000 --- a/server/middlewares/cache/shared/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './api-cache' diff --git a/server/middlewares/index.ts b/server/middlewares/index.ts deleted file mode 100644 index b40f864ce..000000000 --- a/server/middlewares/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -export * from './validators' -export * from './cache' -export * from './activitypub' -export * from './async' -export * from './auth' -export * from './pagination' -export * from './rate-limiter' -export * from './robots' -export * from './servers' -export * from './sort' -export * from './user-right' -export * from './dnt' -export * from './error' -export * from './doc' -export * from './csp' diff --git a/server/middlewares/validators/activitypub/index.ts b/server/middlewares/validators/activitypub/index.ts deleted file mode 100644 index 159338d26..000000000 --- a/server/middlewares/validators/activitypub/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './activity' -export * from './signature' -export * from './pagination' diff --git a/server/middlewares/validators/index.ts b/server/middlewares/validators/index.ts deleted file mode 100644 index 1d0964667..000000000 --- a/server/middlewares/validators/index.ts +++ /dev/null @@ -1,31 +0,0 @@ -export * from './abuse' -export * from './account' -export * from './activitypub' -export * from './actor-image' -export * from './blocklist' -export * from './bulk' -export * from './config' -export * from './express' -export * from './feeds' -export * from './follows' -export * from './jobs' -export * from './logs' -export * from './metrics' -export * from './object-storage-proxy' -export * from './oembed' -export * from './pagination' -export * from './plugins' -export * from './redundancy' -export * from './search' -export * from './server' -export * from './sort' -export * from './static' -export * from './themes' -export * from './user-email-verification' -export * from './user-history' -export * from './user-notifications' -export * from './user-registrations' -export * from './user-subscriptions' -export * from './users' -export * from './videos' -export * from './webfinger' diff --git a/server/middlewares/validators/runners/index.ts b/server/middlewares/validators/runners/index.ts deleted file mode 100644 index 9a9629a80..000000000 --- a/server/middlewares/validators/runners/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './jobs' -export * from './registration-token' -export * from './runners' diff --git a/server/middlewares/validators/shared/index.ts b/server/middlewares/validators/shared/index.ts deleted file mode 100644 index e5cff2dda..000000000 --- a/server/middlewares/validators/shared/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -export * from './abuses' -export * from './accounts' -export * from './users' -export * from './utils' -export * from './video-blacklists' -export * from './video-captions' -export * from './video-channels' -export * from './video-channel-syncs' -export * from './video-comments' -export * from './video-imports' -export * from './video-ownerships' -export * from './video-playlists' -export * from './video-passwords' -export * from './videos' diff --git a/server/middlewares/validators/videos/index.ts b/server/middlewares/validators/videos/index.ts deleted file mode 100644 index 8c6fc49b1..000000000 --- a/server/middlewares/validators/videos/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -export * from './video-blacklist' -export * from './video-captions' -export * from './video-channel-sync' -export * from './video-channels' -export * from './video-comments' -export * from './video-files' -export * from './video-imports' -export * from './video-live' -export * from './video-ownership-changes' -export * from './video-passwords' -export * from './video-rates' -export * from './video-shares' -export * from './video-source' -export * from './video-stats' -export * from './video-studio' -export * from './video-token' -export * from './video-transcoding' -export * from './video-view' -export * from './videos' diff --git a/server/middlewares/validators/videos/shared/index.ts b/server/middlewares/validators/videos/shared/index.ts deleted file mode 100644 index eb11dcc6a..000000000 --- a/server/middlewares/validators/videos/shared/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './upload' -export * from './video-validators' diff --git a/server/models/migrations.ts b/server/models/migrations.ts deleted file mode 100644 index 6c11332a1..000000000 --- a/server/models/migrations.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { ModelAttributeColumnOptions } from 'sequelize' - -declare namespace Migration { - interface Boolean extends ModelAttributeColumnOptions { - defaultValue: boolean | null - } - - interface String extends ModelAttributeColumnOptions { - defaultValue: string | null - } - - interface Integer extends ModelAttributeColumnOptions { - defaultValue: number | null - } - - interface BigInteger extends ModelAttributeColumnOptions { - defaultValue: number | null - } - - interface UUID extends ModelAttributeColumnOptions { - defaultValue: null - } -} - -export { - Migration -} diff --git a/server/models/shared/index.ts b/server/models/shared/index.ts deleted file mode 100644 index 5a7621e4d..000000000 --- a/server/models/shared/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from './abstract-run-query' -export * from './model-builder' -export * from './model-cache' -export * from './query' -export * from './sequelize-helpers' -export * from './sort' -export * from './sql' -export * from './update' diff --git a/server/models/video/formatter/index.ts b/server/models/video/formatter/index.ts deleted file mode 100644 index 77b406559..000000000 --- a/server/models/video/formatter/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './video-activity-pub-format' -export * from './video-api-format' diff --git a/server/models/video/formatter/shared/index.ts b/server/models/video/formatter/shared/index.ts deleted file mode 100644 index d558fa7d6..000000000 --- a/server/models/video/formatter/shared/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './video-format-utils' diff --git a/server/models/video/sql/video/index.ts b/server/models/video/sql/video/index.ts deleted file mode 100644 index e9132d5e1..000000000 --- a/server/models/video/sql/video/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './video-model-get-query-builder' -export * from './videos-id-list-query-builder' -export * from './videos-model-list-query-builder' diff --git a/server/package.json b/server/package.json new file mode 100644 index 000000000..2bf62ff85 --- /dev/null +++ b/server/package.json @@ -0,0 +1,12 @@ +{ + "name": "@peertube/peertube-server", + "private": true, + "version": "0.0.0", + "files": [ "dist" ], + "type": "module", + "exports": { + "./*": "./dist/*" + }, + "devDependencies": {}, + "dependencies": {} +} diff --git a/scripts/create-generate-storyboard-job.ts b/server/scripts/create-generate-storyboard-job.ts similarity index 93% rename from scripts/create-generate-storyboard-job.ts rename to server/scripts/create-generate-storyboard-job.ts index 47c08edac..1f70e4d15 100644 --- a/scripts/create-generate-storyboard-job.ts +++ b/server/scripts/create-generate-storyboard-job.ts @@ -1,9 +1,9 @@ import { program } from 'commander' -import { toCompleteUUID } from '@server/helpers/custom-validators/misc' -import { initDatabaseModels } from '@server/initializers/database' -import { JobQueue } from '@server/lib/job-queue' -import { VideoModel } from '@server/models/video/video' -import { StoryboardModel } from '@server/models/video/storyboard' +import { toCompleteUUID } from '@server/helpers/custom-validators/misc.js' +import { initDatabaseModels } from '@server/initializers/database.js' +import { JobQueue } from '@server/lib/job-queue/index.js' +import { StoryboardModel } from '@server/models/video/storyboard.js' +import { VideoModel } from '@server/models/video/video.js' program .description('Generate videos storyboard') diff --git a/scripts/create-import-video-file-job.ts b/server/scripts/create-import-video-file-job.ts similarity index 90% rename from scripts/create-import-video-file-job.ts rename to server/scripts/create-import-video-file-job.ts index 9cb387d2e..33a45fba1 100644 --- a/scripts/create-import-video-file-job.ts +++ b/server/scripts/create-import-video-file-job.ts @@ -1,9 +1,9 @@ import { program } from 'commander' import { resolve } from 'path' -import { isUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc' -import { initDatabaseModels } from '../server/initializers/database' -import { JobQueue } from '../server/lib/job-queue' -import { VideoModel } from '../server/models/video/video' +import { isUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc.js' +import { initDatabaseModels } from '../server/initializers/database.js' +import { JobQueue } from '../server/lib/job-queue/index.js' +import { VideoModel } from '../server/models/video/video.js' program .option('-v, --video [videoUUID]', 'Video UUID') diff --git a/scripts/create-move-video-storage-job.ts b/server/scripts/create-move-video-storage-job.ts similarity index 90% rename from scripts/create-move-video-storage-job.ts rename to server/scripts/create-move-video-storage-job.ts index 8537114eb..a615d1f44 100644 --- a/scripts/create-move-video-storage-job.ts +++ b/server/scripts/create-move-video-storage-job.ts @@ -1,11 +1,11 @@ import { program } from 'commander' -import { toCompleteUUID } from '@server/helpers/custom-validators/misc' -import { CONFIG } from '@server/initializers/config' -import { initDatabaseModels } from '@server/initializers/database' -import { JobQueue } from '@server/lib/job-queue' -import { moveToExternalStorageState } from '@server/lib/video-state' -import { VideoModel } from '@server/models/video/video' -import { VideoState, VideoStorage } from '@shared/models' +import { toCompleteUUID } from '@server/helpers/custom-validators/misc.js' +import { CONFIG } from '@server/initializers/config.js' +import { initDatabaseModels } from '@server/initializers/database.js' +import { JobQueue } from '@server/lib/job-queue/index.js' +import { moveToExternalStorageState } from '@server/lib/video-state.js' +import { VideoModel } from '@server/models/video/video.js' +import { VideoState, VideoStorage } from '@peertube/peertube-models' program .description('Move videos to another storage.') diff --git a/scripts/migrations/peertube-4.0.ts b/server/scripts/migrations/peertube-4.0.ts similarity index 86% rename from scripts/migrations/peertube-4.0.ts rename to server/scripts/migrations/peertube-4.0.ts index b0891c2e6..619c1da71 100644 --- a/scripts/migrations/peertube-4.0.ts +++ b/server/scripts/migrations/peertube-4.0.ts @@ -1,19 +1,25 @@ import Bluebird from 'bluebird' -import { move, readFile, writeFile } from 'fs-extra' +import { move } from 'fs-extra/esm' +import { readFile, writeFile } from 'fs/promises' import { join } from 'path' -import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' -import { JobQueue } from '@server/lib/job-queue' -import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename, getHlsResolutionPlaylistFilename } from '@server/lib/paths' -import { VideoPathManager } from '@server/lib/video-path-manager' -import { VideoModel } from '@server/models/video/video' -import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' -import { initDatabaseModels } from '../../server/initializers/database' +import { initDatabaseModels } from '@server/initializers/database.js' +import { federateVideoIfNeeded } from '@server/lib/activitypub/videos/index.js' +import { JobQueue } from '@server/lib/job-queue/index.js' +import { + generateHLSMasterPlaylistFilename, + generateHlsSha256SegmentsFilename, + getHlsResolutionPlaylistFilename +} from '@server/lib/paths.js' +import { VideoPathManager } from '@server/lib/video-path-manager.js' +import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist.js' +import { VideoModel } from '@server/models/video/video.js' run() .then(() => process.exit(0)) .catch(err => { console.error(err) process.exit(-1) + }) async function run () { diff --git a/scripts/migrations/peertube-4.2.ts b/server/scripts/migrations/peertube-4.2.ts similarity index 82% rename from scripts/migrations/peertube-4.2.ts rename to server/scripts/migrations/peertube-4.2.ts index d8929692b..6c89ee39e 100644 --- a/scripts/migrations/peertube-4.2.ts +++ b/server/scripts/migrations/peertube-4.2.ts @@ -1,20 +1,19 @@ -import { minBy } from 'lodash' +import { ActorImageType } from '@peertube/peertube-models' +import { buildUUID, getLowercaseExtension } from '@peertube/peertube-node-utils' +import { getImageSize, processImage } from '@server/helpers/image-utils.js' +import { CONFIG } from '@server/initializers/config.js' +import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants.js' +import { initDatabaseModels } from '@server/initializers/database.js' +import { updateActorImages } from '@server/lib/activitypub/actors/index.js' +import { sendUpdateActor } from '@server/lib/activitypub/send/index.js' +import { getBiggestActorImage } from '@server/lib/actor-image.js' +import { JobQueue } from '@server/lib/job-queue/index.js' +import { AccountModel } from '@server/models/account/account.js' +import { ActorModel } from '@server/models/actor/actor.js' +import { VideoChannelModel } from '@server/models/video/video-channel.js' +import { MAccountDefault, MActorDefault, MChannelDefault } from '@server/types/models/index.js' +import minBy from 'lodash-es/minBy.js' import { join } from 'path' -import { getImageSize, processImage } from '@server/helpers/image-utils' -import { CONFIG } from '@server/initializers/config' -import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants' -import { updateActorImages } from '@server/lib/activitypub/actors' -import { sendUpdateActor } from '@server/lib/activitypub/send' -import { getBiggestActorImage } from '@server/lib/actor-image' -import { JobQueue } from '@server/lib/job-queue' -import { AccountModel } from '@server/models/account/account' -import { ActorModel } from '@server/models/actor/actor' -import { VideoChannelModel } from '@server/models/video/video-channel' -import { MAccountDefault, MActorDefault, MChannelDefault } from '@server/types/models' -import { getLowercaseExtension } from '@shared/core-utils' -import { buildUUID } from '@shared/extra-utils' -import { ActorImageType } from '@shared/models' -import { initDatabaseModels } from '../../server/initializers/database' run() .then(() => process.exit(0)) diff --git a/scripts/migrations/peertube-5.0.ts b/server/scripts/migrations/peertube-5.0.ts similarity index 81% rename from scripts/migrations/peertube-5.0.ts rename to server/scripts/migrations/peertube-5.0.ts index a0f51a64c..6139abd08 100644 --- a/scripts/migrations/peertube-5.0.ts +++ b/server/scripts/migrations/peertube-5.0.ts @@ -1,12 +1,12 @@ -import { ensureDir } from 'fs-extra' +import { ensureDir } from 'fs-extra/esm' import { Op } from 'sequelize' -import { updateTorrentMetadata } from '@server/helpers/webtorrent' -import { DIRECTORIES } from '@server/initializers/constants' -import { moveFilesIfPrivacyChanged } from '@server/lib/video-privacy' -import { VideoModel } from '@server/models/video/video' -import { MVideoFullLight } from '@server/types/models' -import { VideoPrivacy } from '@shared/models' -import { initDatabaseModels } from '../../server/initializers/database' +import { updateTorrentMetadata } from '@server/helpers/webtorrent.js' +import { DIRECTORIES } from '@server/initializers/constants.js' +import { moveFilesIfPrivacyChanged } from '@server/lib/video-privacy.js' +import { VideoModel } from '@server/models/video/video.js' +import { MVideoFullLight } from '@server/types/models/index.js' +import { VideoPrivacy } from '@peertube/peertube-models' +import { initDatabaseModels } from '@server/initializers/database.js' run() .then(() => process.exit(0)) diff --git a/scripts/parse-log.ts b/server/scripts/parse-log.ts similarity index 94% rename from scripts/parse-log.ts rename to server/scripts/parse-log.ts index 6770f090b..e80c0d927 100755 --- a/scripts/parse-log.ts +++ b/server/scripts/parse-log.ts @@ -1,13 +1,14 @@ import { program } from 'commander' -import { createReadStream, readdir } from 'fs-extra' +import { createReadStream } from 'fs' +import { readdir } from 'fs/promises' import { join } from 'path' import { stdin } from 'process' import { createInterface } from 'readline' import { format as sqlFormat } from 'sql-formatter' import { inspect } from 'util' import * as winston from 'winston' -import { labelFormatter, mtimeSortFilesDesc } from '../server/helpers/logger' -import { CONFIG } from '../server/initializers/config' +import { labelFormatter, mtimeSortFilesDesc } from '@server/helpers/logger.js' +import { CONFIG } from '@server/initializers/config.js' program .option('-l, --level [level]', 'Level log (debug/info/warn/error)') diff --git a/scripts/plugin/install.ts b/server/scripts/plugin/install.ts similarity index 98% rename from scripts/plugin/install.ts rename to server/scripts/plugin/install.ts index 138f34446..3b13120ff 100755 --- a/scripts/plugin/install.ts +++ b/server/scripts/plugin/install.ts @@ -1,7 +1,7 @@ import { program } from 'commander' import { isAbsolute } from 'path' -import { initDatabaseModels } from '../../server/initializers/database' -import { PluginManager } from '../../server/lib/plugins/plugin-manager' +import { initDatabaseModels } from '../../server/initializers/database.js' +import { PluginManager } from '../../server/lib/plugins/plugin-manager.js' program .option('-n, --npm-name [npmName]', 'Plugin to install') diff --git a/scripts/plugin/uninstall.ts b/server/scripts/plugin/uninstall.ts similarity index 79% rename from scripts/plugin/uninstall.ts rename to server/scripts/plugin/uninstall.ts index 770594685..baf0422c4 100755 --- a/scripts/plugin/uninstall.ts +++ b/server/scripts/plugin/uninstall.ts @@ -1,6 +1,6 @@ import { program } from 'commander' -import { initDatabaseModels } from '../../server/initializers/database' -import { PluginManager } from '../../server/lib/plugins/plugin-manager' +import { initDatabaseModels } from '@server/initializers/database.js' +import { PluginManager } from '@server/lib/plugins/plugin-manager.js' program .option('-n, --npm-name [npmName]', 'Package name to install') diff --git a/scripts/prune-storage.ts b/server/scripts/prune-storage.ts similarity index 86% rename from scripts/prune-storage.ts rename to server/scripts/prune-storage.ts index 9a73a8600..9309724b9 100755 --- a/scripts/prune-storage.ts +++ b/server/scripts/prune-storage.ts @@ -1,19 +1,20 @@ -import { map } from 'bluebird' -import { readdir, remove, stat } from 'fs-extra' +import Bluebird from 'bluebird' +import { remove } from 'fs-extra/esm' +import { readdir, stat } from 'fs/promises' import { basename, join } from 'path' -import { get, start } from 'prompt' -import { DIRECTORIES } from '@server/initializers/constants' -import { VideoFileModel } from '@server/models/video/video-file' -import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' -import { uniqify } from '@shared/core-utils' -import { ThumbnailType } from '@shared/models' -import { getUUIDFromFilename } from '../server/helpers/utils' -import { CONFIG } from '../server/initializers/config' -import { initDatabaseModels } from '../server/initializers/database' -import { ActorImageModel } from '../server/models/actor/actor-image' -import { VideoRedundancyModel } from '../server/models/redundancy/video-redundancy' -import { ThumbnailModel } from '../server/models/video/thumbnail' -import { VideoModel } from '../server/models/video/video' +import prompt from 'prompt' +import { uniqify } from '@peertube/peertube-core-utils' +import { ThumbnailType, ThumbnailType_Type } from '@peertube/peertube-models' +import { DIRECTORIES } from '@server/initializers/constants.js' +import { VideoFileModel } from '@server/models/video/video-file.js' +import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist.js' +import { getUUIDFromFilename } from '../server/helpers/utils.js' +import { CONFIG } from '../server/initializers/config.js' +import { initDatabaseModels } from '../server/initializers/database.js' +import { ActorImageModel } from '../server/models/actor/actor-image.js' +import { VideoRedundancyModel } from '../server/models/redundancy/video-redundancy.js' +import { ThumbnailModel } from '../server/models/video/thumbnail.js' +import { VideoModel } from '../server/models/video/video.js' run() .then(() => process.exit(0)) @@ -82,7 +83,7 @@ async function pruneDirectory (directory: string, existFun: ExistFun) { const files = await readdir(directory) const toDelete: string[] = [] - await map(files, async file => { + await Bluebird.map(files, async file => { const filePath = join(directory, file) if (await existFun(filePath) !== true) { @@ -115,7 +116,7 @@ function doesTorrentFileExist () { return (filePath: string) => VideoFileModel.doesOwnedTorrentFileExist(basename(filePath)) } -function doesThumbnailExist (keepOnlyOwned: boolean, type: ThumbnailType) { +function doesThumbnailExist (keepOnlyOwned: boolean, type: ThumbnailType_Type) { return async (filePath: string) => { const thumbnail = await ThumbnailModel.loadByFilename(basename(filePath), type) if (!thumbnail) return false @@ -162,7 +163,8 @@ async function doesRedundancyExist (filePath: string) { async function askConfirmation () { return new Promise((res, rej) => { - start() + prompt.start() + const schema = { properties: { confirm: { @@ -175,7 +177,8 @@ async function askConfirmation () { } } } - get(schema, function (err, result) { + + prompt.get(schema, function (err, result) { if (err) return rej(err) return res(result.confirm?.match(/y/) !== null) diff --git a/scripts/regenerate-thumbnails.ts b/server/scripts/regenerate-thumbnails.ts similarity index 85% rename from scripts/regenerate-thumbnails.ts rename to server/scripts/regenerate-thumbnails.ts index 061819387..d4346ce40 100644 --- a/scripts/regenerate-thumbnails.ts +++ b/server/scripts/regenerate-thumbnails.ts @@ -1,10 +1,10 @@ -import { map } from 'bluebird' +import Bluebird from 'bluebird' import { program } from 'commander' -import { pathExists, remove } from 'fs-extra' -import { generateImageFilename, processImage } from '@server/helpers/image-utils' -import { THUMBNAILS_SIZE } from '@server/initializers/constants' -import { initDatabaseModels } from '@server/initializers/database' -import { VideoModel } from '@server/models/video/video' +import { pathExists, remove } from 'fs-extra/esm' +import { generateImageFilename, processImage } from '@server/helpers/image-utils.js' +import { THUMBNAILS_SIZE } from '@server/initializers/constants.js' +import { initDatabaseModels } from '@server/initializers/database.js' +import { VideoModel } from '@server/models/video/video.js' program .description('Regenerate local thumbnails using preview files') @@ -19,7 +19,7 @@ async function run () { const ids = await VideoModel.listLocalIds() - await map(ids, id => { + await Bluebird.map(ids, id => { return processVideo(id) .catch(err => console.error('Cannot process video %d.', id, err)) }, { concurrency: 20 }) diff --git a/scripts/reset-password.ts b/server/scripts/reset-password.ts similarity index 79% rename from scripts/reset-password.ts rename to server/scripts/reset-password.ts index b2e5639fb..96e301ba9 100755 --- a/scripts/reset-password.ts +++ b/server/scripts/reset-password.ts @@ -1,7 +1,9 @@ import { program } from 'commander' -import { isUserPasswordValid } from '../server/helpers/custom-validators/users' -import { initDatabaseModels } from '../server/initializers/database' -import { UserModel } from '../server/models/user/user' +import readline from 'readline' +import { Writable } from 'stream' +import { isUserPasswordValid } from '@server/helpers/custom-validators/users.js' +import { initDatabaseModels } from '@server/initializers/database.js' +import { UserModel } from '@server/models/user/user.js' program .option('-u, --user [user]', 'User') @@ -24,8 +26,6 @@ initDatabaseModels(true) process.exit(-1) } - const readline = require('readline') - const Writable = require('stream').Writable const mutableStdout = new Writable({ write: function (_chunk, _encoding, callback) { callback() diff --git a/scripts/update-host.ts b/server/scripts/update-host.ts similarity index 84% rename from scripts/update-host.ts rename to server/scripts/update-host.ts index 1d17ce152..52ac4947a 100755 --- a/scripts/update-host.ts +++ b/server/scripts/update-host.ts @@ -1,21 +1,21 @@ -import { updateTorrentMetadata } from '@server/helpers/webtorrent' -import { getServerActor } from '@server/models/application/application' -import { WEBSERVER } from '../server/initializers/constants' -import { initDatabaseModels } from '../server/initializers/database' +import { updateTorrentMetadata } from '@server/helpers/webtorrent.js' +import { getServerActor } from '@server/models/application/application.js' +import { WEBSERVER } from '@server/initializers/constants.js' +import { initDatabaseModels } from '@server/initializers/database.js' import { getLocalAccountActivityPubUrl, getLocalVideoActivityPubUrl, getLocalVideoAnnounceActivityPubUrl, getLocalVideoChannelActivityPubUrl, getLocalVideoCommentActivityPubUrl -} from '../server/lib/activitypub/url' -import { AccountModel } from '../server/models/account/account' -import { ActorModel } from '../server/models/actor/actor' -import { ActorFollowModel } from '../server/models/actor/actor-follow' -import { VideoModel } from '../server/models/video/video' -import { VideoChannelModel } from '../server/models/video/video-channel' -import { VideoCommentModel } from '../server/models/video/video-comment' -import { VideoShareModel } from '../server/models/video/video-share' +} from '@server/lib/activitypub/url.js' +import { AccountModel } from '@server/models/account/account.js' +import { ActorFollowModel } from '@server/models/actor/actor-follow.js' +import { ActorModel } from '@server/models/actor/actor.js' +import { VideoChannelModel } from '@server/models/video/video-channel.js' +import { VideoCommentModel } from '@server/models/video/video-comment.js' +import { VideoShareModel } from '@server/models/video/video-share.js' +import { VideoModel } from '@server/models/video/video.js' run() .then(() => process.exit(0)) diff --git a/scripts/upgrade.sh b/server/scripts/upgrade.sh similarity index 100% rename from scripts/upgrade.sh rename to server/scripts/upgrade.sh diff --git a/server.ts b/server/server.ts similarity index 84% rename from server.ts rename to server/server.ts index 605b94be0..7f9c68ad9 100644 --- a/server.ts +++ b/server/server.ts @@ -1,28 +1,15 @@ -// ----------- Node modules ----------- -import { registerOpentelemetryTracing } from './server/lib/opentelemetry/tracing' -registerOpentelemetryTracing() - -import express from 'express' -import morgan, { token } from 'morgan' -import cors from 'cors' -import cookieParser from 'cookie-parser' -import { frameguard } from 'helmet' -import { parse } from 'useragent' -import anonymize from 'ip-anonymize' -import { program as cli } from 'commander' +import { registerOpentelemetryTracing } from '@server/lib/opentelemetry/tracing.js' +await registerOpentelemetryTracing() process.title = 'peertube' -// Create our main app -const app = express().disable('x-powered-by') - // ----------- Core checker ----------- -import { checkMissedConfig, checkFFmpeg, checkNodeVersion } from './server/initializers/checker-before-init' +import { checkMissedConfig, checkFFmpeg, checkNodeVersion } from './server/initializers/checker-before-init.js' // Do not use barrels because we don't want to load all modules here (we need to initialize database first) -import { CONFIG } from './server/initializers/config' -import { API_VERSION, WEBSERVER, loadLanguages } from './server/initializers/constants' -import { logger } from './server/helpers/logger' +import { CONFIG } from './server/initializers/config.js' +import { API_VERSION, WEBSERVER, loadLanguages } from './server/initializers/constants.js' +import { logger } from './server/helpers/logger.js' const missed = checkMissedConfig() if (missed.length !== 0) { @@ -43,7 +30,7 @@ try { process.exit(-1) } -import { checkConfig, checkActivityPubUrls, checkFFmpegVersion } from './server/initializers/checker-after-init' +import { checkConfig, checkActivityPubUrls, checkFFmpegVersion } from './server/initializers/checker-after-init.js' try { checkConfig() @@ -52,6 +39,37 @@ try { process.exit(-1) } +// ----------- Database ----------- + +// Initialize database and models +import { initDatabaseModels, checkDatabaseConnectionOrDie } from './server/initializers/database.js' +checkDatabaseConnectionOrDie() + +import { migrate } from './server/initializers/migrator.js' +migrate() + .then(() => initDatabaseModels(false)) + .then(() => startApplication()) + .catch(err => { + logger.error('Cannot start application.', { err }) + process.exit(-1) + }) + +// ----------- Initialize ----------- +loadLanguages() + .catch(err => logger.error('Cannot load languages', { err })) + +// Express configuration +import express from 'express' +import morgan, { token } from 'morgan' +import cors from 'cors' +import cookieParser from 'cookie-parser' +import { frameguard } from 'helmet' +import { parse } from 'useragent' +import anonymize from 'ip-anonymize' +import { program as cli } from 'commander' + +const app = express().disable('x-powered-by') + // Trust our proxy (IP forwarding...) app.set('trust proxy', CONFIG.TRUST_PROXY) @@ -67,7 +85,7 @@ app.use((_req, res, next) => { }) // Security middleware -import { baseCSP } from './server/middlewares/csp' +import { baseCSP } from './server/middlewares/csp.js' if (CONFIG.CSP.ENABLED) { app.use(baseCSP) @@ -79,28 +97,10 @@ if (CONFIG.SECURITY.FRAMEGUARD.ENABLED) { })) } -// ----------- Database ----------- - -// Initialize database and models -import { initDatabaseModels, checkDatabaseConnectionOrDie } from './server/initializers/database' -checkDatabaseConnectionOrDie() - -import { migrate } from './server/initializers/migrator' -migrate() - .then(() => initDatabaseModels(false)) - .then(() => startApplication()) - .catch(err => { - logger.error('Cannot start application.', { err }) - process.exit(-1) - }) - -// ----------- Initialize ----------- -loadLanguages() - // ----------- PeerTube modules ----------- -import { installApplication } from './server/initializers/installer' -import { Emailer } from './server/lib/emailer' -import { JobQueue } from './server/lib/job-queue' +import { installApplication } from './server/initializers/installer.js' +import { Emailer } from './server/lib/emailer.js' +import { JobQueue } from './server/lib/job-queue/index.js' import { activityPubRouter, apiRouter, @@ -117,36 +117,36 @@ import { createWebsocketTrackerServer, sitemapRouter, downloadRouter -} from './server/controllers' -import { advertiseDoNotTrack } from './server/middlewares/dnt' -import { apiFailMiddleware } from './server/middlewares/error' -import { Redis } from './server/lib/redis' -import { ActorFollowScheduler } from './server/lib/schedulers/actor-follow-scheduler' -import { RemoveOldViewsScheduler } from './server/lib/schedulers/remove-old-views-scheduler' -import { UpdateVideosScheduler } from './server/lib/schedulers/update-videos-scheduler' -import { YoutubeDlUpdateScheduler } from './server/lib/schedulers/youtube-dl-update-scheduler' -import { VideosRedundancyScheduler } from './server/lib/schedulers/videos-redundancy-scheduler' -import { RemoveOldHistoryScheduler } from './server/lib/schedulers/remove-old-history-scheduler' -import { AutoFollowIndexInstances } from './server/lib/schedulers/auto-follow-index-instances' -import { RemoveDanglingResumableUploadsScheduler } from './server/lib/schedulers/remove-dangling-resumable-uploads-scheduler' -import { VideoViewsBufferScheduler } from './server/lib/schedulers/video-views-buffer-scheduler' -import { GeoIPUpdateScheduler } from './server/lib/schedulers/geo-ip-update-scheduler' -import { RunnerJobWatchDogScheduler } from './server/lib/schedulers/runner-job-watch-dog-scheduler' -import { isHTTPSignatureDigestValid } from './server/helpers/peertube-crypto' -import { PeerTubeSocket } from './server/lib/peertube-socket' -import { updateStreamingPlaylistsInfohashesIfNeeded } from './server/lib/hls' -import { PluginsCheckScheduler } from './server/lib/schedulers/plugins-check-scheduler' -import { PeerTubeVersionCheckScheduler } from './server/lib/schedulers/peertube-version-check-scheduler' -import { Hooks } from './server/lib/plugins/hooks' -import { PluginManager } from './server/lib/plugins/plugin-manager' -import { LiveManager } from './server/lib/live' -import { HttpStatusCode } from './shared/models/http/http-error-codes' -import { ServerConfigManager } from '@server/lib/server-config-manager' -import { VideoViewsManager } from '@server/lib/views/video-views-manager' -import { isTestOrDevInstance } from './server/helpers/core-utils' -import { OpenTelemetryMetrics } from '@server/lib/opentelemetry/metrics' -import { ApplicationModel } from '@server/models/application/application' -import { VideoChannelSyncLatestScheduler } from '@server/lib/schedulers/video-channel-sync-latest-scheduler' +} from './server/controllers/index.js' +import { advertiseDoNotTrack } from './server/middlewares/dnt.js' +import { apiFailMiddleware } from './server/middlewares/error.js' +import { Redis } from './server/lib/redis.js' +import { ActorFollowScheduler } from './server/lib/schedulers/actor-follow-scheduler.js' +import { RemoveOldViewsScheduler } from './server/lib/schedulers/remove-old-views-scheduler.js' +import { UpdateVideosScheduler } from './server/lib/schedulers/update-videos-scheduler.js' +import { YoutubeDlUpdateScheduler } from './server/lib/schedulers/youtube-dl-update-scheduler.js' +import { VideosRedundancyScheduler } from './server/lib/schedulers/videos-redundancy-scheduler.js' +import { RemoveOldHistoryScheduler } from './server/lib/schedulers/remove-old-history-scheduler.js' +import { AutoFollowIndexInstances } from './server/lib/schedulers/auto-follow-index-instances.js' +import { RemoveDanglingResumableUploadsScheduler } from './server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.js' +import { VideoViewsBufferScheduler } from './server/lib/schedulers/video-views-buffer-scheduler.js' +import { GeoIPUpdateScheduler } from './server/lib/schedulers/geo-ip-update-scheduler.js' +import { RunnerJobWatchDogScheduler } from './server/lib/schedulers/runner-job-watch-dog-scheduler.js' +import { isHTTPSignatureDigestValid } from './server/helpers/peertube-crypto.js' +import { PeerTubeSocket } from './server/lib/peertube-socket.js' +import { updateStreamingPlaylistsInfohashesIfNeeded } from './server/lib/hls.js' +import { PluginsCheckScheduler } from './server/lib/schedulers/plugins-check-scheduler.js' +import { PeerTubeVersionCheckScheduler } from './server/lib/schedulers/peertube-version-check-scheduler.js' +import { Hooks } from './server/lib/plugins/hooks.js' +import { PluginManager } from './server/lib/plugins/plugin-manager.js' +import { LiveManager } from './server/lib/live/index.js' +import { HttpStatusCode } from '@peertube/peertube-models' +import { ServerConfigManager } from '@server/lib/server-config-manager.js' +import { VideoViewsManager } from '@server/lib/views/video-views-manager.js' +import { isTestOrDevInstance } from '@peertube/peertube-node-utils' +import { OpenTelemetryMetrics } from '@server/lib/opentelemetry/metrics.js' +import { ApplicationModel } from '@server/models/application/application.js' +import { VideoChannelSyncLatestScheduler } from '@server/lib/schedulers/video-channel-sync-latest-scheduler.js' // ----------- Command line ----------- diff --git a/server/assets/default-audio-background.jpg b/server/server/assets/default-audio-background.jpg similarity index 100% rename from server/assets/default-audio-background.jpg rename to server/server/assets/default-audio-background.jpg diff --git a/server/assets/default-live-background.jpg b/server/server/assets/default-live-background.jpg similarity index 100% rename from server/assets/default-live-background.jpg rename to server/server/assets/default-live-background.jpg diff --git a/server/controllers/activitypub/client.ts b/server/server/controllers/activitypub/client.ts similarity index 89% rename from server/controllers/activitypub/client.ts rename to server/server/controllers/activitypub/client.ts index be52f1662..5d5e43bf5 100644 --- a/server/controllers/activitypub/client.ts +++ b/server/server/controllers/activitypub/client.ts @@ -1,23 +1,23 @@ import cors from 'cors' import express from 'express' -import { activityPubCollectionPagination } from '@server/lib/activitypub/collection' -import { activityPubContextify } from '@server/lib/activitypub/context' -import { getServerActor } from '@server/models/application/application' -import { MAccountId, MActorId, MChannelId, MVideoId } from '@server/types/models' -import { VideoCommentObject } from '@shared/models' -import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos' -import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' -import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../../initializers/constants' -import { audiencify, getAudience } from '../../lib/activitypub/audience' -import { buildAnnounceWithVideoAudience, buildLikeActivity } from '../../lib/activitypub/send' -import { buildCreateActivity } from '../../lib/activitypub/send/send-create' -import { buildDislikeActivity } from '../../lib/activitypub/send/send-dislike' +import { VideoCommentObject, VideoPlaylistPrivacy, VideoPrivacy, VideoRateType } from '@peertube/peertube-models' +import { activityPubCollectionPagination } from '@server/lib/activitypub/collection.js' +import { getContextFilter } from '@server/lib/activitypub/context.js' +import { getServerActor } from '@server/models/application/application.js' +import { MAccountId, MActorId, MChannelId, MVideoId } from '@server/types/models/index.js' +import { activityPubContextify } from '../../helpers/activity-pub-utils.js' +import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../../initializers/constants.js' +import { audiencify, getAudience } from '../../lib/activitypub/audience.js' +import { buildAnnounceWithVideoAudience, buildLikeActivity } from '../../lib/activitypub/send/index.js' +import { buildCreateActivity } from '../../lib/activitypub/send/send-create.js' +import { buildDislikeActivity } from '../../lib/activitypub/send/send-dislike.js' import { getLocalVideoCommentsActivityPubUrl, getLocalVideoDislikesActivityPubUrl, getLocalVideoLikesActivityPubUrl, getLocalVideoSharesActivityPubUrl -} from '../../lib/activitypub/url' +} from '../../lib/activitypub/url.js' +import { cacheRoute } from '../../middlewares/cache/cache.js' import { activityPubRateLimiter, asyncMiddleware, @@ -27,18 +27,21 @@ import { videoChannelsNameWithHostValidator, videosCustomGetValidator, videosShareValidator -} from '../../middlewares' -import { cacheRoute } from '../../middlewares/cache/cache' -import { getAccountVideoRateValidatorFactory, getVideoLocalViewerValidator, videoCommentGetValidator } from '../../middlewares/validators' -import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy' -import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists' -import { AccountModel } from '../../models/account/account' -import { AccountVideoRateModel } from '../../models/account/account-video-rate' -import { ActorFollowModel } from '../../models/actor/actor-follow' -import { VideoCommentModel } from '../../models/video/video-comment' -import { VideoPlaylistModel } from '../../models/video/video-playlist' -import { VideoShareModel } from '../../models/video/video-share' -import { activityPubResponse } from './utils' +} from '../../middlewares/index.js' +import { + getAccountVideoRateValidatorFactory, + getVideoLocalViewerValidator, + videoCommentGetValidator +} from '../../middlewares/validators/index.js' +import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy.js' +import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists.js' +import { AccountVideoRateModel } from '../../models/account/account-video-rate.js' +import { AccountModel } from '../../models/account/account.js' +import { ActorFollowModel } from '../../models/actor/actor-follow.js' +import { VideoCommentModel } from '../../models/video/video-comment.js' +import { VideoPlaylistModel } from '../../models/video/video-playlist.js' +import { VideoShareModel } from '../../models/video/video-share.js' +import { activityPubResponse } from './utils.js' const activityPubClientRouter = express.Router() activityPubClientRouter.use(cors()) @@ -217,35 +220,35 @@ export { async function accountController (req: express.Request, res: express.Response) { const account = res.locals.account - return activityPubResponse(activityPubContextify(await account.toActivityPubObject(), 'Actor'), res) + return activityPubResponse(activityPubContextify(await account.toActivityPubObject(), 'Actor', getContextFilter()), res) } async function accountFollowersController (req: express.Request, res: express.Response) { const account = res.locals.account const activityPubResult = await actorFollowers(req, account.Actor) - return activityPubResponse(activityPubContextify(activityPubResult, 'Collection'), res) + return activityPubResponse(activityPubContextify(activityPubResult, 'Collection', getContextFilter()), res) } async function accountFollowingController (req: express.Request, res: express.Response) { const account = res.locals.account const activityPubResult = await actorFollowing(req, account.Actor) - return activityPubResponse(activityPubContextify(activityPubResult, 'Collection'), res) + return activityPubResponse(activityPubContextify(activityPubResult, 'Collection', getContextFilter()), res) } async function accountPlaylistsController (req: express.Request, res: express.Response) { const account = res.locals.account const activityPubResult = await actorPlaylists(req, { account }) - return activityPubResponse(activityPubContextify(activityPubResult, 'Collection'), res) + return activityPubResponse(activityPubContextify(activityPubResult, 'Collection', getContextFilter()), res) } async function videoChannelPlaylistsController (req: express.Request, res: express.Response) { const channel = res.locals.videoChannel const activityPubResult = await actorPlaylists(req, { channel }) - return activityPubResponse(activityPubContextify(activityPubResult, 'Collection'), res) + return activityPubResponse(activityPubContextify(activityPubResult, 'Collection', getContextFilter()), res) } function getAccountVideoRateFactory (rateType: VideoRateType) { @@ -257,7 +260,7 @@ function getAccountVideoRateFactory (rateType: VideoRateType) { ? buildLikeActivity(accountVideoRate.url, byActor, accountVideoRate.Video) : buildDislikeActivity(accountVideoRate.url, byActor, accountVideoRate.Video) - return activityPubResponse(activityPubContextify(APObject, 'Rate'), res) + return activityPubResponse(activityPubContextify(APObject, 'Rate', getContextFilter()), res) } } @@ -274,10 +277,10 @@ async function videoController (req: express.Request, res: express.Response) { if (req.path.endsWith('/activity')) { const data = buildCreateActivity(videoAP.url, video.VideoChannel.Account.Actor, videoObject, audience) - return activityPubResponse(activityPubContextify(data, 'Video'), res) + return activityPubResponse(activityPubContextify(data, 'Video', getContextFilter()), res) } - return activityPubResponse(activityPubContextify(videoObject, 'Video'), res) + return activityPubResponse(activityPubContextify(videoObject, 'Video', getContextFilter()), res) } async function videoAnnounceController (req: express.Request, res: express.Response) { @@ -287,7 +290,7 @@ async function videoAnnounceController (req: express.Request, res: express.Respo const { activity } = await buildAnnounceWithVideoAudience(share.Actor, share, res.locals.videoAll, undefined) - return activityPubResponse(activityPubContextify(activity, 'Announce'), res) + return activityPubResponse(activityPubContextify(activity, 'Announce', getContextFilter()), res) } async function videoAnnouncesController (req: express.Request, res: express.Response) { @@ -304,7 +307,7 @@ async function videoAnnouncesController (req: express.Request, res: express.Resp } const json = await activityPubCollectionPagination(getLocalVideoSharesActivityPubUrl(video), handler, req.query.page) - return activityPubResponse(activityPubContextify(json, 'Collection'), res) + return activityPubResponse(activityPubContextify(json, 'Collection', getContextFilter()), res) } async function videoLikesController (req: express.Request, res: express.Response) { @@ -314,7 +317,7 @@ async function videoLikesController (req: express.Request, res: express.Response const json = await videoRates(req, 'like', video, getLocalVideoLikesActivityPubUrl(video)) - return activityPubResponse(activityPubContextify(json, 'Collection'), res) + return activityPubResponse(activityPubContextify(json, 'Collection', getContextFilter()), res) } async function videoDislikesController (req: express.Request, res: express.Response) { @@ -324,7 +327,7 @@ async function videoDislikesController (req: express.Request, res: express.Respo const json = await videoRates(req, 'dislike', video, getLocalVideoDislikesActivityPubUrl(video)) - return activityPubResponse(activityPubContextify(json, 'Collection'), res) + return activityPubResponse(activityPubContextify(json, 'Collection', getContextFilter()), res) } async function videoCommentsController (req: express.Request, res: express.Response) { @@ -342,27 +345,27 @@ async function videoCommentsController (req: express.Request, res: express.Respo } const json = await activityPubCollectionPagination(getLocalVideoCommentsActivityPubUrl(video), handler, req.query.page) - return activityPubResponse(activityPubContextify(json, 'Collection'), res) + return activityPubResponse(activityPubContextify(json, 'Collection', getContextFilter()), res) } async function videoChannelController (req: express.Request, res: express.Response) { const videoChannel = res.locals.videoChannel - return activityPubResponse(activityPubContextify(await videoChannel.toActivityPubObject(), 'Actor'), res) + return activityPubResponse(activityPubContextify(await videoChannel.toActivityPubObject(), 'Actor', getContextFilter()), res) } async function videoChannelFollowersController (req: express.Request, res: express.Response) { const videoChannel = res.locals.videoChannel const activityPubResult = await actorFollowers(req, videoChannel.Actor) - return activityPubResponse(activityPubContextify(activityPubResult, 'Collection'), res) + return activityPubResponse(activityPubContextify(activityPubResult, 'Collection', getContextFilter()), res) } async function videoChannelFollowingController (req: express.Request, res: express.Response) { const videoChannel = res.locals.videoChannel const activityPubResult = await actorFollowing(req, videoChannel.Actor) - return activityPubResponse(activityPubContextify(activityPubResult, 'Collection'), res) + return activityPubResponse(activityPubContextify(activityPubResult, 'Collection', getContextFilter()), res) } async function videoCommentController (req: express.Request, res: express.Response) { @@ -380,11 +383,11 @@ async function videoCommentController (req: express.Request, res: express.Respon if (req.path.endsWith('/activity')) { const data = buildCreateActivity(videoComment.url, videoComment.Account.Actor, videoCommentObject as VideoCommentObject, audience) - return activityPubResponse(activityPubContextify(data, 'Comment'), res) + return activityPubResponse(activityPubContextify(data, 'Comment', getContextFilter()), res) } } - return activityPubResponse(activityPubContextify(videoCommentObject, 'Comment'), res) + return activityPubResponse(activityPubContextify(videoCommentObject, 'Comment', getContextFilter()), res) } async function videoRedundancyController (req: express.Request, res: express.Response) { @@ -399,10 +402,10 @@ async function videoRedundancyController (req: express.Request, res: express.Res if (req.path.endsWith('/activity')) { const data = buildCreateActivity(videoRedundancy.url, serverActor, object, audience) - return activityPubResponse(activityPubContextify(data, 'CacheFile'), res) + return activityPubResponse(activityPubContextify(data, 'CacheFile', getContextFilter()), res) } - return activityPubResponse(activityPubContextify(object, 'CacheFile'), res) + return activityPubResponse(activityPubContextify(object, 'CacheFile', getContextFilter()), res) } async function videoPlaylistController (req: express.Request, res: express.Response) { @@ -417,7 +420,7 @@ async function videoPlaylistController (req: express.Request, res: express.Respo const audience = getAudience(playlist.OwnerAccount.Actor, playlist.privacy === VideoPlaylistPrivacy.PUBLIC) const object = audiencify(json, audience) - return activityPubResponse(activityPubContextify(object, 'Playlist'), res) + return activityPubResponse(activityPubContextify(object, 'Playlist', getContextFilter()), res) } function videoPlaylistElementController (req: express.Request, res: express.Response) { @@ -426,13 +429,13 @@ function videoPlaylistElementController (req: express.Request, res: express.Resp if (redirectIfNotOwned(videoPlaylistElement.url, res)) return const json = videoPlaylistElement.toActivityPubObject() - return activityPubResponse(activityPubContextify(json, 'Playlist'), res) + return activityPubResponse(activityPubContextify(json, 'Playlist', getContextFilter()), res) } function getVideoLocalViewerController (req: express.Request, res: express.Response) { const localViewer = res.locals.localViewerFull - return activityPubResponse(activityPubContextify(localViewer.toActivityPubObject(), 'WatchAction'), res) + return activityPubResponse(activityPubContextify(localViewer.toActivityPubObject(), 'WatchAction', getContextFilter()), res) } // --------------------------------------------------------------------------- diff --git a/server/controllers/activitypub/inbox.ts b/server/server/controllers/activitypub/inbox.ts similarity index 91% rename from server/controllers/activitypub/inbox.ts rename to server/server/controllers/activitypub/inbox.ts index 862c7baf1..6473cea06 100644 --- a/server/controllers/activitypub/inbox.ts +++ b/server/server/controllers/activitypub/inbox.ts @@ -1,9 +1,8 @@ import express from 'express' -import { InboxManager } from '@server/lib/activitypub/inbox-manager' -import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, RootActivity } from '@shared/models' -import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' -import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity' -import { logger } from '../../helpers/logger' +import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, HttpStatusCode, RootActivity } from '@peertube/peertube-models' +import { InboxManager } from '@server/lib/activitypub/inbox-manager.js' +import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity.js' +import { logger } from '../../helpers/logger.js' import { activityPubRateLimiter, asyncMiddleware, @@ -12,8 +11,8 @@ import { localAccountValidator, signatureValidator, videoChannelsNameWithHostValidator -} from '../../middlewares' -import { activityPubValidator } from '../../middlewares/validators/activitypub/activity' +} from '../../middlewares/index.js' +import { activityPubValidator } from '../../middlewares/validators/activitypub/activity.js' const inboxRouter = express.Router() diff --git a/server/controllers/activitypub/index.ts b/server/server/controllers/activitypub/index.ts similarity index 69% rename from server/controllers/activitypub/index.ts rename to server/server/controllers/activitypub/index.ts index c14d95108..7057457ee 100644 --- a/server/controllers/activitypub/index.ts +++ b/server/server/controllers/activitypub/index.ts @@ -1,8 +1,8 @@ import express from 'express' -import { activityPubClientRouter } from './client' -import { inboxRouter } from './inbox' -import { outboxRouter } from './outbox' +import { activityPubClientRouter } from './client.js' +import { inboxRouter } from './inbox.js' +import { outboxRouter } from './outbox.js' const activityPubRouter = express.Router() diff --git a/server/controllers/activitypub/outbox.ts b/server/server/controllers/activitypub/outbox.ts similarity index 80% rename from server/controllers/activitypub/outbox.ts rename to server/server/controllers/activitypub/outbox.ts index 8c88b6971..7714f8400 100644 --- a/server/controllers/activitypub/outbox.ts +++ b/server/server/controllers/activitypub/outbox.ts @@ -1,22 +1,22 @@ import express from 'express' -import { activityPubCollectionPagination } from '@server/lib/activitypub/collection' -import { activityPubContextify } from '@server/lib/activitypub/context' -import { MActorLight } from '@server/types/models' -import { Activity } from '../../../shared/models/activitypub/activity' -import { VideoPrivacy } from '../../../shared/models/videos' -import { logger } from '../../helpers/logger' -import { buildAudience } from '../../lib/activitypub/audience' -import { buildAnnounceActivity, buildCreateActivity } from '../../lib/activitypub/send' +import { Activity, VideoPrivacy } from '@peertube/peertube-models' +import { activityPubContextify } from '@server/helpers/activity-pub-utils.js' +import { activityPubCollectionPagination } from '@server/lib/activitypub/collection.js' +import { getContextFilter } from '@server/lib/activitypub/context.js' +import { MActorLight } from '@server/types/models/index.js' +import { logger } from '../../helpers/logger.js' +import { buildAudience } from '../../lib/activitypub/audience.js' +import { buildAnnounceActivity, buildCreateActivity } from '../../lib/activitypub/send/index.js' import { activityPubRateLimiter, asyncMiddleware, ensureIsLocalChannel, localAccountValidator, videoChannelsNameWithHostValidator -} from '../../middlewares' -import { apPaginationValidator } from '../../middlewares/validators/activitypub' -import { VideoModel } from '../../models/video/video' -import { activityPubResponse } from './utils' +} from '../../middlewares/index.js' +import { apPaginationValidator } from '../../middlewares/validators/activitypub/index.js' +import { VideoModel } from '../../models/video/video.js' +import { activityPubResponse } from './utils.js' const outboxRouter = express.Router() @@ -53,7 +53,7 @@ async function outboxController (req: express.Request, res: express.Response) { const handler = (start: number, count: number) => buildActivities(actor, start, count) const json = await activityPubCollectionPagination(actorOutboxUrl, handler, req.query.page, req.query.size) - return activityPubResponse(activityPubContextify(json, 'Collection'), res) + return activityPubResponse(activityPubContextify(json, 'Collection', getContextFilter()), res) } async function buildActivities (actor: MActorLight, start: number, count: number) { diff --git a/server/controllers/activitypub/utils.ts b/server/server/controllers/activitypub/utils.ts similarity index 100% rename from server/controllers/activitypub/utils.ts rename to server/server/controllers/activitypub/utils.ts diff --git a/server/controllers/api/abuse.ts b/server/server/controllers/api/abuse.ts similarity index 93% rename from server/controllers/api/abuse.ts rename to server/server/controllers/api/abuse.ts index d582f198d..78fd514c6 100644 --- a/server/controllers/api/abuse.ts +++ b/server/server/controllers/api/abuse.ts @@ -1,14 +1,14 @@ import express from 'express' -import { logger } from '@server/helpers/logger' -import { createAccountAbuse, createVideoAbuse, createVideoCommentAbuse } from '@server/lib/moderation' -import { Notifier } from '@server/lib/notifier' -import { AbuseModel } from '@server/models/abuse/abuse' -import { AbuseMessageModel } from '@server/models/abuse/abuse-message' -import { getServerActor } from '@server/models/application/application' -import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' -import { AbuseCreate, AbuseState, HttpStatusCode, UserRight } from '@shared/models' -import { getFormattedObjects } from '../../helpers/utils' -import { sequelizeTypescript } from '../../initializers/database' +import { logger } from '@server/helpers/logger.js' +import { createAccountAbuse, createVideoAbuse, createVideoCommentAbuse } from '@server/lib/moderation.js' +import { Notifier } from '@server/lib/notifier/index.js' +import { AbuseMessageModel } from '@server/models/abuse/abuse-message.js' +import { AbuseModel } from '@server/models/abuse/abuse.js' +import { getServerActor } from '@server/models/application/application.js' +import { abusePredefinedReasonsMap } from '@peertube/peertube-core-utils' +import { AbuseCreate, AbuseState, HttpStatusCode, UserRight } from '@peertube/peertube-models' +import { getFormattedObjects } from '../../helpers/utils.js' +import { sequelizeTypescript } from '../../initializers/database.js' import { abuseGetValidator, abuseListForAdminsValidator, @@ -28,8 +28,8 @@ import { paginationValidator, setDefaultPagination, setDefaultSort -} from '../../middlewares' -import { AccountModel } from '../../models/account/account' +} from '../../middlewares/index.js' +import { AccountModel } from '../../models/account/account.js' const abuseRouter = express.Router() diff --git a/server/controllers/api/accounts.ts b/server/server/controllers/api/accounts.ts similarity index 92% rename from server/controllers/api/accounts.ts rename to server/server/controllers/api/accounts.ts index 49cd7559a..b5fd4d133 100644 --- a/server/controllers/api/accounts.ts +++ b/server/server/controllers/api/accounts.ts @@ -1,12 +1,12 @@ import express from 'express' -import { pickCommonVideoQuery } from '@server/helpers/query' -import { ActorFollowModel } from '@server/models/actor/actor-follow' -import { getServerActor } from '@server/models/application/application' -import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync' -import { buildNSFWFilter, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' -import { getFormattedObjects } from '../../helpers/utils' -import { JobQueue } from '../../lib/job-queue' -import { Hooks } from '../../lib/plugins/hooks' +import { pickCommonVideoQuery } from '@server/helpers/query.js' +import { ActorFollowModel } from '@server/models/actor/actor-follow.js' +import { getServerActor } from '@server/models/application/application.js' +import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync.js' +import { buildNSFWFilter, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils.js' +import { getFormattedObjects } from '../../helpers/utils.js' +import { JobQueue } from '../../lib/job-queue/index.js' +import { Hooks } from '../../lib/plugins/hooks.js' import { apiRateLimiter, asyncMiddleware, @@ -20,7 +20,7 @@ import { videoPlaylistsSortValidator, videoRatesSortValidator, videoRatingValidator -} from '../../middlewares' +} from '../../middlewares/index.js' import { accountNameWithHostGetValidator, accountsFollowersSortValidator, @@ -31,14 +31,14 @@ import { videoChannelStatsValidator, videoChannelSyncsSortValidator, videosSortValidator -} from '../../middlewares/validators' -import { commonVideoPlaylistFiltersValidator, videoPlaylistsSearchValidator } from '../../middlewares/validators/videos/video-playlists' -import { AccountModel } from '../../models/account/account' -import { AccountVideoRateModel } from '../../models/account/account-video-rate' -import { guessAdditionalAttributesFromQuery } from '../../models/video/formatter' -import { VideoModel } from '../../models/video/video' -import { VideoChannelModel } from '../../models/video/video-channel' -import { VideoPlaylistModel } from '../../models/video/video-playlist' +} from '../../middlewares/validators/index.js' +import { commonVideoPlaylistFiltersValidator, videoPlaylistsSearchValidator } from '../../middlewares/validators/videos/video-playlists.js' +import { AccountModel } from '../../models/account/account.js' +import { AccountVideoRateModel } from '../../models/account/account-video-rate.js' +import { guessAdditionalAttributesFromQuery } from '../../models/video/formatter/index.js' +import { VideoModel } from '../../models/video/video.js' +import { VideoChannelModel } from '../../models/video/video-channel.js' +import { VideoPlaylistModel } from '../../models/video/video-playlist.js' const accountsRouter = express.Router() diff --git a/server/controllers/api/blocklist.ts b/server/server/controllers/api/blocklist.ts similarity index 91% rename from server/controllers/api/blocklist.ts rename to server/server/controllers/api/blocklist.ts index dee12b108..08049431d 100644 --- a/server/controllers/api/blocklist.ts +++ b/server/server/controllers/api/blocklist.ts @@ -1,12 +1,12 @@ import express from 'express' -import { handleToNameAndHost } from '@server/helpers/actors' -import { logger } from '@server/helpers/logger' -import { AccountBlocklistModel } from '@server/models/account/account-blocklist' -import { getServerActor } from '@server/models/application/application' -import { ServerBlocklistModel } from '@server/models/server/server-blocklist' -import { MActorAccountId, MUserAccountId } from '@server/types/models' -import { BlockStatus } from '@shared/models' -import { apiRateLimiter, asyncMiddleware, blocklistStatusValidator, optionalAuthenticate } from '../../middlewares' +import { handleToNameAndHost } from '@server/helpers/actors.js' +import { logger } from '@server/helpers/logger.js' +import { AccountBlocklistModel } from '@server/models/account/account-blocklist.js' +import { getServerActor } from '@server/models/application/application.js' +import { ServerBlocklistModel } from '@server/models/server/server-blocklist.js' +import { MActorAccountId, MUserAccountId } from '@server/types/models/index.js' +import { BlockStatus } from '@peertube/peertube-models' +import { apiRateLimiter, asyncMiddleware, blocklistStatusValidator, optionalAuthenticate } from '../../middlewares/index.js' const blocklistRouter = express.Router() diff --git a/server/controllers/api/bulk.ts b/server/server/controllers/api/bulk.ts similarity index 82% rename from server/controllers/api/bulk.ts rename to server/server/controllers/api/bulk.ts index c41c7d378..829482b4a 100644 --- a/server/controllers/api/bulk.ts +++ b/server/server/controllers/api/bulk.ts @@ -1,10 +1,9 @@ import express from 'express' -import { removeComment } from '@server/lib/video-comment' -import { bulkRemoveCommentsOfValidator } from '@server/middlewares/validators/bulk' -import { VideoCommentModel } from '@server/models/video/video-comment' -import { HttpStatusCode } from '@shared/models' -import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model' -import { apiRateLimiter, asyncMiddleware, authenticate } from '../../middlewares' +import { BulkRemoveCommentsOfBody, HttpStatusCode } from '@peertube/peertube-models' +import { removeComment } from '@server/lib/video-comment.js' +import { bulkRemoveCommentsOfValidator } from '@server/middlewares/validators/bulk.js' +import { VideoCommentModel } from '@server/models/video/video-comment.js' +import { apiRateLimiter, asyncMiddleware, authenticate } from '../../middlewares/index.js' const bulkRouter = express.Router() diff --git a/server/controllers/api/config.ts b/server/server/controllers/api/config.ts similarity index 94% rename from server/controllers/api/config.ts rename to server/server/controllers/api/config.ts index c5c4c8a74..58469e97c 100644 --- a/server/controllers/api/config.ts +++ b/server/server/controllers/api/config.ts @@ -1,15 +1,15 @@ import express from 'express' -import { remove, writeJSON } from 'fs-extra' -import { snakeCase } from 'lodash' +import { remove, writeJSON } from 'fs-extra/esm' +import snakeCase from 'lodash-es/snakeCase.js' import validator from 'validator' -import { ServerConfigManager } from '@server/lib/server-config-manager' -import { About, CustomConfig, UserRight } from '@shared/models' -import { auditLoggerFactory, CustomConfigAuditView, getAuditIdFromRes } from '../../helpers/audit-logger' -import { objectConverter } from '../../helpers/core-utils' -import { CONFIG, reloadConfig } from '../../initializers/config' -import { ClientHtml } from '../../lib/client-html' -import { apiRateLimiter, asyncMiddleware, authenticate, ensureUserHasRight, openapiOperationDoc } from '../../middlewares' -import { customConfigUpdateValidator, ensureConfigIsEditable } from '../../middlewares/validators/config' +import { ServerConfigManager } from '@server/lib/server-config-manager.js' +import { About, CustomConfig, UserRight } from '@peertube/peertube-models' +import { auditLoggerFactory, CustomConfigAuditView, getAuditIdFromRes } from '../../helpers/audit-logger.js' +import { objectConverter } from '../../helpers/core-utils.js' +import { CONFIG, reloadConfig } from '../../initializers/config.js' +import { ClientHtml } from '../../lib/client-html.js' +import { apiRateLimiter, asyncMiddleware, authenticate, ensureUserHasRight, openapiOperationDoc } from '../../middlewares/index.js' +import { customConfigUpdateValidator, ensureConfigIsEditable } from '../../middlewares/validators/config.js' const configRouter = express.Router() @@ -93,7 +93,7 @@ async function deleteCustomConfig (req: express.Request, res: express.Response) auditLogger.delete(getAuditIdFromRes(res), new CustomConfigAuditView(customConfig())) - reloadConfig() + await reloadConfig() ClientHtml.invalidCache() const data = customConfig() @@ -109,7 +109,7 @@ async function updateCustomConfig (req: express.Request, res: express.Response) await writeJSON(CONFIG.CUSTOM_FILE, toUpdateJSON, { spaces: 2 }) - reloadConfig() + await reloadConfig() ClientHtml.invalidCache() const data = customConfig() @@ -368,7 +368,7 @@ function convertCustomConfigBody (body: CustomConfig) { } function valueConverter (v: any) { - if (validator.isNumeric(v + '')) return parseInt('' + v, 10) + if (validator.default.isNumeric(v + '')) return parseInt('' + v, 10) return v } diff --git a/server/controllers/api/custom-page.ts b/server/server/controllers/api/custom-page.ts similarity index 90% rename from server/controllers/api/custom-page.ts rename to server/server/controllers/api/custom-page.ts index f4e1a0e79..0be8d46c6 100644 --- a/server/controllers/api/custom-page.ts +++ b/server/server/controllers/api/custom-page.ts @@ -1,8 +1,8 @@ import express from 'express' -import { ServerConfigManager } from '@server/lib/server-config-manager' -import { ActorCustomPageModel } from '@server/models/account/actor-custom-page' -import { HttpStatusCode, UserRight } from '@shared/models' -import { apiRateLimiter, asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' +import { ServerConfigManager } from '@server/lib/server-config-manager.js' +import { ActorCustomPageModel } from '@server/models/account/actor-custom-page.js' +import { HttpStatusCode, UserRight } from '@peertube/peertube-models' +import { apiRateLimiter, asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares/index.js' const customPageRouter = express.Router() diff --git a/server/controllers/api/index.ts b/server/server/controllers/api/index.ts similarity index 61% rename from server/controllers/api/index.ts rename to server/server/controllers/api/index.ts index 38bd135d0..cb5d59802 100644 --- a/server/controllers/api/index.ts +++ b/server/server/controllers/api/index.ts @@ -1,26 +1,26 @@ import cors from 'cors' import express from 'express' -import { logger } from '@server/helpers/logger' -import { HttpStatusCode } from '../../../shared/models' -import { abuseRouter } from './abuse' -import { accountsRouter } from './accounts' -import { blocklistRouter } from './blocklist' -import { bulkRouter } from './bulk' -import { configRouter } from './config' -import { customPageRouter } from './custom-page' -import { jobsRouter } from './jobs' -import { metricsRouter } from './metrics' -import { oauthClientsRouter } from './oauth-clients' -import { overviewsRouter } from './overviews' -import { pluginRouter } from './plugins' -import { runnersRouter } from './runners' -import { searchRouter } from './search' -import { serverRouter } from './server' -import { usersRouter } from './users' -import { videoChannelRouter } from './video-channel' -import { videoChannelSyncRouter } from './video-channel-sync' -import { videoPlaylistRouter } from './video-playlist' -import { videosRouter } from './videos' +import { logger } from '@server/helpers/logger.js' +import { HttpStatusCode } from '@peertube/peertube-models' +import { abuseRouter } from './abuse.js' +import { accountsRouter } from './accounts.js' +import { blocklistRouter } from './blocklist.js' +import { bulkRouter } from './bulk.js' +import { configRouter } from './config.js' +import { customPageRouter } from './custom-page.js' +import { jobsRouter } from './jobs.js' +import { metricsRouter } from './metrics.js' +import { oauthClientsRouter } from './oauth-clients.js' +import { overviewsRouter } from './overviews.js' +import { pluginRouter } from './plugins.js' +import { runnersRouter } from './runners/index.js' +import { searchRouter } from './search/index.js' +import { serverRouter } from './server/index.js' +import { usersRouter } from './users/index.js' +import { videoChannelSyncRouter } from './video-channel-sync.js' +import { videoChannelRouter } from './video-channel.js' +import { videoPlaylistRouter } from './video-playlist.js' +import { videosRouter } from './videos/index.js' const apiRouter = express.Router() diff --git a/server/controllers/api/jobs.ts b/server/server/controllers/api/jobs.ts similarity index 92% rename from server/controllers/api/jobs.ts rename to server/server/controllers/api/jobs.ts index c701bc970..9a86d2a1e 100644 --- a/server/controllers/api/jobs.ts +++ b/server/server/controllers/api/jobs.ts @@ -1,8 +1,8 @@ import { Job as BullJob } from 'bullmq' import express from 'express' -import { HttpStatusCode, Job, JobState, JobType, ResultList, UserRight } from '@shared/models' -import { isArray } from '../../helpers/custom-validators/misc' -import { JobQueue } from '../../lib/job-queue' +import { HttpStatusCode, Job, JobState, JobType, ResultList, UserRight } from '@peertube/peertube-models' +import { isArray } from '../../helpers/custom-validators/misc.js' +import { JobQueue } from '../../lib/job-queue/index.js' import { apiRateLimiter, asyncMiddleware, @@ -13,8 +13,8 @@ import { paginationValidatorBuilder, setDefaultPagination, setDefaultSort -} from '../../middlewares' -import { listJobsValidator } from '../../middlewares/validators/jobs' +} from '../../middlewares/index.js' +import { listJobsValidator } from '../../middlewares/validators/jobs.js' const jobsRouter = express.Router() diff --git a/server/controllers/api/metrics.ts b/server/server/controllers/api/metrics.ts similarity index 82% rename from server/controllers/api/metrics.ts rename to server/server/controllers/api/metrics.ts index 909963fa7..42299817f 100644 --- a/server/controllers/api/metrics.ts +++ b/server/server/controllers/api/metrics.ts @@ -1,8 +1,8 @@ import express from 'express' -import { CONFIG } from '@server/initializers/config' -import { OpenTelemetryMetrics } from '@server/lib/opentelemetry/metrics' -import { HttpStatusCode, PlaybackMetricCreate } from '@shared/models' -import { addPlaybackMetricValidator, apiRateLimiter, asyncMiddleware } from '../../middlewares' +import { CONFIG } from '@server/initializers/config.js' +import { OpenTelemetryMetrics } from '@server/lib/opentelemetry/metrics.js' +import { HttpStatusCode, PlaybackMetricCreate } from '@peertube/peertube-models' +import { addPlaybackMetricValidator, apiRateLimiter, asyncMiddleware } from '../../middlewares/index.js' const metricsRouter = express.Router() diff --git a/server/controllers/api/oauth-clients.ts b/server/server/controllers/api/oauth-clients.ts similarity index 84% rename from server/controllers/api/oauth-clients.ts rename to server/server/controllers/api/oauth-clients.ts index 1899dbb02..a9ed9e330 100644 --- a/server/controllers/api/oauth-clients.ts +++ b/server/server/controllers/api/oauth-clients.ts @@ -1,10 +1,10 @@ import express from 'express' -import { isTestOrDevInstance } from '@server/helpers/core-utils' -import { OAuthClientModel } from '@server/models/oauth/oauth-client' -import { HttpStatusCode, OAuthClientLocal } from '@shared/models' -import { logger } from '../../helpers/logger' -import { CONFIG } from '../../initializers/config' -import { apiRateLimiter, asyncMiddleware, openapiOperationDoc } from '../../middlewares' +import { HttpStatusCode, OAuthClientLocal } from '@peertube/peertube-models' +import { isTestOrDevInstance } from '@peertube/peertube-node-utils' +import { OAuthClientModel } from '@server/models/oauth/oauth-client.js' +import { logger } from '../../helpers/logger.js' +import { CONFIG } from '../../initializers/config.js' +import { apiRateLimiter, asyncMiddleware, openapiOperationDoc } from '../../middlewares/index.js' const oauthClientsRouter = express.Router() diff --git a/server/controllers/api/overviews.ts b/server/server/controllers/api/overviews.ts similarity index 90% rename from server/controllers/api/overviews.ts rename to server/server/controllers/api/overviews.ts index fc616281e..a34669662 100644 --- a/server/controllers/api/overviews.ts +++ b/server/server/controllers/api/overviews.ts @@ -1,14 +1,14 @@ import express from 'express' import memoizee from 'memoizee' -import { logger } from '@server/helpers/logger' -import { Hooks } from '@server/lib/plugins/hooks' -import { getServerActor } from '@server/models/application/application' -import { VideoModel } from '@server/models/video/video' -import { CategoryOverview, ChannelOverview, TagOverview, VideosOverview } from '../../../shared/models/overviews' -import { buildNSFWFilter } from '../../helpers/express-utils' -import { MEMOIZE_TTL, OVERVIEWS } from '../../initializers/constants' -import { apiRateLimiter, asyncMiddleware, optionalAuthenticate, videosOverviewValidator } from '../../middlewares' -import { TagModel } from '../../models/video/tag' +import { logger } from '@server/helpers/logger.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { getServerActor } from '@server/models/application/application.js' +import { VideoModel } from '@server/models/video/video.js' +import { CategoryOverview, ChannelOverview, TagOverview, VideosOverview } from '@peertube/peertube-models' +import { buildNSFWFilter } from '../../helpers/express-utils.js' +import { MEMOIZE_TTL, OVERVIEWS } from '../../initializers/constants.js' +import { apiRateLimiter, asyncMiddleware, optionalAuthenticate, videosOverviewValidator } from '../../middlewares/index.js' +import { TagModel } from '../../models/video/tag.js' const overviewsRouter = express.Router() diff --git a/server/controllers/api/plugins.ts b/server/server/controllers/api/plugins.ts similarity index 95% rename from server/controllers/api/plugins.ts rename to server/server/controllers/api/plugins.ts index 337b72b2f..85e458c9e 100644 --- a/server/controllers/api/plugins.ts +++ b/server/server/controllers/api/plugins.ts @@ -1,8 +1,8 @@ import express from 'express' -import { logger } from '@server/helpers/logger' -import { getFormattedObjects } from '@server/helpers/utils' -import { listAvailablePluginsFromIndex } from '@server/lib/plugins/plugin-index' -import { PluginManager } from '@server/lib/plugins/plugin-manager' +import { logger } from '@server/helpers/logger.js' +import { getFormattedObjects } from '@server/helpers/utils.js' +import { listAvailablePluginsFromIndex } from '@server/lib/plugins/plugin-index.js' +import { PluginManager } from '@server/lib/plugins/plugin-manager.js' import { apiRateLimiter, asyncMiddleware, @@ -14,7 +14,7 @@ import { pluginsSortValidator, setDefaultPagination, setDefaultSort -} from '@server/middlewares' +} from '@server/middlewares/index.js' import { existingPluginValidator, installOrUpdatePluginValidator, @@ -22,8 +22,8 @@ import { listPluginsValidator, uninstallPluginValidator, updatePluginSettingsValidator -} from '@server/middlewares/validators/plugins' -import { PluginModel } from '@server/models/server/plugin' +} from '@server/middlewares/validators/plugins.js' +import { PluginModel } from '@server/models/server/plugin.js' import { HttpStatusCode, InstallOrUpdatePlugin, @@ -32,7 +32,7 @@ import { PublicServerSetting, RegisteredServerSettings, UserRight -} from '@shared/models' +} from '@peertube/peertube-models' const pluginRouter = express.Router() diff --git a/server/controllers/api/runners/index.ts b/server/server/controllers/api/runners/index.ts similarity index 74% rename from server/controllers/api/runners/index.ts rename to server/server/controllers/api/runners/index.ts index 9998fe4cc..b5cec3d1a 100644 --- a/server/controllers/api/runners/index.ts +++ b/server/server/controllers/api/runners/index.ts @@ -1,8 +1,8 @@ import express from 'express' -import { runnerJobsRouter } from './jobs' -import { runnerJobFilesRouter } from './jobs-files' -import { manageRunnersRouter } from './manage-runners' -import { runnerRegistrationTokensRouter } from './registration-tokens' +import { runnerJobsRouter } from './jobs.js' +import { runnerJobFilesRouter } from './jobs-files.js' +import { manageRunnersRouter } from './manage-runners.js' +import { runnerRegistrationTokensRouter } from './registration-tokens.js' const runnersRouter = express.Router() diff --git a/server/controllers/api/runners/jobs-files.ts b/server/server/controllers/api/runners/jobs-files.ts similarity index 92% rename from server/controllers/api/runners/jobs-files.ts rename to server/server/controllers/api/runners/jobs-files.ts index d28f43701..91a7302b8 100644 --- a/server/controllers/api/runners/jobs-files.ts +++ b/server/server/controllers/api/runners/jobs-files.ts @@ -1,15 +1,15 @@ import express from 'express' -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { proxifyHLS, proxifyWebVideoFile } from '@server/lib/object-storage' -import { VideoPathManager } from '@server/lib/video-path-manager' -import { getStudioTaskFilePath } from '@server/lib/video-studio' -import { apiRateLimiter, asyncMiddleware } from '@server/middlewares' -import { jobOfRunnerGetValidatorFactory } from '@server/middlewares/validators/runners' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { proxifyHLS, proxifyWebVideoFile } from '@server/lib/object-storage/index.js' +import { VideoPathManager } from '@server/lib/video-path-manager.js' +import { getStudioTaskFilePath } from '@server/lib/video-studio.js' +import { apiRateLimiter, asyncMiddleware } from '@server/middlewares/index.js' +import { jobOfRunnerGetValidatorFactory } from '@server/middlewares/validators/runners/index.js' import { runnerJobGetVideoStudioTaskFileValidator, runnerJobGetVideoTranscodingFileValidator -} from '@server/middlewares/validators/runners/job-files' -import { RunnerJobState, VideoStorage } from '@shared/models' +} from '@server/middlewares/validators/runners/job-files.js' +import { RunnerJobState, VideoStorage } from '@peertube/peertube-models' const lTags = loggerTagsFactory('api', 'runner') diff --git a/server/controllers/api/runners/jobs.ts b/server/server/controllers/api/runners/jobs.ts similarity index 96% rename from server/controllers/api/runners/jobs.ts rename to server/server/controllers/api/runners/jobs.ts index e9e2ddf49..c7aada7c2 100644 --- a/server/controllers/api/runners/jobs.ts +++ b/server/server/controllers/api/runners/jobs.ts @@ -1,11 +1,11 @@ import express, { UploadFiles } from 'express' -import { retryTransactionWrapper } from '@server/helpers/database-utils' -import { createReqFiles } from '@server/helpers/express-utils' -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { generateRunnerJobToken } from '@server/helpers/token-generator' -import { MIMETYPES } from '@server/initializers/constants' -import { sequelizeTypescript } from '@server/initializers/database' -import { getRunnerJobHandlerClass, runnerJobCanBeCancelled, updateLastRunnerContact } from '@server/lib/runners' +import { retryTransactionWrapper } from '@server/helpers/database-utils.js' +import { createReqFiles } from '@server/helpers/express-utils.js' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { generateRunnerJobToken } from '@server/helpers/token-generator.js' +import { MIMETYPES } from '@server/initializers/constants.js' +import { sequelizeTypescript } from '@server/initializers/database.js' +import { getRunnerJobHandlerClass, runnerJobCanBeCancelled, updateLastRunnerContact } from '@server/lib/runners/index.js' import { apiRateLimiter, asyncMiddleware, @@ -15,7 +15,7 @@ import { runnerJobsSortValidator, setDefaultPagination, setDefaultSort -} from '@server/middlewares' +} from '@server/middlewares/index.js' import { abortRunnerJobValidator, acceptRunnerJobValidator, @@ -27,9 +27,9 @@ import { runnerJobGetValidator, successRunnerJobValidator, updateRunnerJobValidator -} from '@server/middlewares/validators/runners' -import { RunnerModel } from '@server/models/runner/runner' -import { RunnerJobModel } from '@server/models/runner/runner-job' +} from '@server/middlewares/validators/runners/index.js' +import { RunnerModel } from '@server/models/runner/runner.js' +import { RunnerJobModel } from '@server/models/runner/runner-job.js' import { AbortRunnerJobBody, AcceptRunnerJobResult, @@ -50,7 +50,7 @@ import { VODAudioMergeTranscodingSuccess, VODHLSTranscodingSuccess, VODWebVideoTranscodingSuccess -} from '@shared/models' +} from '@peertube/peertube-models' const postRunnerJobSuccessVideoFiles = createReqFiles( [ 'payload[videoFile]', 'payload[resolutionPlaylistFile]' ], diff --git a/server/controllers/api/runners/manage-runners.ts b/server/server/controllers/api/runners/manage-runners.ts similarity index 90% rename from server/controllers/api/runners/manage-runners.ts rename to server/server/controllers/api/runners/manage-runners.ts index be7ebc0b3..fb2199bea 100644 --- a/server/controllers/api/runners/manage-runners.ts +++ b/server/server/controllers/api/runners/manage-runners.ts @@ -1,6 +1,7 @@ import express from 'express' -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { generateRunnerToken } from '@server/helpers/token-generator' +import { HttpStatusCode, ListRunnersQuery, RegisterRunnerBody, UserRight } from '@peertube/peertube-models' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { generateRunnerToken } from '@server/helpers/token-generator.js' import { apiRateLimiter, asyncMiddleware, @@ -10,10 +11,13 @@ import { runnersSortValidator, setDefaultPagination, setDefaultSort -} from '@server/middlewares' -import { deleteRunnerValidator, getRunnerFromTokenValidator, registerRunnerValidator } from '@server/middlewares/validators/runners' -import { RunnerModel } from '@server/models/runner/runner' -import { HttpStatusCode, ListRunnersQuery, RegisterRunnerBody, UserRight } from '@shared/models' +} from '@server/middlewares/index.js' +import { + deleteRunnerValidator, + getRunnerFromTokenValidator, + registerRunnerValidator +} from '@server/middlewares/validators/runners/index.js' +import { RunnerModel } from '@server/models/runner/runner.js' const lTags = loggerTagsFactory('api', 'runner') diff --git a/server/controllers/api/runners/registration-tokens.ts b/server/server/controllers/api/runners/registration-tokens.ts similarity index 93% rename from server/controllers/api/runners/registration-tokens.ts rename to server/server/controllers/api/runners/registration-tokens.ts index 117ff271b..462c489bb 100644 --- a/server/controllers/api/runners/registration-tokens.ts +++ b/server/server/controllers/api/runners/registration-tokens.ts @@ -1,6 +1,6 @@ import express from 'express' -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { generateRunnerRegistrationToken } from '@server/helpers/token-generator' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { generateRunnerRegistrationToken } from '@server/helpers/token-generator.js' import { apiRateLimiter, asyncMiddleware, @@ -10,10 +10,10 @@ import { runnerRegistrationTokensSortValidator, setDefaultPagination, setDefaultSort -} from '@server/middlewares' -import { deleteRegistrationTokenValidator } from '@server/middlewares/validators/runners' -import { RunnerRegistrationTokenModel } from '@server/models/runner/runner-registration-token' -import { HttpStatusCode, ListRunnerRegistrationTokensQuery, UserRight } from '@shared/models' +} from '@server/middlewares/index.js' +import { deleteRegistrationTokenValidator } from '@server/middlewares/validators/runners/index.js' +import { RunnerRegistrationTokenModel } from '@server/models/runner/runner-registration-token.js' +import { HttpStatusCode, ListRunnerRegistrationTokensQuery, UserRight } from '@peertube/peertube-models' const lTags = loggerTagsFactory('api', 'runner') diff --git a/server/controllers/api/search/index.ts b/server/server/controllers/api/search/index.ts similarity index 57% rename from server/controllers/api/search/index.ts rename to server/server/controllers/api/search/index.ts index 4d395161c..f1a1f493f 100644 --- a/server/controllers/api/search/index.ts +++ b/server/server/controllers/api/search/index.ts @@ -1,8 +1,8 @@ import express from 'express' -import { apiRateLimiter } from '@server/middlewares' -import { searchChannelsRouter } from './search-video-channels' -import { searchPlaylistsRouter } from './search-video-playlists' -import { searchVideosRouter } from './search-videos' +import { apiRateLimiter } from '@server/middlewares/index.js' +import { searchChannelsRouter } from './search-video-channels.js' +import { searchPlaylistsRouter } from './search-video-playlists.js' +import { searchVideosRouter } from './search-videos.js' const searchRouter = express.Router() diff --git a/server/controllers/api/search/search-video-channels.ts b/server/server/controllers/api/search/search-video-channels.ts similarity index 83% rename from server/controllers/api/search/search-video-channels.ts rename to server/server/controllers/api/search/search-video-channels.ts index 1d2a9d235..cccc3b3dc 100644 --- a/server/controllers/api/search/search-video-channels.ts +++ b/server/server/controllers/api/search/search-video-channels.ts @@ -1,19 +1,18 @@ import express from 'express' -import { sanitizeUrl } from '@server/helpers/core-utils' -import { pickSearchChannelQuery } from '@server/helpers/query' -import { doJSONRequest } from '@server/helpers/requests' -import { CONFIG } from '@server/initializers/config' -import { WEBSERVER } from '@server/initializers/constants' -import { findLatestAPRedirection } from '@server/lib/activitypub/activity' -import { Hooks } from '@server/lib/plugins/hooks' -import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' -import { getServerActor } from '@server/models/application/application' -import { HttpStatusCode, ResultList, VideoChannel } from '@shared/models' -import { VideoChannelsSearchQueryAfterSanitize } from '../../../../shared/models/search' -import { isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils' -import { logger } from '../../../helpers/logger' -import { getFormattedObjects } from '../../../helpers/utils' -import { getOrCreateAPActor, loadActorUrlOrGetFromWebfinger } from '../../../lib/activitypub/actors' +import { sanitizeUrl } from '@server/helpers/core-utils.js' +import { pickSearchChannelQuery } from '@server/helpers/query.js' +import { doJSONRequest } from '@server/helpers/requests.js' +import { CONFIG } from '@server/initializers/config.js' +import { WEBSERVER } from '@server/initializers/constants.js' +import { findLatestAPRedirection } from '@server/lib/activitypub/activity.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search.js' +import { getServerActor } from '@server/models/application/application.js' +import { HttpStatusCode, ResultList, VideoChannel, VideoChannelsSearchQueryAfterSanitize } from '@peertube/peertube-models' +import { isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils.js' +import { logger } from '../../../helpers/logger.js' +import { getFormattedObjects } from '../../../helpers/utils.js' +import { getOrCreateAPActor, loadActorUrlOrGetFromWebfinger } from '../../../lib/activitypub/actors/index.js' import { asyncMiddleware, openapiOperationDoc, @@ -23,10 +22,10 @@ import { setDefaultSearchSort, videoChannelsListSearchValidator, videoChannelsSearchSortValidator -} from '../../../middlewares' -import { VideoChannelModel } from '../../../models/video/video-channel' -import { MChannelAccountDefault } from '../../../types/models' -import { searchLocalUrl } from './shared' +} from '../../../middlewares/index.js' +import { VideoChannelModel } from '../../../models/video/video-channel.js' +import { MChannelAccountDefault } from '../../../types/models/index.js' +import { searchLocalUrl } from './shared/index.js' const searchChannelsRouter = express.Router() diff --git a/server/controllers/api/search/search-video-playlists.ts b/server/server/controllers/api/search/search-video-playlists.ts similarity index 83% rename from server/controllers/api/search/search-video-playlists.ts rename to server/server/controllers/api/search/search-video-playlists.ts index 97aeeaba9..4c0f98cf2 100644 --- a/server/controllers/api/search/search-video-playlists.ts +++ b/server/server/controllers/api/search/search-video-playlists.ts @@ -1,20 +1,20 @@ import express from 'express' -import { sanitizeUrl } from '@server/helpers/core-utils' -import { isUserAbleToSearchRemoteURI } from '@server/helpers/express-utils' -import { logger } from '@server/helpers/logger' -import { pickSearchPlaylistQuery } from '@server/helpers/query' -import { doJSONRequest } from '@server/helpers/requests' -import { getFormattedObjects } from '@server/helpers/utils' -import { CONFIG } from '@server/initializers/config' -import { WEBSERVER } from '@server/initializers/constants' -import { findLatestAPRedirection } from '@server/lib/activitypub/activity' -import { getOrCreateAPVideoPlaylist } from '@server/lib/activitypub/playlists/get' -import { Hooks } from '@server/lib/plugins/hooks' -import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' -import { getServerActor } from '@server/models/application/application' -import { VideoPlaylistModel } from '@server/models/video/video-playlist' -import { MVideoPlaylistFullSummary } from '@server/types/models' -import { HttpStatusCode, ResultList, VideoPlaylist, VideoPlaylistsSearchQueryAfterSanitize } from '@shared/models' +import { sanitizeUrl } from '@server/helpers/core-utils.js' +import { isUserAbleToSearchRemoteURI } from '@server/helpers/express-utils.js' +import { logger } from '@server/helpers/logger.js' +import { pickSearchPlaylistQuery } from '@server/helpers/query.js' +import { doJSONRequest } from '@server/helpers/requests.js' +import { getFormattedObjects } from '@server/helpers/utils.js' +import { CONFIG } from '@server/initializers/config.js' +import { WEBSERVER } from '@server/initializers/constants.js' +import { findLatestAPRedirection } from '@server/lib/activitypub/activity.js' +import { getOrCreateAPVideoPlaylist } from '@server/lib/activitypub/playlists/get.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search.js' +import { getServerActor } from '@server/models/application/application.js' +import { VideoPlaylistModel } from '@server/models/video/video-playlist.js' +import { MVideoPlaylistFullSummary } from '@server/types/models/index.js' +import { HttpStatusCode, ResultList, VideoPlaylist, VideoPlaylistsSearchQueryAfterSanitize } from '@peertube/peertube-models' import { asyncMiddleware, openapiOperationDoc, @@ -24,8 +24,8 @@ import { setDefaultSearchSort, videoPlaylistsListSearchValidator, videoPlaylistsSearchSortValidator -} from '../../../middlewares' -import { searchLocalUrl } from './shared' +} from '../../../middlewares/index.js' +import { searchLocalUrl } from './shared/index.js' const searchPlaylistsRouter = express.Router() diff --git a/server/controllers/api/search/search-videos.ts b/server/server/controllers/api/search/search-videos.ts similarity index 83% rename from server/controllers/api/search/search-videos.ts rename to server/server/controllers/api/search/search-videos.ts index b33064335..a6700ed7d 100644 --- a/server/controllers/api/search/search-videos.ts +++ b/server/server/controllers/api/search/search-videos.ts @@ -1,19 +1,18 @@ import express from 'express' -import { sanitizeUrl } from '@server/helpers/core-utils' -import { pickSearchVideoQuery } from '@server/helpers/query' -import { doJSONRequest } from '@server/helpers/requests' -import { CONFIG } from '@server/initializers/config' -import { WEBSERVER } from '@server/initializers/constants' -import { findLatestAPRedirection } from '@server/lib/activitypub/activity' -import { getOrCreateAPVideo } from '@server/lib/activitypub/videos' -import { Hooks } from '@server/lib/plugins/hooks' -import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' -import { getServerActor } from '@server/models/application/application' -import { HttpStatusCode, ResultList, Video } from '@shared/models' -import { VideosSearchQueryAfterSanitize } from '../../../../shared/models/search' -import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils' -import { logger } from '../../../helpers/logger' -import { getFormattedObjects } from '../../../helpers/utils' +import { sanitizeUrl } from '@server/helpers/core-utils.js' +import { pickSearchVideoQuery } from '@server/helpers/query.js' +import { doJSONRequest } from '@server/helpers/requests.js' +import { CONFIG } from '@server/initializers/config.js' +import { WEBSERVER } from '@server/initializers/constants.js' +import { findLatestAPRedirection } from '@server/lib/activitypub/activity.js' +import { getOrCreateAPVideo } from '@server/lib/activitypub/videos/index.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search.js' +import { getServerActor } from '@server/models/application/application.js' +import { HttpStatusCode, ResultList, Video, VideosSearchQueryAfterSanitize } from '@peertube/peertube-models' +import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils.js' +import { logger } from '../../../helpers/logger.js' +import { getFormattedObjects } from '../../../helpers/utils.js' import { asyncMiddleware, commonVideosFiltersValidator, @@ -24,11 +23,11 @@ import { setDefaultSearchSort, videosSearchSortValidator, videosSearchValidator -} from '../../../middlewares' -import { guessAdditionalAttributesFromQuery } from '../../../models/video/formatter' -import { VideoModel } from '../../../models/video/video' -import { MVideoAccountLightBlacklistAllFiles } from '../../../types/models' -import { searchLocalUrl } from './shared' +} from '../../../middlewares/index.js' +import { guessAdditionalAttributesFromQuery } from '../../../models/video/formatter/index.js' +import { VideoModel } from '../../../models/video/video.js' +import { MVideoAccountLightBlacklistAllFiles } from '../../../types/models/index.js' +import { searchLocalUrl } from './shared/index.js' const searchVideosRouter = express.Router() diff --git a/server/server/controllers/api/search/shared/index.ts b/server/server/controllers/api/search/shared/index.ts new file mode 100644 index 000000000..84814912c --- /dev/null +++ b/server/server/controllers/api/search/shared/index.ts @@ -0,0 +1 @@ +export * from './utils.js' diff --git a/server/controllers/api/search/shared/utils.ts b/server/server/controllers/api/search/shared/utils.ts similarity index 100% rename from server/controllers/api/search/shared/utils.ts rename to server/server/controllers/api/search/shared/utils.ts diff --git a/server/controllers/api/server/contact.ts b/server/server/controllers/api/server/contact.ts similarity index 71% rename from server/controllers/api/server/contact.ts rename to server/server/controllers/api/server/contact.ts index 56596bea5..53e73fa2b 100644 --- a/server/controllers/api/server/contact.ts +++ b/server/server/controllers/api/server/contact.ts @@ -1,10 +1,9 @@ -import { logger } from '@server/helpers/logger' import express from 'express' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' -import { ContactForm } from '../../../../shared/models/server' -import { Emailer } from '../../../lib/emailer' -import { Redis } from '../../../lib/redis' -import { asyncMiddleware, contactAdministratorValidator } from '../../../middlewares' +import { ContactForm, HttpStatusCode } from '@peertube/peertube-models' +import { logger } from '@server/helpers/logger.js' +import { Emailer } from '../../../lib/emailer.js' +import { Redis } from '../../../lib/redis.js' +import { asyncMiddleware, contactAdministratorValidator } from '../../../middlewares/index.js' const contactRouter = express.Router() diff --git a/server/controllers/api/server/debug.ts b/server/server/controllers/api/server/debug.ts similarity index 83% rename from server/controllers/api/server/debug.ts rename to server/server/controllers/api/server/debug.ts index f3792bfc8..338a1214f 100644 --- a/server/controllers/api/server/debug.ts +++ b/server/server/controllers/api/server/debug.ts @@ -1,14 +1,12 @@ import express from 'express' -import { InboxManager } from '@server/lib/activitypub/inbox-manager' -import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler' -import { VideoViewsBufferScheduler } from '@server/lib/schedulers/video-views-buffer-scheduler' -import { VideoViewsManager } from '@server/lib/views/video-views-manager' -import { Debug, SendDebugCommand } from '@shared/models' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' -import { UserRight } from '../../../../shared/models/users' -import { authenticate, ensureUserHasRight } from '../../../middlewares' -import { VideoChannelSyncLatestScheduler } from '@server/lib/schedulers/video-channel-sync-latest-scheduler' -import { UpdateVideosScheduler } from '@server/lib/schedulers/update-videos-scheduler' +import { Debug, HttpStatusCode, SendDebugCommand, UserRight } from '@peertube/peertube-models' +import { InboxManager } from '@server/lib/activitypub/inbox-manager.js' +import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.js' +import { UpdateVideosScheduler } from '@server/lib/schedulers/update-videos-scheduler.js' +import { VideoChannelSyncLatestScheduler } from '@server/lib/schedulers/video-channel-sync-latest-scheduler.js' +import { VideoViewsBufferScheduler } from '@server/lib/schedulers/video-views-buffer-scheduler.js' +import { VideoViewsManager } from '@server/lib/views/video-views-manager.js' +import { authenticate, ensureUserHasRight } from '../../../middlewares/index.js' const debugRouter = express.Router() diff --git a/server/controllers/api/server/follows.ts b/server/server/controllers/api/server/follows.ts similarity index 92% rename from server/controllers/api/server/follows.ts rename to server/server/controllers/api/server/follows.ts index 87828813a..d7f84053a 100644 --- a/server/controllers/api/server/follows.ts +++ b/server/server/controllers/api/server/follows.ts @@ -1,16 +1,14 @@ import express from 'express' -import { getServerActor } from '@server/models/application/application' -import { ServerFollowCreate } from '@shared/models' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' -import { UserRight } from '../../../../shared/models/users' -import { logger } from '../../../helpers/logger' -import { getFormattedObjects } from '../../../helpers/utils' -import { SERVER_ACTOR_NAME } from '../../../initializers/constants' -import { sequelizeTypescript } from '../../../initializers/database' -import { autoFollowBackIfNeeded } from '../../../lib/activitypub/follow' -import { sendAccept, sendReject, sendUndoFollow } from '../../../lib/activitypub/send' -import { JobQueue } from '../../../lib/job-queue' -import { removeRedundanciesOfServer } from '../../../lib/redundancy' +import { HttpStatusCode, ServerFollowCreate, UserRight } from '@peertube/peertube-models' +import { getServerActor } from '@server/models/application/application.js' +import { logger } from '../../../helpers/logger.js' +import { getFormattedObjects } from '../../../helpers/utils.js' +import { SERVER_ACTOR_NAME } from '../../../initializers/constants.js' +import { sequelizeTypescript } from '../../../initializers/database.js' +import { autoFollowBackIfNeeded } from '../../../lib/activitypub/follow.js' +import { sendAccept, sendReject, sendUndoFollow } from '../../../lib/activitypub/send/index.js' +import { JobQueue } from '../../../lib/job-queue/index.js' +import { removeRedundanciesOfServer } from '../../../lib/redundancy.js' import { asyncMiddleware, authenticate, @@ -19,7 +17,7 @@ import { setBodyHostsPort, setDefaultPagination, setDefaultSort -} from '../../../middlewares' +} from '../../../middlewares/index.js' import { acceptFollowerValidator, followValidator, @@ -29,8 +27,8 @@ import { listFollowsValidator, rejectFollowerValidator, removeFollowingValidator -} from '../../../middlewares/validators' -import { ActorFollowModel } from '../../../models/actor/actor-follow' +} from '../../../middlewares/validators/index.js' +import { ActorFollowModel } from '../../../models/actor/actor-follow.js' const serverFollowsRouter = express.Router() serverFollowsRouter.get('/following', diff --git a/server/controllers/api/server/index.ts b/server/server/controllers/api/server/index.ts similarity index 54% rename from server/controllers/api/server/index.ts rename to server/server/controllers/api/server/index.ts index 57f7d601c..e3df8889b 100644 --- a/server/controllers/api/server/index.ts +++ b/server/server/controllers/api/server/index.ts @@ -1,12 +1,12 @@ import express from 'express' -import { apiRateLimiter } from '@server/middlewares' -import { contactRouter } from './contact' -import { debugRouter } from './debug' -import { serverFollowsRouter } from './follows' -import { logsRouter } from './logs' -import { serverRedundancyRouter } from './redundancy' -import { serverBlocklistRouter } from './server-blocklist' -import { statsRouter } from './stats' +import { apiRateLimiter } from '@server/middlewares/index.js' +import { contactRouter } from './contact.js' +import { debugRouter } from './debug.js' +import { serverFollowsRouter } from './follows.js' +import { logsRouter } from './logs.js' +import { serverRedundancyRouter } from './redundancy.js' +import { serverBlocklistRouter } from './server-blocklist.js' +import { statsRouter } from './stats.js' const serverRouter = express.Router() diff --git a/server/controllers/api/server/logs.ts b/server/server/controllers/api/server/logs.ts similarity index 89% rename from server/controllers/api/server/logs.ts rename to server/server/controllers/api/server/logs.ts index ed0aa6e8e..1ebf8053c 100644 --- a/server/controllers/api/server/logs.ts +++ b/server/server/controllers/api/server/logs.ts @@ -1,16 +1,14 @@ import express from 'express' -import { readdir, readFile } from 'fs-extra' +import { readdir, readFile } from 'fs/promises' import { join } from 'path' -import { isArray } from '@server/helpers/custom-validators/misc' -import { logger, mtimeSortFilesDesc } from '@server/helpers/logger' -import { pick } from '@shared/core-utils' -import { ClientLogCreate, HttpStatusCode } from '@shared/models' -import { ServerLogLevel } from '../../../../shared/models/server/server-log-level.type' -import { UserRight } from '../../../../shared/models/users' -import { CONFIG } from '../../../initializers/config' -import { AUDIT_LOG_FILENAME, LOG_FILENAME, MAX_LOGS_OUTPUT_CHARACTERS } from '../../../initializers/constants' -import { asyncMiddleware, authenticate, buildRateLimiter, ensureUserHasRight, optionalAuthenticate } from '../../../middlewares' -import { createClientLogValidator, getAuditLogsValidator, getLogsValidator } from '../../../middlewares/validators/logs' +import { pick } from '@peertube/peertube-core-utils' +import { ClientLogCreate, HttpStatusCode, ServerLogLevel, UserRight } from '@peertube/peertube-models' +import { isArray } from '@server/helpers/custom-validators/misc.js' +import { logger, mtimeSortFilesDesc } from '@server/helpers/logger.js' +import { CONFIG } from '../../../initializers/config.js' +import { AUDIT_LOG_FILENAME, LOG_FILENAME, MAX_LOGS_OUTPUT_CHARACTERS } from '../../../initializers/constants.js' +import { asyncMiddleware, authenticate, buildRateLimiter, ensureUserHasRight, optionalAuthenticate } from '../../../middlewares/index.js' +import { createClientLogValidator, getAuditLogsValidator, getLogsValidator } from '../../../middlewares/validators/logs.js' const createClientLogRateLimiter = buildRateLimiter({ windowMs: CONFIG.RATES_LIMIT.RECEIVE_CLIENT_LOG.WINDOW_MS, diff --git a/server/controllers/api/server/redundancy.ts b/server/server/controllers/api/server/redundancy.ts similarity index 89% rename from server/controllers/api/server/redundancy.ts rename to server/server/controllers/api/server/redundancy.ts index 94e187cd4..e16f85593 100644 --- a/server/controllers/api/server/redundancy.ts +++ b/server/server/controllers/api/server/redundancy.ts @@ -1,10 +1,9 @@ import express from 'express' -import { JobQueue } from '@server/lib/job-queue' -import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' -import { UserRight } from '../../../../shared/models/users' -import { logger } from '../../../helpers/logger' -import { removeRedundanciesOfServer, removeVideoRedundancy } from '../../../lib/redundancy' +import { HttpStatusCode, UserRight } from '@peertube/peertube-models' +import { JobQueue } from '@server/lib/job-queue/index.js' +import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy.js' +import { logger } from '../../../helpers/logger.js' +import { removeRedundanciesOfServer, removeVideoRedundancy } from '../../../lib/redundancy.js' import { asyncMiddleware, authenticate, @@ -13,13 +12,13 @@ import { setDefaultPagination, setDefaultVideoRedundanciesSort, videoRedundanciesSortValidator -} from '../../../middlewares' +} from '../../../middlewares/index.js' import { addVideoRedundancyValidator, listVideoRedundanciesValidator, removeVideoRedundancyValidator, updateServerRedundancyValidator -} from '../../../middlewares/validators/redundancy' +} from '../../../middlewares/validators/redundancy.js' const serverRedundancyRouter = express.Router() diff --git a/server/controllers/api/server/server-blocklist.ts b/server/server/controllers/api/server/server-blocklist.ts similarity index 89% rename from server/controllers/api/server/server-blocklist.ts rename to server/server/controllers/api/server/server-blocklist.ts index 740f95da3..9ca7ec03e 100644 --- a/server/controllers/api/server/server-blocklist.ts +++ b/server/server/controllers/api/server/server-blocklist.ts @@ -1,12 +1,16 @@ import 'multer' import express from 'express' -import { logger } from '@server/helpers/logger' -import { getServerActor } from '@server/models/application/application' -import { UserNotificationModel } from '@server/models/user/user-notification' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' -import { UserRight } from '../../../../shared/models/users' -import { getFormattedObjects } from '../../../helpers/utils' -import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist' +import { HttpStatusCode, UserRight } from '@peertube/peertube-models' +import { logger } from '@server/helpers/logger.js' +import { getServerActor } from '@server/models/application/application.js' +import { UserNotificationModel } from '@server/models/user/user-notification.js' +import { getFormattedObjects } from '../../../helpers/utils.js' +import { + addAccountInBlocklist, + addServerInBlocklist, + removeAccountFromBlocklist, + removeServerFromBlocklist +} from '../../../lib/blocklist.js' import { asyncMiddleware, asyncRetryTransactionMiddleware, @@ -15,7 +19,7 @@ import { paginationValidator, setDefaultPagination, setDefaultSort -} from '../../../middlewares' +} from '../../../middlewares/index.js' import { accountsBlocklistSortValidator, blockAccountValidator, @@ -23,9 +27,9 @@ import { serversBlocklistSortValidator, unblockAccountByServerValidator, unblockServerByServerValidator -} from '../../../middlewares/validators' -import { AccountBlocklistModel } from '../../../models/account/account-blocklist' -import { ServerBlocklistModel } from '../../../models/server/server-blocklist' +} from '../../../middlewares/validators/index.js' +import { AccountBlocklistModel } from '../../../models/account/account-blocklist.js' +import { ServerBlocklistModel } from '../../../models/server/server-blocklist.js' const serverBlocklistRouter = express.Router() diff --git a/server/controllers/api/server/stats.ts b/server/server/controllers/api/server/stats.ts similarity index 69% rename from server/controllers/api/server/stats.ts rename to server/server/controllers/api/server/stats.ts index 2ab398f4d..5a5f70f02 100644 --- a/server/controllers/api/server/stats.ts +++ b/server/server/controllers/api/server/stats.ts @@ -1,9 +1,9 @@ import express from 'express' -import { StatsManager } from '@server/lib/stat-manager' -import { ROUTE_CACHE_LIFETIME } from '../../../initializers/constants' -import { asyncMiddleware } from '../../../middlewares' -import { cacheRoute } from '../../../middlewares/cache/cache' -import { Hooks } from '@server/lib/plugins/hooks' +import { StatsManager } from '@server/lib/stat-manager.js' +import { ROUTE_CACHE_LIFETIME } from '../../../initializers/constants.js' +import { asyncMiddleware } from '../../../middlewares/index.js' +import { cacheRoute } from '../../../middlewares/cache/cache.js' +import { Hooks } from '@server/lib/plugins/hooks.js' const statsRouter = express.Router() diff --git a/server/controllers/api/users/email-verification.ts b/server/server/controllers/api/users/email-verification.ts similarity index 90% rename from server/controllers/api/users/email-verification.ts rename to server/server/controllers/api/users/email-verification.ts index 230aaa9af..ef9dc30b6 100644 --- a/server/controllers/api/users/email-verification.ts +++ b/server/server/controllers/api/users/email-verification.ts @@ -1,13 +1,13 @@ import express from 'express' -import { HttpStatusCode } from '@shared/models' -import { CONFIG } from '../../../initializers/config' -import { sendVerifyRegistrationEmail, sendVerifyUserEmail } from '../../../lib/user' -import { asyncMiddleware, buildRateLimiter } from '../../../middlewares' +import { HttpStatusCode } from '@peertube/peertube-models' +import { CONFIG } from '../../../initializers/config.js' +import { sendVerifyRegistrationEmail, sendVerifyUserEmail } from '../../../lib/user.js' +import { asyncMiddleware, buildRateLimiter } from '../../../middlewares/index.js' import { registrationVerifyEmailValidator, usersAskSendVerifyEmailValidator, usersVerifyEmailValidator -} from '../../../middlewares/validators' +} from '../../../middlewares/validators/index.js' const askSendEmailLimiter = buildRateLimiter({ windowMs: CONFIG.RATES_LIMIT.ASK_SEND_EMAIL.WINDOW_MS, diff --git a/server/controllers/api/users/index.ts b/server/server/controllers/api/users/index.ts similarity index 88% rename from server/controllers/api/users/index.ts rename to server/server/controllers/api/users/index.ts index 5eac6fd0f..e5290fe25 100644 --- a/server/controllers/api/users/index.ts +++ b/server/server/controllers/api/users/index.ts @@ -1,18 +1,18 @@ import express from 'express' -import { tokensRouter } from '@server/controllers/api/users/token' -import { Hooks } from '@server/lib/plugins/hooks' -import { OAuthTokenModel } from '@server/models/oauth/oauth-token' -import { MUserAccountDefault } from '@server/types/models' -import { pick } from '@shared/core-utils' -import { HttpStatusCode, UserCreate, UserCreateResult, UserRight, UserUpdate } from '@shared/models' -import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger' -import { logger } from '../../../helpers/logger' -import { generateRandomString, getFormattedObjects } from '../../../helpers/utils' -import { WEBSERVER } from '../../../initializers/constants' -import { sequelizeTypescript } from '../../../initializers/database' -import { Emailer } from '../../../lib/emailer' -import { Redis } from '../../../lib/redis' -import { buildUser, createUserAccountAndChannelAndPlaylist } from '../../../lib/user' +import { tokensRouter } from '@server/controllers/api/users/token.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { OAuthTokenModel } from '@server/models/oauth/oauth-token.js' +import { MUserAccountDefault } from '@server/types/models/index.js' +import { pick } from '@peertube/peertube-core-utils' +import { HttpStatusCode, UserCreate, UserCreateResult, UserRight, UserUpdate } from '@peertube/peertube-models' +import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger.js' +import { logger } from '../../../helpers/logger.js' +import { generateRandomString, getFormattedObjects } from '../../../helpers/utils.js' +import { WEBSERVER } from '../../../initializers/constants.js' +import { sequelizeTypescript } from '../../../initializers/database.js' +import { Emailer } from '../../../lib/emailer.js' +import { Redis } from '../../../lib/redis.js' +import { buildUser, createUserAccountAndChannelAndPlaylist } from '../../../lib/user.js' import { adminUsersSortValidator, apiRateLimiter, @@ -29,24 +29,24 @@ import { usersListValidator, usersRemoveValidator, usersUpdateValidator -} from '../../../middlewares' +} from '../../../middlewares/index.js' import { ensureCanModerateUser, usersAskResetPasswordValidator, usersBlockingValidator, usersResetPasswordValidator -} from '../../../middlewares/validators' -import { UserModel } from '../../../models/user/user' -import { emailVerificationRouter } from './email-verification' -import { meRouter } from './me' -import { myAbusesRouter } from './my-abuses' -import { myBlocklistRouter } from './my-blocklist' -import { myVideosHistoryRouter } from './my-history' -import { myNotificationsRouter } from './my-notifications' -import { mySubscriptionsRouter } from './my-subscriptions' -import { myVideoPlaylistsRouter } from './my-video-playlists' -import { registrationsRouter } from './registrations' -import { twoFactorRouter } from './two-factor' +} from '../../../middlewares/validators/index.js' +import { UserModel } from '../../../models/user/user.js' +import { emailVerificationRouter } from './email-verification.js' +import { meRouter } from './me.js' +import { myAbusesRouter } from './my-abuses.js' +import { myBlocklistRouter } from './my-blocklist.js' +import { myVideosHistoryRouter } from './my-history.js' +import { myNotificationsRouter } from './my-notifications.js' +import { mySubscriptionsRouter } from './my-subscriptions.js' +import { myVideoPlaylistsRouter } from './my-video-playlists.js' +import { registrationsRouter } from './registrations.js' +import { twoFactorRouter } from './two-factor.js' const auditLogger = auditLoggerFactory('users') diff --git a/server/controllers/api/users/me.ts b/server/server/controllers/api/users/me.ts similarity index 87% rename from server/controllers/api/users/me.ts rename to server/server/controllers/api/users/me.ts index 26811136e..69edd342d 100644 --- a/server/controllers/api/users/me.ts +++ b/server/server/controllers/api/users/me.ts @@ -1,18 +1,24 @@ import 'multer' import express from 'express' -import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '@server/helpers/audit-logger' -import { Hooks } from '@server/lib/plugins/hooks' -import { pick } from '@shared/core-utils' -import { ActorImageType, HttpStatusCode, UserUpdateMe, UserVideoQuota, UserVideoRate as FormattedUserVideoRate } from '@shared/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { createReqFiles } from '../../../helpers/express-utils' -import { getFormattedObjects } from '../../../helpers/utils' -import { CONFIG } from '../../../initializers/config' -import { MIMETYPES } from '../../../initializers/constants' -import { sequelizeTypescript } from '../../../initializers/database' -import { sendUpdateActor } from '../../../lib/activitypub/send' -import { deleteLocalActorImageFile, updateLocalActorImageFiles } from '../../../lib/local-actor' -import { getOriginalVideoFileTotalDailyFromUser, getOriginalVideoFileTotalFromUser, sendVerifyUserEmail } from '../../../lib/user' +import { pick } from '@peertube/peertube-core-utils' +import { + ActorImageType, + HttpStatusCode, + UserUpdateMe, + UserVideoQuota, + UserVideoRate as FormattedUserVideoRate +} from '@peertube/peertube-models' +import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '@server/helpers/audit-logger.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { createReqFiles } from '../../../helpers/express-utils.js' +import { getFormattedObjects } from '../../../helpers/utils.js' +import { CONFIG } from '../../../initializers/config.js' +import { MIMETYPES } from '../../../initializers/constants.js' +import { sequelizeTypescript } from '../../../initializers/database.js' +import { sendUpdateActor } from '../../../lib/activitypub/send/index.js' +import { deleteLocalActorImageFile, updateLocalActorImageFiles } from '../../../lib/local-actor.js' +import { getOriginalVideoFileTotalDailyFromUser, getOriginalVideoFileTotalFromUser, sendVerifyUserEmail } from '../../../lib/user.js' import { asyncMiddleware, asyncRetryTransactionMiddleware, @@ -23,20 +29,20 @@ import { setDefaultVideosSort, usersUpdateMeValidator, usersVideoRatingValidator -} from '../../../middlewares' +} from '../../../middlewares/index.js' +import { updateAvatarValidator } from '../../../middlewares/validators/actor-image.js' import { deleteMeValidator, getMyVideoImportsValidator, usersVideosValidator, videoImportsSortValidator, videosSortValidator -} from '../../../middlewares/validators' -import { updateAvatarValidator } from '../../../middlewares/validators/actor-image' -import { AccountModel } from '../../../models/account/account' -import { AccountVideoRateModel } from '../../../models/account/account-video-rate' -import { UserModel } from '../../../models/user/user' -import { VideoModel } from '../../../models/video/video' -import { VideoImportModel } from '../../../models/video/video-import' +} from '../../../middlewares/validators/index.js' +import { AccountVideoRateModel } from '../../../models/account/account-video-rate.js' +import { AccountModel } from '../../../models/account/account.js' +import { UserModel } from '../../../models/user/user.js' +import { VideoImportModel } from '../../../models/video/video-import.js' +import { VideoModel } from '../../../models/video/video.js' const auditLogger = auditLoggerFactory('users') diff --git a/server/controllers/api/users/my-abuses.ts b/server/server/controllers/api/users/my-abuses.ts similarity index 91% rename from server/controllers/api/users/my-abuses.ts rename to server/server/controllers/api/users/my-abuses.ts index 103c3d332..510d5528f 100644 --- a/server/controllers/api/users/my-abuses.ts +++ b/server/server/controllers/api/users/my-abuses.ts @@ -1,5 +1,5 @@ import express from 'express' -import { AbuseModel } from '@server/models/abuse/abuse' +import { AbuseModel } from '@server/models/abuse/abuse.js' import { abuseListForUserValidator, abusesSortValidator, @@ -8,7 +8,7 @@ import { paginationValidator, setDefaultPagination, setDefaultSort -} from '../../../middlewares' +} from '../../../middlewares/index.js' const myAbusesRouter = express.Router() diff --git a/server/controllers/api/users/my-blocklist.ts b/server/server/controllers/api/users/my-blocklist.ts similarity index 89% rename from server/controllers/api/users/my-blocklist.ts rename to server/server/controllers/api/users/my-blocklist.ts index 0b56645cf..46a988ea6 100644 --- a/server/controllers/api/users/my-blocklist.ts +++ b/server/server/controllers/api/users/my-blocklist.ts @@ -1,10 +1,15 @@ import 'multer' import express from 'express' -import { logger } from '@server/helpers/logger' -import { UserNotificationModel } from '@server/models/user/user-notification' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' -import { getFormattedObjects } from '../../../helpers/utils' -import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist' +import { HttpStatusCode } from '@peertube/peertube-models' +import { logger } from '@server/helpers/logger.js' +import { UserNotificationModel } from '@server/models/user/user-notification.js' +import { getFormattedObjects } from '../../../helpers/utils.js' +import { + addAccountInBlocklist, + addServerInBlocklist, + removeAccountFromBlocklist, + removeServerFromBlocklist +} from '../../../lib/blocklist.js' import { asyncMiddleware, asyncRetryTransactionMiddleware, @@ -13,16 +18,16 @@ import { setDefaultPagination, setDefaultSort, unblockAccountByAccountValidator -} from '../../../middlewares' +} from '../../../middlewares/index.js' import { accountsBlocklistSortValidator, blockAccountValidator, blockServerValidator, serversBlocklistSortValidator, unblockServerByAccountValidator -} from '../../../middlewares/validators' -import { AccountBlocklistModel } from '../../../models/account/account-blocklist' -import { ServerBlocklistModel } from '../../../models/server/server-blocklist' +} from '../../../middlewares/validators/index.js' +import { AccountBlocklistModel } from '../../../models/account/account-blocklist.js' +import { ServerBlocklistModel } from '../../../models/server/server-blocklist.js' const myBlocklistRouter = express.Router() diff --git a/server/controllers/api/users/my-history.ts b/server/server/controllers/api/users/my-history.ts similarity index 89% rename from server/controllers/api/users/my-history.ts rename to server/server/controllers/api/users/my-history.ts index e6d3e86ac..c2106e4e5 100644 --- a/server/controllers/api/users/my-history.ts +++ b/server/server/controllers/api/users/my-history.ts @@ -1,8 +1,8 @@ -import { forceNumber } from '@shared/core-utils' import express from 'express' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' -import { getFormattedObjects } from '../../../helpers/utils' -import { sequelizeTypescript } from '../../../initializers/database' +import { forceNumber } from '@peertube/peertube-core-utils' +import { HttpStatusCode } from '@peertube/peertube-models' +import { getFormattedObjects } from '../../../helpers/utils.js' +import { sequelizeTypescript } from '../../../initializers/database.js' import { asyncMiddleware, asyncRetryTransactionMiddleware, @@ -12,8 +12,8 @@ import { userHistoryListValidator, userHistoryRemoveAllValidator, userHistoryRemoveElementValidator -} from '../../../middlewares' -import { UserVideoHistoryModel } from '../../../models/user/user-video-history' +} from '../../../middlewares/index.js' +import { UserVideoHistoryModel } from '../../../models/user/user-video-history.js' const myVideosHistoryRouter = express.Router() diff --git a/server/controllers/api/users/my-notifications.ts b/server/server/controllers/api/users/my-notifications.ts similarity index 90% rename from server/controllers/api/users/my-notifications.ts rename to server/server/controllers/api/users/my-notifications.ts index 6014cdbbf..c0172a452 100644 --- a/server/controllers/api/users/my-notifications.ts +++ b/server/server/controllers/api/users/my-notifications.ts @@ -1,8 +1,8 @@ import 'multer' import express from 'express' -import { UserNotificationModel } from '@server/models/user/user-notification' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' -import { UserNotificationSetting } from '../../../../shared/models/users' +import { HttpStatusCode, UserNotificationSetting } from '@peertube/peertube-models' +import { getFormattedObjects } from '@server/helpers/utils.js' +import { UserNotificationModel } from '@server/models/user/user-notification.js' import { asyncMiddleware, asyncRetryTransactionMiddleware, @@ -11,15 +11,14 @@ import { setDefaultPagination, setDefaultSort, userNotificationsSortValidator -} from '../../../middlewares' +} from '../../../middlewares/index.js' import { listUserNotificationsValidator, markAsReadUserNotificationsValidator, updateNotificationSettingsValidator -} from '../../../middlewares/validators/user-notifications' -import { UserNotificationSettingModel } from '../../../models/user/user-notification-setting' -import { meRouter } from './me' -import { getFormattedObjects } from '@server/helpers/utils' +} from '../../../middlewares/validators/user-notifications.js' +import { UserNotificationSettingModel } from '../../../models/user/user-notification-setting.js' +import { meRouter } from './me.js' const myNotificationsRouter = express.Router() diff --git a/server/controllers/api/users/my-subscriptions.ts b/server/server/controllers/api/users/my-subscriptions.ts similarity index 88% rename from server/controllers/api/users/my-subscriptions.ts rename to server/server/controllers/api/users/my-subscriptions.ts index c4360f59d..f2010950e 100644 --- a/server/controllers/api/users/my-subscriptions.ts +++ b/server/server/controllers/api/users/my-subscriptions.ts @@ -1,15 +1,15 @@ import 'multer' import express from 'express' -import { handlesToNameAndHost } from '@server/helpers/actors' -import { pickCommonVideoQuery } from '@server/helpers/query' -import { sendUndoFollow } from '@server/lib/activitypub/send' -import { Hooks } from '@server/lib/plugins/hooks' -import { VideoChannelModel } from '@server/models/video/video-channel' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' -import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils' -import { getFormattedObjects } from '../../../helpers/utils' -import { sequelizeTypescript } from '../../../initializers/database' -import { JobQueue } from '../../../lib/job-queue' +import { HttpStatusCode } from '@peertube/peertube-models' +import { handlesToNameAndHost } from '@server/helpers/actors.js' +import { pickCommonVideoQuery } from '@server/helpers/query.js' +import { sendUndoFollow } from '@server/lib/activitypub/send/index.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { VideoChannelModel } from '@server/models/video/video-channel.js' +import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils.js' +import { getFormattedObjects } from '../../../helpers/utils.js' +import { sequelizeTypescript } from '../../../initializers/database.js' +import { JobQueue } from '../../../lib/job-queue/index.js' import { asyncMiddleware, asyncRetryTransactionMiddleware, @@ -21,16 +21,16 @@ import { setDefaultVideosSort, userSubscriptionAddValidator, userSubscriptionGetValidator -} from '../../../middlewares' +} from '../../../middlewares/index.js' import { areSubscriptionsExistValidator, userSubscriptionListValidator, userSubscriptionsSortValidator, videosSortValidator -} from '../../../middlewares/validators' -import { ActorFollowModel } from '../../../models/actor/actor-follow' -import { guessAdditionalAttributesFromQuery } from '../../../models/video/formatter' -import { VideoModel } from '../../../models/video/video' +} from '../../../middlewares/validators/index.js' +import { ActorFollowModel } from '../../../models/actor/actor-follow.js' +import { guessAdditionalAttributesFromQuery } from '../../../models/video/formatter/index.js' +import { VideoModel } from '../../../models/video/video.js' const mySubscriptionsRouter = express.Router() diff --git a/server/controllers/api/users/my-video-playlists.ts b/server/server/controllers/api/users/my-video-playlists.ts similarity index 84% rename from server/controllers/api/users/my-video-playlists.ts rename to server/server/controllers/api/users/my-video-playlists.ts index fbdbb7e50..a72ea103d 100644 --- a/server/controllers/api/users/my-video-playlists.ts +++ b/server/server/controllers/api/users/my-video-playlists.ts @@ -1,10 +1,10 @@ import express from 'express' -import { forceNumber } from '@shared/core-utils' -import { uuidToShort } from '@shared/extra-utils' -import { VideosExistInPlaylists } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model' -import { asyncMiddleware, authenticate } from '../../../middlewares' -import { doVideosInPlaylistExistValidator } from '../../../middlewares/validators/videos/video-playlists' -import { VideoPlaylistModel } from '../../../models/video/video-playlist' +import { forceNumber } from '@peertube/peertube-core-utils' +import { VideosExistInPlaylists } from '@peertube/peertube-models' +import { uuidToShort } from '@peertube/peertube-node-utils' +import { asyncMiddleware, authenticate } from '../../../middlewares/index.js' +import { doVideosInPlaylistExistValidator } from '../../../middlewares/validators/videos/video-playlists.js' +import { VideoPlaylistModel } from '../../../models/video/video-playlist.js' const myVideoPlaylistsRouter = express.Router() diff --git a/server/controllers/api/users/registrations.ts b/server/server/controllers/api/users/registrations.ts similarity index 94% rename from server/controllers/api/users/registrations.ts rename to server/server/controllers/api/users/registrations.ts index 5e213d6cc..6c2a309e8 100644 --- a/server/controllers/api/users/registrations.ts +++ b/server/server/controllers/api/users/registrations.ts @@ -1,8 +1,8 @@ import express from 'express' -import { Emailer } from '@server/lib/emailer' -import { Hooks } from '@server/lib/plugins/hooks' -import { UserRegistrationModel } from '@server/models/user/user-registration' -import { pick } from '@shared/core-utils' +import { Emailer } from '@server/lib/emailer.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { UserRegistrationModel } from '@server/models/user/user-registration.js' +import { pick } from '@peertube/peertube-core-utils' import { HttpStatusCode, UserRegister, @@ -10,12 +10,12 @@ import { UserRegistrationState, UserRegistrationUpdateState, UserRight -} from '@shared/models' -import { auditLoggerFactory, UserAuditView } from '../../../helpers/audit-logger' -import { logger } from '../../../helpers/logger' -import { CONFIG } from '../../../initializers/config' -import { Notifier } from '../../../lib/notifier' -import { buildUser, createUserAccountAndChannelAndPlaylist, sendVerifyRegistrationEmail, sendVerifyUserEmail } from '../../../lib/user' +} from '@peertube/peertube-models' +import { auditLoggerFactory, UserAuditView } from '../../../helpers/audit-logger.js' +import { logger } from '../../../helpers/logger.js' +import { CONFIG } from '../../../initializers/config.js' +import { Notifier } from '../../../lib/notifier/index.js' +import { buildUser, createUserAccountAndChannelAndPlaylist, sendVerifyRegistrationEmail, sendVerifyUserEmail } from '../../../lib/user.js' import { acceptOrRejectRegistrationValidator, asyncMiddleware, @@ -33,7 +33,7 @@ import { userRegistrationsSortValidator, usersDirectRegistrationValidator, usersRequestRegistrationValidator -} from '../../../middlewares' +} from '../../../middlewares/index.js' const auditLogger = auditLoggerFactory('users') diff --git a/server/controllers/api/users/token.ts b/server/server/controllers/api/users/token.ts similarity index 89% rename from server/controllers/api/users/token.ts rename to server/server/controllers/api/users/token.ts index c6afea67c..a3f18f6e1 100644 --- a/server/controllers/api/users/token.ts +++ b/server/server/controllers/api/users/token.ts @@ -1,14 +1,14 @@ import express from 'express' -import { logger } from '@server/helpers/logger' -import { CONFIG } from '@server/initializers/config' -import { OTP } from '@server/initializers/constants' -import { getAuthNameFromRefreshGrant, getBypassFromExternalAuth, getBypassFromPasswordGrant } from '@server/lib/auth/external-auth' -import { handleOAuthToken, MissingTwoFactorError } from '@server/lib/auth/oauth' -import { BypassLogin, revokeToken } from '@server/lib/auth/oauth-model' -import { Hooks } from '@server/lib/plugins/hooks' -import { asyncMiddleware, authenticate, buildRateLimiter, openapiOperationDoc } from '@server/middlewares' -import { buildUUID } from '@shared/extra-utils' -import { ScopedToken } from '@shared/models/users/user-scoped-token' +import { ScopedToken } from '@peertube/peertube-models' +import { logger } from '@server/helpers/logger.js' +import { CONFIG } from '@server/initializers/config.js' +import { OTP } from '@server/initializers/constants.js' +import { getAuthNameFromRefreshGrant, getBypassFromExternalAuth, getBypassFromPasswordGrant } from '@server/lib/auth/external-auth.js' +import { BypassLogin, revokeToken } from '@server/lib/auth/oauth-model.js' +import { handleOAuthToken, MissingTwoFactorError } from '@server/lib/auth/oauth.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { asyncMiddleware, authenticate, buildRateLimiter, openapiOperationDoc } from '@server/middlewares/index.js' +import { buildUUID } from '@peertube/peertube-node-utils' const tokensRouter = express.Router() diff --git a/server/controllers/api/users/two-factor.ts b/server/server/controllers/api/users/two-factor.ts similarity index 87% rename from server/controllers/api/users/two-factor.ts rename to server/server/controllers/api/users/two-factor.ts index e6ae9e4dd..f3dba3a53 100644 --- a/server/controllers/api/users/two-factor.ts +++ b/server/server/controllers/api/users/two-factor.ts @@ -1,15 +1,15 @@ import express from 'express' -import { generateOTPSecret, isOTPValid } from '@server/helpers/otp' -import { encrypt } from '@server/helpers/peertube-crypto' -import { CONFIG } from '@server/initializers/config' -import { Redis } from '@server/lib/redis' -import { asyncMiddleware, authenticate, usersCheckCurrentPasswordFactory } from '@server/middlewares' +import { generateOTPSecret, isOTPValid } from '@server/helpers/otp.js' +import { encrypt } from '@server/helpers/peertube-crypto.js' +import { CONFIG } from '@server/initializers/config.js' +import { Redis } from '@server/lib/redis.js' +import { asyncMiddleware, authenticate, usersCheckCurrentPasswordFactory } from '@server/middlewares/index.js' import { confirmTwoFactorValidator, disableTwoFactorValidator, requestOrConfirmTwoFactorValidator -} from '@server/middlewares/validators/two-factor' -import { HttpStatusCode, TwoFactorEnableResult } from '@shared/models' +} from '@server/middlewares/validators/two-factor.js' +import { HttpStatusCode, TwoFactorEnableResult } from '@peertube/peertube-models' const twoFactorRouter = express.Router() diff --git a/server/controllers/api/video-channel-sync.ts b/server/server/controllers/api/video-channel-sync.ts similarity index 88% rename from server/controllers/api/video-channel-sync.ts rename to server/server/controllers/api/video-channel-sync.ts index 6b52ac7dd..fb1f05f7c 100644 --- a/server/controllers/api/video-channel-sync.ts +++ b/server/server/controllers/api/video-channel-sync.ts @@ -1,6 +1,6 @@ import express from 'express' -import { auditLoggerFactory, getAuditIdFromRes, VideoChannelSyncAuditView } from '@server/helpers/audit-logger' -import { logger } from '@server/helpers/logger' +import { auditLoggerFactory, getAuditIdFromRes, VideoChannelSyncAuditView } from '@server/helpers/audit-logger.js' +import { logger } from '@server/helpers/logger.js' import { apiRateLimiter, asyncMiddleware, @@ -10,10 +10,10 @@ import { ensureSyncExists, ensureSyncIsEnabled, videoChannelSyncValidator -} from '@server/middlewares' -import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync' -import { MChannelSyncFormattable } from '@server/types/models' -import { HttpStatusCode, VideoChannelSyncState } from '@shared/models' +} from '@server/middlewares/index.js' +import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync.js' +import { MChannelSyncFormattable } from '@server/types/models/index.js' +import { HttpStatusCode, VideoChannelSyncState } from '@peertube/peertube-models' const videoChannelSyncRouter = express.Router() const auditLogger = auditLoggerFactory('channel-syncs') diff --git a/server/controllers/api/video-channel.ts b/server/server/controllers/api/video-channel.ts similarity index 92% rename from server/controllers/api/video-channel.ts rename to server/server/controllers/api/video-channel.ts index 18de5bf6a..4add1a637 100644 --- a/server/controllers/api/video-channel.ts +++ b/server/server/controllers/api/video-channel.ts @@ -1,21 +1,27 @@ import express from 'express' -import { pickCommonVideoQuery } from '@server/helpers/query' -import { Hooks } from '@server/lib/plugins/hooks' -import { ActorFollowModel } from '@server/models/actor/actor-follow' -import { getServerActor } from '@server/models/application/application' -import { MChannelBannerAccountDefault } from '@server/types/models' -import { ActorImageType, HttpStatusCode, VideoChannelCreate, VideoChannelUpdate, VideosImportInChannelCreate } from '@shared/models' -import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger' -import { resetSequelizeInstance } from '../../helpers/database-utils' -import { buildNSFWFilter, createReqFiles, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' -import { logger } from '../../helpers/logger' -import { getFormattedObjects } from '../../helpers/utils' -import { MIMETYPES } from '../../initializers/constants' -import { sequelizeTypescript } from '../../initializers/database' -import { sendUpdateActor } from '../../lib/activitypub/send' -import { JobQueue } from '../../lib/job-queue' -import { deleteLocalActorImageFile, updateLocalActorImageFiles } from '../../lib/local-actor' -import { createLocalVideoChannel, federateAllVideosOfChannel } from '../../lib/video-channel' +import { + ActorImageType, + HttpStatusCode, + VideoChannelCreate, + VideoChannelUpdate, + VideosImportInChannelCreate +} from '@peertube/peertube-models' +import { pickCommonVideoQuery } from '@server/helpers/query.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { ActorFollowModel } from '@server/models/actor/actor-follow.js' +import { getServerActor } from '@server/models/application/application.js' +import { MChannelBannerAccountDefault } from '@server/types/models/index.js' +import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger.js' +import { resetSequelizeInstance } from '../../helpers/database-utils.js' +import { buildNSFWFilter, createReqFiles, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils.js' +import { logger } from '../../helpers/logger.js' +import { getFormattedObjects } from '../../helpers/utils.js' +import { MIMETYPES } from '../../initializers/constants.js' +import { sequelizeTypescript } from '../../initializers/database.js' +import { sendUpdateActor } from '../../lib/activitypub/send/index.js' +import { JobQueue } from '../../lib/job-queue/index.js' +import { deleteLocalActorImageFile, updateLocalActorImageFiles } from '../../lib/local-actor.js' +import { createLocalVideoChannel, federateAllVideosOfChannel } from '../../lib/video-channel.js' import { apiRateLimiter, asyncMiddleware, @@ -33,7 +39,8 @@ import { videoChannelsSortValidator, videoChannelsUpdateValidator, videoPlaylistsSortValidator -} from '../../middlewares' +} from '../../middlewares/index.js' +import { updateAvatarValidator, updateBannerValidator } from '../../middlewares/validators/actor-image.js' import { ensureChannelOwnerCanUpload, ensureIsLocalChannel, @@ -42,14 +49,13 @@ import { videoChannelsListValidator, videoChannelsNameWithHostValidator, videosSortValidator -} from '../../middlewares/validators' -import { updateAvatarValidator, updateBannerValidator } from '../../middlewares/validators/actor-image' -import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists' -import { AccountModel } from '../../models/account/account' -import { guessAdditionalAttributesFromQuery } from '../../models/video/formatter' -import { VideoModel } from '../../models/video/video' -import { VideoChannelModel } from '../../models/video/video-channel' -import { VideoPlaylistModel } from '../../models/video/video-playlist' +} from '../../middlewares/validators/index.js' +import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists.js' +import { AccountModel } from '../../models/account/account.js' +import { guessAdditionalAttributesFromQuery } from '../../models/video/formatter/index.js' +import { VideoChannelModel } from '../../models/video/video-channel.js' +import { VideoPlaylistModel } from '../../models/video/video-playlist.js' +import { VideoModel } from '../../models/video/video.js' const auditLogger = auditLoggerFactory('channels') const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT) diff --git a/server/controllers/api/video-playlist.ts b/server/server/controllers/api/video-playlist.ts similarity index 91% rename from server/controllers/api/video-playlist.ts rename to server/server/controllers/api/video-playlist.ts index 73362e1e3..64207f50d 100644 --- a/server/controllers/api/video-playlist.ts +++ b/server/server/controllers/api/video-playlist.ts @@ -1,28 +1,32 @@ import express from 'express' -import { scheduleRefreshIfNeeded } from '@server/lib/activitypub/playlists' -import { VideoMiniaturePermanentFileCache } from '@server/lib/files-cache' -import { Hooks } from '@server/lib/plugins/hooks' -import { getServerActor } from '@server/models/application/application' -import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/types/models' -import { forceNumber } from '@shared/core-utils' -import { uuidToShort } from '@shared/extra-utils' -import { VideoPlaylistCreateResult, VideoPlaylistElementCreateResult } from '@shared/models' -import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' -import { VideoPlaylistCreate } from '../../../shared/models/videos/playlist/video-playlist-create.model' -import { VideoPlaylistElementCreate } from '../../../shared/models/videos/playlist/video-playlist-element-create.model' -import { VideoPlaylistElementUpdate } from '../../../shared/models/videos/playlist/video-playlist-element-update.model' -import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' -import { VideoPlaylistReorder } from '../../../shared/models/videos/playlist/video-playlist-reorder.model' -import { VideoPlaylistUpdate } from '../../../shared/models/videos/playlist/video-playlist-update.model' -import { resetSequelizeInstance } from '../../helpers/database-utils' -import { createReqFiles } from '../../helpers/express-utils' -import { logger } from '../../helpers/logger' -import { getFormattedObjects } from '../../helpers/utils' -import { MIMETYPES, VIDEO_PLAYLIST_PRIVACIES } from '../../initializers/constants' -import { sequelizeTypescript } from '../../initializers/database' -import { sendCreateVideoPlaylist, sendDeleteVideoPlaylist, sendUpdateVideoPlaylist } from '../../lib/activitypub/send' -import { getLocalVideoPlaylistActivityPubUrl, getLocalVideoPlaylistElementActivityPubUrl } from '../../lib/activitypub/url' -import { updateLocalPlaylistMiniatureFromExisting } from '../../lib/thumbnail' +import { forceNumber } from '@peertube/peertube-core-utils' +import { + HttpStatusCode, + VideoPlaylistCreate, + VideoPlaylistCreateResult, + VideoPlaylistElementCreate, + VideoPlaylistElementCreateResult, + VideoPlaylistElementUpdate, + VideoPlaylistPrivacy, + VideoPlaylistPrivacyType, + VideoPlaylistReorder, + VideoPlaylistUpdate +} from '@peertube/peertube-models' +import { scheduleRefreshIfNeeded } from '@server/lib/activitypub/playlists/index.js' +import { VideoMiniaturePermanentFileCache } from '@server/lib/files-cache/index.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { getServerActor } from '@server/models/application/application.js' +import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/types/models/index.js' +import { uuidToShort } from '@peertube/peertube-node-utils' +import { resetSequelizeInstance } from '../../helpers/database-utils.js' +import { createReqFiles } from '../../helpers/express-utils.js' +import { logger } from '../../helpers/logger.js' +import { getFormattedObjects } from '../../helpers/utils.js' +import { MIMETYPES, VIDEO_PLAYLIST_PRIVACIES } from '../../initializers/constants.js' +import { sequelizeTypescript } from '../../initializers/database.js' +import { sendCreateVideoPlaylist, sendDeleteVideoPlaylist, sendUpdateVideoPlaylist } from '../../lib/activitypub/send/index.js' +import { getLocalVideoPlaylistActivityPubUrl, getLocalVideoPlaylistElementActivityPubUrl } from '../../lib/activitypub/url.js' +import { updateLocalPlaylistMiniatureFromExisting } from '../../lib/thumbnail.js' import { apiRateLimiter, asyncMiddleware, @@ -32,8 +36,8 @@ import { paginationValidator, setDefaultPagination, setDefaultSort -} from '../../middlewares' -import { videoPlaylistsSortValidator } from '../../middlewares/validators' +} from '../../middlewares/index.js' +import { videoPlaylistsSortValidator } from '../../middlewares/validators/index.js' import { commonVideoPlaylistFiltersValidator, videoPlaylistsAddValidator, @@ -43,10 +47,10 @@ import { videoPlaylistsReorderVideosValidator, videoPlaylistsUpdateOrRemoveVideoValidator, videoPlaylistsUpdateValidator -} from '../../middlewares/validators/videos/video-playlists' -import { AccountModel } from '../../models/account/account' -import { VideoPlaylistModel } from '../../models/video/video-playlist' -import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element' +} from '../../middlewares/validators/videos/video-playlists.js' +import { AccountModel } from '../../models/account/account.js' +import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element.js' +import { VideoPlaylistModel } from '../../models/video/video-playlist.js' const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT) @@ -247,7 +251,7 @@ async function updateVideoPlaylist (req: express.Request, res: express.Response) if (videoPlaylistInfoToUpdate.description !== undefined) videoPlaylistInstance.description = videoPlaylistInfoToUpdate.description if (videoPlaylistInfoToUpdate.privacy !== undefined) { - videoPlaylistInstance.privacy = forceNumber(videoPlaylistInfoToUpdate.privacy) + videoPlaylistInstance.privacy = forceNumber(videoPlaylistInfoToUpdate.privacy) as VideoPlaylistPrivacyType if (wasNotPrivatePlaylist === true && videoPlaylistInstance.privacy === VideoPlaylistPrivacy.PRIVATE) { await sendDeleteVideoPlaylist(videoPlaylistInstance, t) diff --git a/server/controllers/api/videos/blacklist.ts b/server/server/controllers/api/videos/blacklist.ts similarity index 93% rename from server/controllers/api/videos/blacklist.ts rename to server/server/controllers/api/videos/blacklist.ts index 4103bb063..1facbc5d3 100644 --- a/server/controllers/api/videos/blacklist.ts +++ b/server/server/controllers/api/videos/blacklist.ts @@ -1,9 +1,9 @@ import express from 'express' -import { blacklistVideo, unblacklistVideo } from '@server/lib/video-blacklist' -import { HttpStatusCode, UserRight, VideoBlacklistCreate } from '@shared/models' -import { logger } from '../../../helpers/logger' -import { getFormattedObjects } from '../../../helpers/utils' -import { sequelizeTypescript } from '../../../initializers/database' +import { blacklistVideo, unblacklistVideo } from '@server/lib/video-blacklist.js' +import { HttpStatusCode, UserRight, VideoBlacklistCreate } from '@peertube/peertube-models' +import { logger } from '../../../helpers/logger.js' +import { getFormattedObjects } from '../../../helpers/utils.js' +import { sequelizeTypescript } from '../../../initializers/database.js' import { asyncMiddleware, authenticate, @@ -17,8 +17,8 @@ import { videosBlacklistFiltersValidator, videosBlacklistRemoveValidator, videosBlacklistUpdateValidator -} from '../../../middlewares' -import { VideoBlacklistModel } from '../../../models/video/video-blacklist' +} from '../../../middlewares/index.js' +import { VideoBlacklistModel } from '../../../models/video/video-blacklist.js' const blacklistRouter = express.Router() diff --git a/server/controllers/api/videos/captions.ts b/server/server/controllers/api/videos/captions.ts similarity index 85% rename from server/controllers/api/videos/captions.ts rename to server/server/controllers/api/videos/captions.ts index 2b511a398..b8e7149c6 100644 --- a/server/controllers/api/videos/captions.ts +++ b/server/server/controllers/api/videos/captions.ts @@ -1,17 +1,17 @@ import express from 'express' -import { Hooks } from '@server/lib/plugins/hooks' -import { MVideoCaption } from '@server/types/models' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' -import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' -import { createReqFiles } from '../../../helpers/express-utils' -import { logger } from '../../../helpers/logger' -import { getFormattedObjects } from '../../../helpers/utils' -import { MIMETYPES } from '../../../initializers/constants' -import { sequelizeTypescript } from '../../../initializers/database' -import { federateVideoIfNeeded } from '../../../lib/activitypub/videos' -import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate } from '../../../middlewares' -import { addVideoCaptionValidator, deleteVideoCaptionValidator, listVideoCaptionsValidator } from '../../../middlewares/validators' -import { VideoCaptionModel } from '../../../models/video/video-caption' +import { HttpStatusCode } from '@peertube/peertube-models' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { MVideoCaption } from '@server/types/models/index.js' +import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils.js' +import { createReqFiles } from '../../../helpers/express-utils.js' +import { logger } from '../../../helpers/logger.js' +import { getFormattedObjects } from '../../../helpers/utils.js' +import { MIMETYPES } from '../../../initializers/constants.js' +import { sequelizeTypescript } from '../../../initializers/database.js' +import { federateVideoIfNeeded } from '../../../lib/activitypub/videos/index.js' +import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate } from '../../../middlewares/index.js' +import { addVideoCaptionValidator, deleteVideoCaptionValidator, listVideoCaptionsValidator } from '../../../middlewares/validators/index.js' +import { VideoCaptionModel } from '../../../models/video/video-caption.js' const reqVideoCaptionAdd = createReqFiles([ 'captionfile' ], MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT) diff --git a/server/controllers/api/videos/comment.ts b/server/server/controllers/api/videos/comment.ts similarity index 90% rename from server/controllers/api/videos/comment.ts rename to server/server/controllers/api/videos/comment.ts index 70ca21500..ae8994382 100644 --- a/server/controllers/api/videos/comment.ts +++ b/server/server/controllers/api/videos/comment.ts @@ -1,15 +1,19 @@ -import { MCommentFormattable } from '@server/types/models' import express from 'express' - -import { ResultList, ThreadsResultList, UserRight, VideoCommentCreate } from '../../../../shared/models' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' -import { VideoCommentThreads } from '../../../../shared/models/videos/comment/video-comment.model' -import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger' -import { getFormattedObjects } from '../../../helpers/utils' -import { sequelizeTypescript } from '../../../initializers/database' -import { Notifier } from '../../../lib/notifier' -import { Hooks } from '../../../lib/plugins/hooks' -import { buildFormattedCommentTree, createVideoComment, removeComment } from '../../../lib/video-comment' +import { + HttpStatusCode, + ResultList, + ThreadsResultList, + UserRight, + VideoCommentCreate, + VideoCommentThreads +} from '@peertube/peertube-models' +import { MCommentFormattable } from '@server/types/models/index.js' +import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger.js' +import { getFormattedObjects } from '../../../helpers/utils.js' +import { sequelizeTypescript } from '../../../initializers/database.js' +import { Notifier } from '../../../lib/notifier/index.js' +import { Hooks } from '../../../lib/plugins/hooks.js' +import { buildFormattedCommentTree, createVideoComment, removeComment } from '../../../lib/video-comment.js' import { asyncMiddleware, asyncRetryTransactionMiddleware, @@ -19,7 +23,7 @@ import { paginationValidator, setDefaultPagination, setDefaultSort -} from '../../../middlewares' +} from '../../../middlewares/index.js' import { addVideoCommentReplyValidator, addVideoCommentThreadValidator, @@ -29,9 +33,9 @@ import { removeVideoCommentValidator, videoCommentsValidator, videoCommentThreadsSortValidator -} from '../../../middlewares/validators' -import { AccountModel } from '../../../models/account/account' -import { VideoCommentModel } from '../../../models/video/video-comment' +} from '../../../middlewares/validators/index.js' +import { AccountModel } from '../../../models/account/account.js' +import { VideoCommentModel } from '../../../models/video/video-comment.js' const auditLogger = auditLoggerFactory('comments') const videoCommentRouter = express.Router() diff --git a/server/controllers/api/videos/files.ts b/server/server/controllers/api/videos/files.ts similarity index 89% rename from server/controllers/api/videos/files.ts rename to server/server/controllers/api/videos/files.ts index 67b60ff63..c62c85c54 100644 --- a/server/controllers/api/videos/files.ts +++ b/server/server/controllers/api/videos/files.ts @@ -1,11 +1,11 @@ import express from 'express' -import toInt from 'validator/lib/toInt' -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' -import { updatePlaylistAfterFileChange } from '@server/lib/hls' -import { removeAllWebVideoFiles, removeHLSFile, removeHLSPlaylist, removeWebVideoFile } from '@server/lib/video-file' -import { VideoFileModel } from '@server/models/video/video-file' -import { HttpStatusCode, UserRight } from '@shared/models' +import validator from 'validator' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { federateVideoIfNeeded } from '@server/lib/activitypub/videos/index.js' +import { updatePlaylistAfterFileChange } from '@server/lib/hls.js' +import { removeAllWebVideoFiles, removeHLSFile, removeHLSPlaylist, removeWebVideoFile } from '@server/lib/video-file.js' +import { VideoFileModel } from '@server/models/video/video-file.js' +import { HttpStatusCode, UserRight } from '@peertube/peertube-models' import { asyncMiddleware, authenticate, @@ -16,7 +16,7 @@ import { videoFilesDeleteWebVideoFileValidator, videoFilesDeleteWebVideoValidator, videosGetValidator -} from '../../../middlewares' +} from '../../../middlewares/index.js' const lTags = loggerTagsFactory('api', 'video') const filesRouter = express.Router() @@ -64,7 +64,7 @@ export { // --------------------------------------------------------------------------- async function getVideoFileMetadata (req: express.Request, res: express.Response) { - const videoFile = await VideoFileModel.loadWithMetadata(toInt(req.params.videoFileId)) + const videoFile = await VideoFileModel.loadWithMetadata(validator.default.toInt(req.params.videoFileId)) return res.json(videoFile.metadata) } diff --git a/server/controllers/api/videos/import.ts b/server/server/controllers/api/videos/import.ts similarity index 90% rename from server/controllers/api/videos/import.ts rename to server/server/controllers/api/videos/import.ts index defe9efd4..185215cc9 100644 --- a/server/controllers/api/videos/import.ts +++ b/server/server/controllers/api/videos/import.ts @@ -1,20 +1,28 @@ import express from 'express' -import { move, readFile } from 'fs-extra' +import { move } from 'fs-extra/esm' +import { readFile } from 'fs/promises' import { decode } from 'magnet-uri' import parseTorrent, { Instance } from 'parse-torrent' import { join } from 'path' -import { buildYoutubeDLImport, buildVideoFromImport, insertFromImportIntoDB, YoutubeDlImportError } from '@server/lib/video-pre-import' -import { MThumbnail, MVideoThumbnail } from '@server/types/models' -import { HttpStatusCode, ServerErrorCode, ThumbnailType, VideoImportCreate, VideoImportPayload, VideoImportState } from '@shared/models' -import { auditLoggerFactory, getAuditIdFromRes, VideoImportAuditView } from '../../../helpers/audit-logger' -import { isArray } from '../../../helpers/custom-validators/misc' -import { cleanUpReqFiles, createReqFiles } from '../../../helpers/express-utils' -import { logger } from '../../../helpers/logger' -import { getSecureTorrentName } from '../../../helpers/utils' -import { CONFIG } from '../../../initializers/config' -import { MIMETYPES } from '../../../initializers/constants' -import { JobQueue } from '../../../lib/job-queue/job-queue' -import { updateLocalVideoMiniatureFromExisting } from '../../../lib/thumbnail' +import { buildVideoFromImport, buildYoutubeDLImport, insertFromImportIntoDB, YoutubeDlImportError } from '@server/lib/video-pre-import.js' +import { MThumbnail, MVideoThumbnail } from '@server/types/models/index.js' +import { + HttpStatusCode, + ServerErrorCode, + ThumbnailType, + VideoImportCreate, + VideoImportPayload, + VideoImportState +} from '@peertube/peertube-models' +import { auditLoggerFactory, getAuditIdFromRes, VideoImportAuditView } from '../../../helpers/audit-logger.js' +import { isArray } from '../../../helpers/custom-validators/misc.js' +import { cleanUpReqFiles, createReqFiles } from '../../../helpers/express-utils.js' +import { logger } from '../../../helpers/logger.js' +import { getSecureTorrentName } from '../../../helpers/utils.js' +import { CONFIG } from '../../../initializers/config.js' +import { MIMETYPES } from '../../../initializers/constants.js' +import { JobQueue } from '../../../lib/job-queue/job-queue.js' +import { updateLocalVideoMiniatureFromExisting } from '../../../lib/thumbnail.js' import { asyncMiddleware, asyncRetryTransactionMiddleware, @@ -22,7 +30,7 @@ import { videoImportAddValidator, videoImportCancelValidator, videoImportDeleteValidator -} from '../../../middlewares' +} from '../../../middlewares/index.js' const auditLogger = auditLoggerFactory('video-imports') const videoImportsRouter = express.Router() diff --git a/server/controllers/api/videos/index.ts b/server/server/controllers/api/videos/index.ts similarity index 79% rename from server/controllers/api/videos/index.ts rename to server/server/controllers/api/videos/index.ts index 3cdd42289..f8e3d9cb5 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/server/controllers/api/videos/index.ts @@ -1,18 +1,18 @@ import express from 'express' -import { pickCommonVideoQuery } from '@server/helpers/query' -import { doJSONRequest } from '@server/helpers/requests' -import { openapiOperationDoc } from '@server/middlewares/doc' -import { getServerActor } from '@server/models/application/application' -import { MVideoAccountLight } from '@server/types/models' -import { HttpStatusCode } from '../../../../shared/models' -import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' -import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils' -import { logger } from '../../../helpers/logger' -import { getFormattedObjects } from '../../../helpers/utils' -import { REMOTE_SCHEME, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../initializers/constants' -import { sequelizeTypescript } from '../../../initializers/database' -import { JobQueue } from '../../../lib/job-queue' -import { Hooks } from '../../../lib/plugins/hooks' +import { HttpStatusCode } from '@peertube/peertube-models' +import { pickCommonVideoQuery } from '@server/helpers/query.js' +import { doJSONRequest } from '@server/helpers/requests.js' +import { openapiOperationDoc } from '@server/middlewares/doc.js' +import { getServerActor } from '@server/models/application/application.js' +import { MVideoAccountLight } from '@server/types/models/index.js' +import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger.js' +import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils.js' +import { logger } from '../../../helpers/logger.js' +import { getFormattedObjects } from '../../../helpers/utils.js' +import { REMOTE_SCHEME, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../initializers/constants.js' +import { sequelizeTypescript } from '../../../initializers/database.js' +import { JobQueue } from '../../../lib/job-queue/index.js' +import { Hooks } from '../../../lib/plugins/hooks.js' import { apiRateLimiter, asyncMiddleware, @@ -28,27 +28,27 @@ import { videosGetValidator, videosRemoveValidator, videosSortValidator -} from '../../../middlewares' -import { guessAdditionalAttributesFromQuery } from '../../../models/video/formatter' -import { VideoModel } from '../../../models/video/video' -import { blacklistRouter } from './blacklist' -import { videoCaptionsRouter } from './captions' -import { videoCommentRouter } from './comment' -import { filesRouter } from './files' -import { videoImportsRouter } from './import' -import { liveRouter } from './live' -import { ownershipVideoRouter } from './ownership' -import { videoPasswordRouter } from './passwords' -import { rateVideoRouter } from './rate' -import { videoSourceRouter } from './source' -import { statsRouter } from './stats' -import { storyboardRouter } from './storyboard' -import { studioRouter } from './studio' -import { tokenRouter } from './token' -import { transcodingRouter } from './transcoding' -import { updateRouter } from './update' -import { uploadRouter } from './upload' -import { viewRouter } from './view' +} from '../../../middlewares/index.js' +import { guessAdditionalAttributesFromQuery } from '../../../models/video/formatter/index.js' +import { VideoModel } from '../../../models/video/video.js' +import { blacklistRouter } from './blacklist.js' +import { videoCaptionsRouter } from './captions.js' +import { videoCommentRouter } from './comment.js' +import { filesRouter } from './files.js' +import { videoImportsRouter } from './import.js' +import { liveRouter } from './live.js' +import { ownershipVideoRouter } from './ownership.js' +import { videoPasswordRouter } from './passwords.js' +import { rateVideoRouter } from './rate.js' +import { videoSourceRouter } from './source.js' +import { statsRouter } from './stats.js' +import { storyboardRouter } from './storyboard.js' +import { studioRouter } from './studio.js' +import { tokenRouter } from './token.js' +import { transcodingRouter } from './transcoding.js' +import { updateRouter } from './update.js' +import { uploadRouter } from './upload.js' +import { viewRouter } from './view.js' const auditLogger = auditLoggerFactory('videos') const videosRouter = express.Router() diff --git a/server/controllers/api/videos/live.ts b/server/server/controllers/api/videos/live.ts similarity index 87% rename from server/controllers/api/videos/live.ts rename to server/server/controllers/api/videos/live.ts index e19e8c652..84cb3d51b 100644 --- a/server/controllers/api/videos/live.ts +++ b/server/server/controllers/api/videos/live.ts @@ -1,31 +1,39 @@ import express from 'express' -import { exists } from '@server/helpers/custom-validators/misc' -import { createReqFiles } from '@server/helpers/express-utils' -import { getFormattedObjects } from '@server/helpers/utils' -import { ASSETS_PATH, MIMETYPES } from '@server/initializers/constants' -import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url' -import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' -import { Hooks } from '@server/lib/plugins/hooks' -import { buildLocalVideoFromReq, buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video' +import { + HttpStatusCode, + LiveVideoCreate, + LiveVideoLatencyMode, + LiveVideoUpdate, + UserRight, + VideoPrivacy, + VideoState +} from '@peertube/peertube-models' +import { exists } from '@server/helpers/custom-validators/misc.js' +import { createReqFiles } from '@server/helpers/express-utils.js' +import { getFormattedObjects } from '@server/helpers/utils.js' +import { ASSETS_PATH, MIMETYPES } from '@server/initializers/constants.js' +import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url.js' +import { federateVideoIfNeeded } from '@server/lib/activitypub/videos/index.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { buildLocalVideoFromReq, buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video.js' import { videoLiveAddValidator, videoLiveFindReplaySessionValidator, videoLiveGetValidator, videoLiveListSessionsValidator, videoLiveUpdateValidator -} from '@server/middlewares/validators/videos/video-live' -import { VideoLiveModel } from '@server/models/video/video-live' -import { VideoLiveSessionModel } from '@server/models/video/video-live-session' -import { MVideoDetails, MVideoFullLight, MVideoLive } from '@server/types/models' -import { buildUUID, uuidToShort } from '@shared/extra-utils' -import { HttpStatusCode, LiveVideoCreate, LiveVideoLatencyMode, LiveVideoUpdate, UserRight, VideoPrivacy, VideoState } from '@shared/models' -import { logger } from '../../../helpers/logger' -import { sequelizeTypescript } from '../../../initializers/database' -import { updateLocalVideoMiniatureFromExisting } from '../../../lib/thumbnail' -import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, optionalAuthenticate } from '../../../middlewares' -import { VideoModel } from '../../../models/video/video' -import { VideoLiveReplaySettingModel } from '@server/models/video/video-live-replay-setting' -import { VideoPasswordModel } from '@server/models/video/video-password' +} from '@server/middlewares/validators/videos/video-live.js' +import { VideoLiveReplaySettingModel } from '@server/models/video/video-live-replay-setting.js' +import { VideoLiveSessionModel } from '@server/models/video/video-live-session.js' +import { VideoLiveModel } from '@server/models/video/video-live.js' +import { VideoPasswordModel } from '@server/models/video/video-password.js' +import { MVideoDetails, MVideoFullLight, MVideoLive } from '@server/types/models/index.js' +import { buildUUID, uuidToShort } from '@peertube/peertube-node-utils' +import { logger } from '../../../helpers/logger.js' +import { sequelizeTypescript } from '../../../initializers/database.js' +import { updateLocalVideoMiniatureFromExisting } from '../../../lib/thumbnail.js' +import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, optionalAuthenticate } from '../../../middlewares/index.js' +import { VideoModel } from '../../../models/video/video.js' const liveRouter = express.Router() diff --git a/server/controllers/api/videos/ownership.ts b/server/server/controllers/api/videos/ownership.ts similarity index 89% rename from server/controllers/api/videos/ownership.ts rename to server/server/controllers/api/videos/ownership.ts index 88355b289..ceb3a2739 100644 --- a/server/controllers/api/videos/ownership.ts +++ b/server/server/controllers/api/videos/ownership.ts @@ -1,12 +1,11 @@ import express from 'express' -import { MVideoFullLight } from '@server/types/models' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' -import { VideoChangeOwnershipStatus, VideoState } from '../../../../shared/models/videos' -import { logger } from '../../../helpers/logger' -import { getFormattedObjects } from '../../../helpers/utils' -import { sequelizeTypescript } from '../../../initializers/database' -import { sendUpdateVideo } from '../../../lib/activitypub/send' -import { changeVideoChannelShare } from '../../../lib/activitypub/share' +import { HttpStatusCode, VideoChangeOwnershipStatus, VideoState } from '@peertube/peertube-models' +import { MVideoFullLight } from '@server/types/models/index.js' +import { logger } from '../../../helpers/logger.js' +import { getFormattedObjects } from '../../../helpers/utils.js' +import { sequelizeTypescript } from '../../../initializers/database.js' +import { sendUpdateVideo } from '../../../lib/activitypub/send/index.js' +import { changeVideoChannelShare } from '../../../lib/activitypub/share.js' import { asyncMiddleware, asyncRetryTransactionMiddleware, @@ -16,10 +15,10 @@ import { videosAcceptChangeOwnershipValidator, videosChangeOwnershipValidator, videosTerminateChangeOwnershipValidator -} from '../../../middlewares' -import { VideoModel } from '../../../models/video/video' -import { VideoChangeOwnershipModel } from '../../../models/video/video-change-ownership' -import { VideoChannelModel } from '../../../models/video/video-channel' +} from '../../../middlewares/index.js' +import { VideoChangeOwnershipModel } from '../../../models/video/video-change-ownership.js' +import { VideoChannelModel } from '../../../models/video/video-channel.js' +import { VideoModel } from '../../../models/video/video.js' const ownershipVideoRouter = express.Router() diff --git a/server/controllers/api/videos/passwords.ts b/server/server/controllers/api/videos/passwords.ts similarity index 90% rename from server/controllers/api/videos/passwords.ts rename to server/server/controllers/api/videos/passwords.ts index d11cf5bcc..bc356e8ac 100644 --- a/server/controllers/api/videos/passwords.ts +++ b/server/server/controllers/api/videos/passwords.ts @@ -1,25 +1,24 @@ import express from 'express' - -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' -import { getFormattedObjects } from '../../../helpers/utils' +import { Transaction } from 'sequelize' +import { HttpStatusCode } from '@peertube/peertube-models' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { getVideoWithAttributes } from '@server/helpers/video.js' +import { VideoPasswordModel } from '@server/models/video/video-password.js' +import { getFormattedObjects } from '../../../helpers/utils.js' import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, setDefaultPagination, setDefaultSort -} from '../../../middlewares' +} from '../../../middlewares/index.js' import { listVideoPasswordValidator, paginationValidator, removeVideoPasswordValidator, updateVideoPasswordListValidator, videoPasswordsSortValidator -} from '../../../middlewares/validators' -import { VideoPasswordModel } from '@server/models/video/video-password' -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { Transaction } from 'sequelize' -import { getVideoWithAttributes } from '@server/helpers/video' +} from '../../../middlewares/validators/index.js' const lTags = loggerTagsFactory('api', 'video') const videoPasswordRouter = express.Router() diff --git a/server/controllers/api/videos/rate.ts b/server/server/controllers/api/videos/rate.ts similarity index 90% rename from server/controllers/api/videos/rate.ts rename to server/server/controllers/api/videos/rate.ts index 6b26a8eee..b0c4a328d 100644 --- a/server/controllers/api/videos/rate.ts +++ b/server/server/controllers/api/videos/rate.ts @@ -1,12 +1,12 @@ import express from 'express' -import { HttpStatusCode, UserVideoRateUpdate } from '@shared/models' -import { logger } from '../../../helpers/logger' -import { VIDEO_RATE_TYPES } from '../../../initializers/constants' -import { sequelizeTypescript } from '../../../initializers/database' -import { getLocalRateUrl, sendVideoRateChange } from '../../../lib/activitypub/video-rates' -import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoUpdateRateValidator } from '../../../middlewares' -import { AccountModel } from '../../../models/account/account' -import { AccountVideoRateModel } from '../../../models/account/account-video-rate' +import { HttpStatusCode, UserVideoRateUpdate } from '@peertube/peertube-models' +import { logger } from '../../../helpers/logger.js' +import { VIDEO_RATE_TYPES } from '../../../initializers/constants.js' +import { sequelizeTypescript } from '../../../initializers/database.js' +import { getLocalRateUrl, sendVideoRateChange } from '../../../lib/activitypub/video-rates.js' +import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoUpdateRateValidator } from '../../../middlewares/index.js' +import { AccountModel } from '../../../models/account/account.js' +import { AccountVideoRateModel } from '../../../models/account/account-video-rate.js' const rateVideoRouter = express.Router() diff --git a/server/controllers/api/videos/source.ts b/server/server/controllers/api/videos/source.ts similarity index 90% rename from server/controllers/api/videos/source.ts rename to server/server/controllers/api/videos/source.ts index 75fe68b6c..d66062842 100644 --- a/server/controllers/api/videos/source.ts +++ b/server/server/controllers/api/videos/source.ts @@ -1,28 +1,28 @@ import express from 'express' -import { move } from 'fs-extra' -import { sequelizeTypescript } from '@server/initializers/database' -import { CreateJobArgument, CreateJobOptions, JobQueue } from '@server/lib/job-queue' -import { Hooks } from '@server/lib/plugins/hooks' -import { regenerateMiniaturesIfNeeded } from '@server/lib/thumbnail' -import { uploadx } from '@server/lib/uploadx' -import { buildMoveToObjectStorageJob } from '@server/lib/video' -import { autoBlacklistVideoIfNeeded } from '@server/lib/video-blacklist' -import { buildNewFile } from '@server/lib/video-file' -import { VideoPathManager } from '@server/lib/video-path-manager' -import { buildNextVideoState } from '@server/lib/video-state' -import { openapiOperationDoc } from '@server/middlewares/doc' -import { VideoModel } from '@server/models/video/video' -import { VideoSourceModel } from '@server/models/video/video-source' -import { MStreamingPlaylistFiles, MVideo, MVideoFile, MVideoFullLight } from '@server/types/models' -import { VideoState } from '@shared/models' -import { logger, loggerTagsFactory } from '../../../helpers/logger' +import { move } from 'fs-extra/esm' +import { sequelizeTypescript } from '@server/initializers/database.js' +import { CreateJobArgument, CreateJobOptions, JobQueue } from '@server/lib/job-queue/index.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { regenerateMiniaturesIfNeeded } from '@server/lib/thumbnail.js' +import { uploadx } from '@server/lib/uploadx.js' +import { buildMoveToObjectStorageJob } from '@server/lib/video.js' +import { autoBlacklistVideoIfNeeded } from '@server/lib/video-blacklist.js' +import { buildNewFile } from '@server/lib/video-file.js' +import { VideoPathManager } from '@server/lib/video-path-manager.js' +import { buildNextVideoState } from '@server/lib/video-state.js' +import { openapiOperationDoc } from '@server/middlewares/doc.js' +import { VideoModel } from '@server/models/video/video.js' +import { VideoSourceModel } from '@server/models/video/video-source.js' +import { MStreamingPlaylistFiles, MVideo, MVideoFile, MVideoFullLight } from '@server/types/models/index.js' +import { VideoState } from '@peertube/peertube-models' +import { logger, loggerTagsFactory } from '../../../helpers/logger.js' import { asyncMiddleware, authenticate, replaceVideoSourceResumableInitValidator, replaceVideoSourceResumableValidator, videoSourceGetLatestValidator -} from '../../../middlewares' +} from '../../../middlewares/index.js' const lTags = loggerTagsFactory('api', 'video') diff --git a/server/controllers/api/videos/stats.ts b/server/server/controllers/api/videos/stats.ts similarity index 94% rename from server/controllers/api/videos/stats.ts rename to server/server/controllers/api/videos/stats.ts index e79f01888..8b3182e49 100644 --- a/server/controllers/api/videos/stats.ts +++ b/server/server/controllers/api/videos/stats.ts @@ -1,13 +1,13 @@ import express from 'express' -import { LocalVideoViewerModel } from '@server/models/view/local-video-viewer' -import { VideoStatsOverallQuery, VideoStatsTimeserieMetric, VideoStatsTimeserieQuery } from '@shared/models' +import { LocalVideoViewerModel } from '@server/models/view/local-video-viewer.js' +import { VideoStatsOverallQuery, VideoStatsTimeserieMetric, VideoStatsTimeserieQuery } from '@peertube/peertube-models' import { asyncMiddleware, authenticate, videoOverallStatsValidator, videoRetentionStatsValidator, videoTimeserieStatsValidator -} from '../../../middlewares' +} from '../../../middlewares/index.js' const statsRouter = express.Router() diff --git a/server/controllers/api/videos/storyboard.ts b/server/server/controllers/api/videos/storyboard.ts similarity index 89% rename from server/controllers/api/videos/storyboard.ts rename to server/server/controllers/api/videos/storyboard.ts index 47a22011d..92e580141 100644 --- a/server/controllers/api/videos/storyboard.ts +++ b/server/server/controllers/api/videos/storyboard.ts @@ -1,7 +1,7 @@ import express from 'express' -import { getVideoWithAttributes } from '@server/helpers/video' -import { StoryboardModel } from '@server/models/video/storyboard' -import { asyncMiddleware, videosGetValidator } from '../../../middlewares' +import { getVideoWithAttributes } from '@server/helpers/video.js' +import { StoryboardModel } from '@server/models/video/storyboard.js' +import { asyncMiddleware, videosGetValidator } from '../../../middlewares/index.js' const storyboardRouter = express.Router() diff --git a/server/controllers/api/videos/studio.ts b/server/server/controllers/api/videos/studio.ts similarity index 96% rename from server/controllers/api/videos/studio.ts rename to server/server/controllers/api/videos/studio.ts index 7c31dfd2b..642bd26ed 100644 --- a/server/controllers/api/videos/studio.ts +++ b/server/server/controllers/api/videos/studio.ts @@ -1,10 +1,10 @@ import Bluebird from 'bluebird' import express from 'express' -import { move } from 'fs-extra' +import { move } from 'fs-extra/esm' import { basename } from 'path' -import { createAnyReqFiles } from '@server/helpers/express-utils' -import { MIMETYPES, VIDEO_FILTERS } from '@server/initializers/constants' -import { buildTaskFileFieldname, createVideoStudioJob, getStudioTaskFilePath, getTaskFileFromReq } from '@server/lib/video-studio' +import { createAnyReqFiles } from '@server/helpers/express-utils.js' +import { MIMETYPES, VIDEO_FILTERS } from '@server/initializers/constants.js' +import { buildTaskFileFieldname, createVideoStudioJob, getStudioTaskFilePath, getTaskFileFromReq } from '@server/lib/video-studio.js' import { HttpStatusCode, VideoState, @@ -15,8 +15,8 @@ import { VideoStudioTaskOutro, VideoStudioTaskPayload, VideoStudioTaskWatermark -} from '@shared/models' -import { asyncMiddleware, authenticate, videoStudioAddEditionValidator } from '../../../middlewares' +} from '@peertube/peertube-models' +import { asyncMiddleware, authenticate, videoStudioAddEditionValidator } from '../../../middlewares/index.js' const studioRouter = express.Router() diff --git a/server/controllers/api/videos/token.ts b/server/server/controllers/api/videos/token.ts similarity index 86% rename from server/controllers/api/videos/token.ts rename to server/server/controllers/api/videos/token.ts index e961ffd9e..9892518aa 100644 --- a/server/controllers/api/videos/token.ts +++ b/server/server/controllers/api/videos/token.ts @@ -1,7 +1,7 @@ import express from 'express' -import { VideoTokensManager } from '@server/lib/video-tokens-manager' -import { VideoPrivacy, VideoToken } from '@shared/models' -import { asyncMiddleware, optionalAuthenticate, videoFileTokenValidator, videosCustomGetValidator } from '../../../middlewares' +import { VideoTokensManager } from '@server/lib/video-tokens-manager.js' +import { VideoPrivacy, VideoToken } from '@peertube/peertube-models' +import { asyncMiddleware, optionalAuthenticate, videoFileTokenValidator, videosCustomGetValidator } from '../../../middlewares/index.js' const tokenRouter = express.Router() diff --git a/server/controllers/api/videos/transcoding.ts b/server/server/controllers/api/videos/transcoding.ts similarity index 89% rename from server/controllers/api/videos/transcoding.ts rename to server/server/controllers/api/videos/transcoding.ts index c0b93742f..5a5eb6dd1 100644 --- a/server/controllers/api/videos/transcoding.ts +++ b/server/server/controllers/api/videos/transcoding.ts @@ -1,11 +1,11 @@ import express from 'express' -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { Hooks } from '@server/lib/plugins/hooks' -import { createTranscodingJobs } from '@server/lib/transcoding/create-transcoding-job' -import { computeResolutionsToTranscode } from '@server/lib/transcoding/transcoding-resolutions' -import { VideoJobInfoModel } from '@server/models/video/video-job-info' -import { HttpStatusCode, UserRight, VideoState, VideoTranscodingCreate } from '@shared/models' -import { asyncMiddleware, authenticate, createTranscodingValidator, ensureUserHasRight } from '../../../middlewares' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { createTranscodingJobs } from '@server/lib/transcoding/create-transcoding-job.js' +import { computeResolutionsToTranscode } from '@server/lib/transcoding/transcoding-resolutions.js' +import { VideoJobInfoModel } from '@server/models/video/video-job-info.js' +import { HttpStatusCode, UserRight, VideoState, VideoTranscodingCreate } from '@peertube/peertube-models' +import { asyncMiddleware, authenticate, createTranscodingValidator, ensureUserHasRight } from '../../../middlewares/index.js' const lTags = loggerTagsFactory('api', 'video') const transcodingRouter = express.Router() diff --git a/server/controllers/api/videos/update.ts b/server/server/controllers/api/videos/update.ts similarity index 87% rename from server/controllers/api/videos/update.ts rename to server/server/controllers/api/videos/update.ts index 1edc509dc..1c8cecba1 100644 --- a/server/controllers/api/videos/update.ts +++ b/server/server/controllers/api/videos/update.ts @@ -1,27 +1,27 @@ import express from 'express' -import { Transaction } from 'sequelize/types' -import { changeVideoChannelShare } from '@server/lib/activitypub/share' -import { addVideoJobsAfterUpdate, buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video' -import { setVideoPrivacy } from '@server/lib/video-privacy' -import { openapiOperationDoc } from '@server/middlewares/doc' -import { FilteredModelAttributes } from '@server/types' -import { MVideoFullLight } from '@server/types/models' -import { forceNumber } from '@shared/core-utils' -import { HttpStatusCode, VideoPrivacy, VideoUpdate } from '@shared/models' -import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' -import { resetSequelizeInstance } from '../../../helpers/database-utils' -import { createReqFiles } from '../../../helpers/express-utils' -import { logger, loggerTagsFactory } from '../../../helpers/logger' -import { MIMETYPES } from '../../../initializers/constants' -import { sequelizeTypescript } from '../../../initializers/database' -import { Hooks } from '../../../lib/plugins/hooks' -import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' -import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videosUpdateValidator } from '../../../middlewares' -import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' -import { VideoModel } from '../../../models/video/video' -import { VideoPathManager } from '@server/lib/video-path-manager' -import { VideoPasswordModel } from '@server/models/video/video-password' -import { exists } from '@server/helpers/custom-validators/misc' +import { Transaction } from 'sequelize' +import { forceNumber } from '@peertube/peertube-core-utils' +import { HttpStatusCode, VideoPrivacy, VideoPrivacyType, VideoUpdate } from '@peertube/peertube-models' +import { exists } from '@server/helpers/custom-validators/misc.js' +import { changeVideoChannelShare } from '@server/lib/activitypub/share.js' +import { VideoPathManager } from '@server/lib/video-path-manager.js' +import { setVideoPrivacy } from '@server/lib/video-privacy.js' +import { addVideoJobsAfterUpdate, buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video.js' +import { openapiOperationDoc } from '@server/middlewares/doc.js' +import { VideoPasswordModel } from '@server/models/video/video-password.js' +import { FilteredModelAttributes } from '@server/types/index.js' +import { MVideoFullLight } from '@server/types/models/index.js' +import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger.js' +import { resetSequelizeInstance } from '../../../helpers/database-utils.js' +import { createReqFiles } from '../../../helpers/express-utils.js' +import { logger, loggerTagsFactory } from '../../../helpers/logger.js' +import { MIMETYPES } from '../../../initializers/constants.js' +import { sequelizeTypescript } from '../../../initializers/database.js' +import { Hooks } from '../../../lib/plugins/hooks.js' +import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist.js' +import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videosUpdateValidator } from '../../../middlewares/index.js' +import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update.js' +import { VideoModel } from '../../../models/video/video.js' const lTags = loggerTagsFactory('api', 'video') const auditLogger = auditLoggerFactory('videos') @@ -176,7 +176,7 @@ async function updateVideoPrivacy (options: { const { videoInstance, videoInfoToUpdate, hadPrivacyForFederation, transaction } = options const isNewVideo = videoInstance.isNewVideo(videoInfoToUpdate.privacy) - const newPrivacy = forceNumber(videoInfoToUpdate.privacy) + const newPrivacy = forceNumber(videoInfoToUpdate.privacy) as VideoPrivacyType setVideoPrivacy(videoInstance, newPrivacy) // Delete passwords if video is not anymore password protected diff --git a/server/controllers/api/videos/upload.ts b/server/server/controllers/api/videos/upload.ts similarity index 90% rename from server/controllers/api/videos/upload.ts rename to server/server/controllers/api/videos/upload.ts index e520bf4b5..47f06e336 100644 --- a/server/controllers/api/videos/upload.ts +++ b/server/server/controllers/api/videos/upload.ts @@ -1,29 +1,29 @@ import express from 'express' -import { move } from 'fs-extra' +import { move } from 'fs-extra/esm' import { basename } from 'path' -import { getResumableUploadPath } from '@server/helpers/upload' -import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url' -import { CreateJobArgument, CreateJobOptions, JobQueue } from '@server/lib/job-queue' -import { Redis } from '@server/lib/redis' -import { uploadx } from '@server/lib/uploadx' -import { buildLocalVideoFromReq, buildMoveToObjectStorageJob, buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video' -import { buildNewFile } from '@server/lib/video-file' -import { VideoPathManager } from '@server/lib/video-path-manager' -import { buildNextVideoState } from '@server/lib/video-state' -import { openapiOperationDoc } from '@server/middlewares/doc' -import { VideoPasswordModel } from '@server/models/video/video-password' -import { VideoSourceModel } from '@server/models/video/video-source' -import { MVideoFile, MVideoFullLight } from '@server/types/models' -import { uuidToShort } from '@shared/extra-utils' -import { HttpStatusCode, VideoCreate, VideoPrivacy, VideoState } from '@shared/models' -import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' -import { createReqFiles } from '../../../helpers/express-utils' -import { logger, loggerTagsFactory } from '../../../helpers/logger' -import { MIMETYPES } from '../../../initializers/constants' -import { sequelizeTypescript } from '../../../initializers/database' -import { Hooks } from '../../../lib/plugins/hooks' -import { generateLocalVideoMiniature } from '../../../lib/thumbnail' -import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' +import { getResumableUploadPath } from '@server/helpers/upload.js' +import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url.js' +import { CreateJobArgument, CreateJobOptions, JobQueue } from '@server/lib/job-queue/index.js' +import { Redis } from '@server/lib/redis.js' +import { uploadx } from '@server/lib/uploadx.js' +import { buildLocalVideoFromReq, buildMoveToObjectStorageJob, buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video.js' +import { buildNewFile } from '@server/lib/video-file.js' +import { VideoPathManager } from '@server/lib/video-path-manager.js' +import { buildNextVideoState } from '@server/lib/video-state.js' +import { openapiOperationDoc } from '@server/middlewares/doc.js' +import { VideoPasswordModel } from '@server/models/video/video-password.js' +import { VideoSourceModel } from '@server/models/video/video-source.js' +import { MVideoFile, MVideoFullLight } from '@server/types/models/index.js' +import { uuidToShort } from '@peertube/peertube-node-utils' +import { HttpStatusCode, VideoCreate, VideoPrivacy, VideoState } from '@peertube/peertube-models' +import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger.js' +import { createReqFiles } from '../../../helpers/express-utils.js' +import { logger, loggerTagsFactory } from '../../../helpers/logger.js' +import { MIMETYPES } from '../../../initializers/constants.js' +import { sequelizeTypescript } from '../../../initializers/database.js' +import { Hooks } from '../../../lib/plugins/hooks.js' +import { generateLocalVideoMiniature } from '../../../lib/thumbnail.js' +import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist.js' import { asyncMiddleware, asyncRetryTransactionMiddleware, @@ -31,9 +31,9 @@ import { videosAddLegacyValidator, videosAddResumableInitValidator, videosAddResumableValidator -} from '../../../middlewares' -import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' -import { VideoModel } from '../../../models/video/video' +} from '../../../middlewares/index.js' +import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update.js' +import { VideoModel } from '../../../models/video/video.js' const lTags = loggerTagsFactory('api', 'video') const auditLogger = auditLoggerFactory('videos') diff --git a/server/controllers/api/videos/view.ts b/server/server/controllers/api/videos/view.ts similarity index 80% rename from server/controllers/api/videos/view.ts rename to server/server/controllers/api/videos/view.ts index a747fa334..cc0534753 100644 --- a/server/controllers/api/videos/view.ts +++ b/server/server/controllers/api/videos/view.ts @@ -1,10 +1,16 @@ import express from 'express' -import { Hooks } from '@server/lib/plugins/hooks' -import { VideoViewsManager } from '@server/lib/views/video-views-manager' -import { MVideoId } from '@server/types/models' -import { HttpStatusCode, VideoView } from '@shared/models' -import { asyncMiddleware, methodsValidator, openapiOperationDoc, optionalAuthenticate, videoViewValidator } from '../../../middlewares' -import { UserVideoHistoryModel } from '../../../models/user/user-video-history' +import { HttpStatusCode, VideoView } from '@peertube/peertube-models' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { VideoViewsManager } from '@server/lib/views/video-views-manager.js' +import { MVideoId } from '@server/types/models/index.js' +import { + asyncMiddleware, + methodsValidator, + openapiOperationDoc, + optionalAuthenticate, + videoViewValidator +} from '../../../middlewares/index.js' +import { UserVideoHistoryModel } from '../../../models/user/user-video-history.js' const viewRouter = express.Router() diff --git a/server/controllers/client.ts b/server/server/controllers/client.ts similarity index 92% rename from server/controllers/client.ts rename to server/server/controllers/client.ts index 2d0c49904..a790859c7 100644 --- a/server/controllers/client.ts +++ b/server/server/controllers/client.ts @@ -1,16 +1,16 @@ import express from 'express' import { constants, promises as fs } from 'fs' -import { readFile } from 'fs-extra' +import { readFile } from 'fs/promises' import { join } from 'path' -import { logger } from '@server/helpers/logger' -import { CONFIG } from '@server/initializers/config' -import { Hooks } from '@server/lib/plugins/hooks' -import { root } from '@shared/core-utils' -import { buildFileLocale, getCompleteLocale, is18nLocale, LOCALE_FILES } from '@shared/core-utils/i18n' -import { HttpStatusCode } from '@shared/models' -import { STATIC_MAX_AGE } from '../initializers/constants' -import { ClientHtml, sendHTML, serveIndexHTML } from '../lib/client-html' -import { asyncMiddleware, buildRateLimiter, embedCSP } from '../middlewares' +import { buildFileLocale, getCompleteLocale, is18nLocale, LOCALE_FILES } from '@peertube/peertube-core-utils' +import { HttpStatusCode } from '@peertube/peertube-models' +import { logger } from '@server/helpers/logger.js' +import { CONFIG } from '@server/initializers/config.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { currentDir, root } from '@peertube/peertube-node-utils' +import { STATIC_MAX_AGE } from '../initializers/constants.js' +import { ClientHtml, sendHTML, serveIndexHTML } from '../lib/client-html.js' +import { asyncMiddleware, buildRateLimiter, embedCSP } from '../middlewares/index.js' const clientsRouter = express.Router() @@ -135,7 +135,7 @@ function serveServerTranslations (req: express.Request, res: express.Response) { const completeLocale = getCompleteLocale(locale) const completeFileLocale = buildFileLocale(completeLocale) - const path = join(__dirname, `../../../client/dist/locale/${file}.${completeFileLocale}.json`) + const path = join(currentDir(import.meta.url), `../../../client/dist/locale/${file}.${completeFileLocale}.json`) return res.sendFile(path, { maxAge: STATIC_MAX_AGE.SERVER }) } diff --git a/server/controllers/download.ts b/server/server/controllers/download.ts similarity index 94% rename from server/controllers/download.ts rename to server/server/controllers/download.ts index 4b94e34bd..51b7b3af5 100644 --- a/server/controllers/download.ts +++ b/server/server/controllers/download.ts @@ -1,15 +1,15 @@ import cors from 'cors' import express from 'express' -import { logger } from '@server/helpers/logger' -import { VideoTorrentsSimpleFileCache } from '@server/lib/files-cache' -import { generateHLSFilePresignedUrl, generateWebVideoPresignedUrl } from '@server/lib/object-storage' -import { Hooks } from '@server/lib/plugins/hooks' -import { VideoPathManager } from '@server/lib/video-path-manager' -import { MStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoFullLight } from '@server/types/models' -import { forceNumber } from '@shared/core-utils' -import { HttpStatusCode, VideoStorage, VideoStreamingPlaylistType } from '@shared/models' -import { STATIC_DOWNLOAD_PATHS } from '../initializers/constants' -import { asyncMiddleware, optionalAuthenticate, videosDownloadValidator } from '../middlewares' +import { logger } from '@server/helpers/logger.js' +import { VideoTorrentsSimpleFileCache } from '@server/lib/files-cache/index.js' +import { generateHLSFilePresignedUrl, generateWebVideoPresignedUrl } from '@server/lib/object-storage/index.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { VideoPathManager } from '@server/lib/video-path-manager.js' +import { MStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoFullLight } from '@server/types/models/index.js' +import { forceNumber } from '@peertube/peertube-core-utils' +import { HttpStatusCode, VideoStorage, VideoStreamingPlaylistType } from '@peertube/peertube-models' +import { STATIC_DOWNLOAD_PATHS } from '../initializers/constants.js' +import { asyncMiddleware, optionalAuthenticate, videosDownloadValidator } from '../middlewares/index.js' const downloadRouter = express.Router() diff --git a/server/controllers/feeds/comment-feeds.ts b/server/server/controllers/feeds/comment-feeds.ts similarity index 89% rename from server/controllers/feeds/comment-feeds.ts rename to server/server/controllers/feeds/comment-feeds.ts index c013662ea..4178f198e 100644 --- a/server/controllers/feeds/comment-feeds.ts +++ b/server/server/controllers/feeds/comment-feeds.ts @@ -1,17 +1,17 @@ import express from 'express' -import { toSafeHtml } from '@server/helpers/markdown' -import { cacheRouteFactory } from '@server/middlewares' -import { CONFIG } from '../../initializers/config' -import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../../initializers/constants' +import { toSafeHtml } from '@server/helpers/markdown.js' +import { cacheRouteFactory } from '@server/middlewares/index.js' +import { CONFIG } from '../../initializers/config.js' +import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../../initializers/constants.js' import { asyncMiddleware, feedsFormatValidator, setFeedFormatContentType, videoCommentsFeedsValidator, feedsAccountOrChannelFiltersValidator -} from '../../middlewares' -import { VideoCommentModel } from '../../models/video/video-comment' -import { buildFeedMetadata, initFeed, sendFeed } from './shared' +} from '../../middlewares/index.js' +import { VideoCommentModel } from '../../models/video/video-comment.js' +import { buildFeedMetadata, initFeed, sendFeed } from './shared/index.js' const commentFeedsRouter = express.Router() diff --git a/server/controllers/feeds/index.ts b/server/server/controllers/feeds/index.ts similarity index 62% rename from server/controllers/feeds/index.ts rename to server/server/controllers/feeds/index.ts index 19352318d..b7210372f 100644 --- a/server/controllers/feeds/index.ts +++ b/server/server/controllers/feeds/index.ts @@ -1,9 +1,9 @@ import express from 'express' -import { CONFIG } from '@server/initializers/config' -import { buildRateLimiter } from '@server/middlewares' -import { commentFeedsRouter } from './comment-feeds' -import { videoFeedsRouter } from './video-feeds' -import { videoPodcastFeedsRouter } from './video-podcast-feeds' +import { CONFIG } from '@server/initializers/config.js' +import { buildRateLimiter } from '@server/middlewares/index.js' +import { commentFeedsRouter } from './comment-feeds.js' +import { videoFeedsRouter } from './video-feeds.js' +import { videoPodcastFeedsRouter } from './video-podcast-feeds.js' const feedsRouter = express.Router() diff --git a/server/controllers/feeds/shared/common-feed-utils.ts b/server/server/controllers/feeds/shared/common-feed-utils.ts similarity index 90% rename from server/controllers/feeds/shared/common-feed-utils.ts rename to server/server/controllers/feeds/shared/common-feed-utils.ts index 9e2f8adbb..af9cafb5d 100644 --- a/server/controllers/feeds/shared/common-feed-utils.ts +++ b/server/server/controllers/feeds/shared/common-feed-utils.ts @@ -1,14 +1,14 @@ import express from 'express' import { Feed } from '@peertube/feed' -import { CustomTag, CustomXMLNS, Person } from '@peertube/feed/lib/typings' -import { mdToOneLinePlainText } from '@server/helpers/markdown' -import { CONFIG } from '@server/initializers/config' -import { WEBSERVER } from '@server/initializers/constants' -import { getBiggestActorImage } from '@server/lib/actor-image' -import { UserModel } from '@server/models/user/user' -import { MAccountDefault, MChannelBannerAccountDefault, MUser, MVideoFullLight } from '@server/types/models' -import { pick } from '@shared/core-utils' -import { ActorImageType } from '@shared/models' +import { CustomTag, CustomXMLNS, Person } from '@peertube/feed/lib/typings/index.js' +import { mdToOneLinePlainText } from '@server/helpers/markdown.js' +import { CONFIG } from '@server/initializers/config.js' +import { WEBSERVER } from '@server/initializers/constants.js' +import { getBiggestActorImage } from '@server/lib/actor-image.js' +import { UserModel } from '@server/models/user/user.js' +import { MAccountDefault, MChannelBannerAccountDefault, MUser, MVideoFullLight } from '@server/types/models/index.js' +import { pick } from '@peertube/peertube-core-utils' +import { ActorImageType } from '@peertube/peertube-models' export function initFeed (parameters: { name: string diff --git a/server/server/controllers/feeds/shared/index.ts b/server/server/controllers/feeds/shared/index.ts new file mode 100644 index 000000000..b36a7265c --- /dev/null +++ b/server/server/controllers/feeds/shared/index.ts @@ -0,0 +1,2 @@ +export * from './video-feed-utils.js' +export * from './common-feed-utils.js' diff --git a/server/controllers/feeds/shared/video-feed-utils.ts b/server/server/controllers/feeds/shared/video-feed-utils.ts similarity index 79% rename from server/controllers/feeds/shared/video-feed-utils.ts rename to server/server/controllers/feeds/shared/video-feed-utils.ts index b154e04fa..b6306c214 100644 --- a/server/controllers/feeds/shared/video-feed-utils.ts +++ b/server/server/controllers/feeds/shared/video-feed-utils.ts @@ -1,18 +1,18 @@ -import { mdToOneLinePlainText, toSafeHtml } from '@server/helpers/markdown' -import { CONFIG } from '@server/initializers/config' -import { WEBSERVER } from '@server/initializers/constants' -import { getServerActor } from '@server/models/application/application' -import { getCategoryLabel } from '@server/models/video/formatter' -import { DisplayOnlyForFollowerOptions } from '@server/models/video/sql/video' -import { VideoModel } from '@server/models/video/video' -import { MThumbnail, MUserDefault } from '@server/types/models' -import { VideoInclude } from '@shared/models' +import { VideoIncludeType } from '@peertube/peertube-models' +import { mdToOneLinePlainText, toSafeHtml } from '@server/helpers/markdown.js' +import { CONFIG } from '@server/initializers/config.js' +import { WEBSERVER } from '@server/initializers/constants.js' +import { getServerActor } from '@server/models/application/application.js' +import { getCategoryLabel } from '@server/models/video/formatter/index.js' +import { DisplayOnlyForFollowerOptions } from '@server/models/video/sql/video/index.js' +import { VideoModel } from '@server/models/video/video.js' +import { MThumbnail, MUserDefault } from '@server/types/models/index.js' export async function getVideosForFeeds (options: { sort: string nsfw: boolean isLocal: boolean - include: VideoInclude + include: VideoIncludeType accountId?: number videoChannelId?: number diff --git a/server/controllers/feeds/video-feeds.ts b/server/server/controllers/feeds/video-feeds.ts similarity index 93% rename from server/controllers/feeds/video-feeds.ts rename to server/server/controllers/feeds/video-feeds.ts index e5941be40..fc0e6e0f7 100644 --- a/server/controllers/feeds/video-feeds.ts +++ b/server/server/controllers/feeds/video-feeds.ts @@ -1,11 +1,11 @@ import express from 'express' import { extname } from 'path' import { Feed } from '@peertube/feed' -import { cacheRouteFactory } from '@server/middlewares' -import { VideoModel } from '@server/models/video/video' -import { VideoInclude } from '@shared/models' -import { buildNSFWFilter } from '../../helpers/express-utils' -import { MIMETYPES, ROUTE_CACHE_LIFETIME, WEBSERVER } from '../../initializers/constants' +import { cacheRouteFactory } from '@server/middlewares/index.js' +import { VideoModel } from '@server/models/video/video.js' +import { VideoInclude } from '@peertube/peertube-models' +import { buildNSFWFilter } from '../../helpers/express-utils.js' +import { MIMETYPES, ROUTE_CACHE_LIFETIME, WEBSERVER } from '../../initializers/constants.js' import { asyncMiddleware, commonVideosFiltersValidator, @@ -15,8 +15,8 @@ import { feedsAccountOrChannelFiltersValidator, videosSortValidator, videoSubscriptionFeedsValidator -} from '../../middlewares' -import { buildFeedMetadata, getCommonVideoFeedAttributes, getVideosForFeeds, initFeed, sendFeed } from './shared' +} from '../../middlewares/index.js' +import { buildFeedMetadata, getCommonVideoFeedAttributes, getVideosForFeeds, initFeed, sendFeed } from './shared/index.js' const videoFeedsRouter = express.Router() diff --git a/server/controllers/feeds/video-podcast-feeds.ts b/server/server/controllers/feeds/video-podcast-feeds.ts similarity index 93% rename from server/controllers/feeds/video-podcast-feeds.ts rename to server/server/controllers/feeds/video-podcast-feeds.ts index fca82ba68..84d5acadd 100644 --- a/server/controllers/feeds/video-podcast-feeds.ts +++ b/server/server/controllers/feeds/video-podcast-feeds.ts @@ -1,20 +1,20 @@ import express from 'express' import { extname } from 'path' import { Feed } from '@peertube/feed' -import { CustomTag, CustomXMLNS, LiveItemStatus } from '@peertube/feed/lib/typings' -import { getBiggestActorImage } from '@server/lib/actor-image' -import { InternalEventEmitter } from '@server/lib/internal-event-emitter' -import { Hooks } from '@server/lib/plugins/hooks' -import { buildPodcastGroupsCache, cacheRouteFactory, videoFeedsPodcastSetCacheKey } from '@server/middlewares' -import { MVideo, MVideoCaptionVideo, MVideoFullLight } from '@server/types/models' -import { sortObjectComparator } from '@shared/core-utils' -import { ActorImageType, VideoFile, VideoInclude, VideoResolution, VideoState } from '@shared/models' -import { buildNSFWFilter } from '../../helpers/express-utils' -import { MIMETYPES, ROUTE_CACHE_LIFETIME, WEBSERVER } from '../../initializers/constants' -import { asyncMiddleware, setFeedPodcastContentType, videoFeedsPodcastValidator } from '../../middlewares' -import { VideoModel } from '../../models/video/video' -import { VideoCaptionModel } from '../../models/video/video-caption' -import { buildFeedMetadata, getCommonVideoFeedAttributes, getVideosForFeeds, initFeed } from './shared' +import { CustomTag, CustomXMLNS, LiveItemStatus } from '@peertube/feed/lib/typings/index.js' +import { getBiggestActorImage } from '@server/lib/actor-image.js' +import { InternalEventEmitter } from '@server/lib/internal-event-emitter.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { buildPodcastGroupsCache, cacheRouteFactory, videoFeedsPodcastSetCacheKey } from '@server/middlewares/index.js' +import { MVideo, MVideoCaptionVideo, MVideoFullLight } from '@server/types/models/index.js' +import { sortObjectComparator } from '@peertube/peertube-core-utils' +import { ActorImageType, VideoFile, VideoInclude, VideoResolution, VideoState } from '@peertube/peertube-models' +import { buildNSFWFilter } from '../../helpers/express-utils.js' +import { MIMETYPES, ROUTE_CACHE_LIFETIME, WEBSERVER } from '../../initializers/constants.js' +import { asyncMiddleware, setFeedPodcastContentType, videoFeedsPodcastValidator } from '../../middlewares/index.js' +import { VideoModel } from '../../models/video/video.js' +import { VideoCaptionModel } from '../../models/video/video-caption.js' +import { buildFeedMetadata, getCommonVideoFeedAttributes, getVideosForFeeds, initFeed } from './shared/index.js' const videoPodcastFeedsRouter = express.Router() diff --git a/server/server/controllers/index.ts b/server/server/controllers/index.ts new file mode 100644 index 000000000..db326c486 --- /dev/null +++ b/server/server/controllers/index.ts @@ -0,0 +1,14 @@ +export * from './activitypub/index.js' +export * from './api/index.js' +export * from './sitemap.js' +export * from './client.js' +export * from './download.js' +export * from './feeds/index.js' +export * from './lazy-static.js' +export * from './misc.js' +export * from './object-storage-proxy.js' +export * from './plugins.js' +export * from './services.js' +export * from './static.js' +export * from './tracker.js' +export * from './well-known.js' diff --git a/server/controllers/lazy-static.ts b/server/server/controllers/lazy-static.ts similarity index 95% rename from server/controllers/lazy-static.ts rename to server/server/controllers/lazy-static.ts index dad30365c..69aa549a7 100644 --- a/server/controllers/lazy-static.ts +++ b/server/server/controllers/lazy-static.ts @@ -1,8 +1,8 @@ import cors from 'cors' import express from 'express' -import { CONFIG } from '@server/initializers/config' -import { HttpStatusCode } from '../../shared/models/http/http-error-codes' -import { FILES_CACHE, LAZY_STATIC_PATHS, STATIC_MAX_AGE } from '../initializers/constants' +import { HttpStatusCode } from '@peertube/peertube-models' +import { CONFIG } from '@server/initializers/config.js' +import { FILES_CACHE, LAZY_STATIC_PATHS, STATIC_MAX_AGE } from '../initializers/constants.js' import { AvatarPermanentFileCache, VideoCaptionsSimpleFileCache, @@ -10,8 +10,8 @@ import { VideoPreviewsSimpleFileCache, VideoStoryboardsSimpleFileCache, VideoTorrentsSimpleFileCache -} from '../lib/files-cache' -import { asyncMiddleware, handleStaticError } from '../middlewares' +} from '../lib/files-cache/index.js' +import { asyncMiddleware, handleStaticError } from '../middlewares/index.js' // --------------------------------------------------------------------------- // Cache initializations diff --git a/server/controllers/misc.ts b/server/server/controllers/misc.ts similarity index 90% rename from server/controllers/misc.ts rename to server/server/controllers/misc.ts index a7dfc7867..cf204e965 100644 --- a/server/controllers/misc.ts +++ b/server/server/controllers/misc.ts @@ -1,17 +1,16 @@ import cors from 'cors' import express from 'express' -import { CONFIG, isEmailEnabled } from '@server/initializers/config' -import { serveIndexHTML } from '@server/lib/client-html' -import { ServerConfigManager } from '@server/lib/server-config-manager' -import { HttpStatusCode } from '@shared/models' -import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/nodeinfo/nodeinfo.model' -import { CONSTRAINTS_FIELDS, DEFAULT_THEME_NAME, PEERTUBE_VERSION, ROUTE_CACHE_LIFETIME } from '../initializers/constants' -import { getThemeOrDefault } from '../lib/plugins/theme-utils' -import { apiRateLimiter, asyncMiddleware } from '../middlewares' -import { cacheRoute } from '../middlewares/cache/cache' -import { UserModel } from '../models/user/user' -import { VideoModel } from '../models/video/video' -import { VideoCommentModel } from '../models/video/video-comment' +import { HttpNodeinfoDiasporaSoftwareNsSchema20, HttpStatusCode } from '@peertube/peertube-models' +import { CONFIG, isEmailEnabled } from '@server/initializers/config.js' +import { serveIndexHTML } from '@server/lib/client-html.js' +import { ServerConfigManager } from '@server/lib/server-config-manager.js' +import { CONSTRAINTS_FIELDS, DEFAULT_THEME_NAME, PEERTUBE_VERSION, ROUTE_CACHE_LIFETIME } from '../initializers/constants.js' +import { getThemeOrDefault } from '../lib/plugins/theme-utils.js' +import { cacheRoute } from '../middlewares/cache/cache.js' +import { apiRateLimiter, asyncMiddleware } from '../middlewares/index.js' +import { UserModel } from '../models/user/user.js' +import { VideoCommentModel } from '../models/video/video-comment.js' +import { VideoModel } from '../models/video/video.js' const miscRouter = express.Router() diff --git a/server/controllers/object-storage-proxy.ts b/server/server/controllers/object-storage-proxy.ts similarity index 95% rename from server/controllers/object-storage-proxy.ts rename to server/server/controllers/object-storage-proxy.ts index d0c59bf93..957f46198 100644 --- a/server/controllers/object-storage-proxy.ts +++ b/server/server/controllers/object-storage-proxy.ts @@ -1,15 +1,15 @@ import cors from 'cors' import express from 'express' -import { OBJECT_STORAGE_PROXY_PATHS } from '@server/initializers/constants' -import { proxifyHLS, proxifyWebVideoFile } from '@server/lib/object-storage' +import { OBJECT_STORAGE_PROXY_PATHS } from '@server/initializers/constants.js' +import { proxifyHLS, proxifyWebVideoFile } from '@server/lib/object-storage/index.js' import { asyncMiddleware, ensureCanAccessPrivateVideoHLSFiles, ensureCanAccessVideoPrivateWebVideoFiles, ensurePrivateObjectStorageProxyIsEnabled, optionalAuthenticate -} from '@server/middlewares' -import { doReinjectVideoFileToken } from './shared/m3u8-playlist' +} from '@server/middlewares/index.js' +import { doReinjectVideoFileToken } from './shared/m3u8-playlist.js' const objectStorageProxyRouter = express.Router() diff --git a/server/controllers/plugins.ts b/server/server/controllers/plugins.ts similarity index 89% rename from server/controllers/plugins.ts rename to server/server/controllers/plugins.ts index f0491b16a..1bcecce0e 100644 --- a/server/controllers/plugins.ts +++ b/server/server/controllers/plugins.ts @@ -1,17 +1,16 @@ import express from 'express' import { join } from 'path' -import { logger } from '@server/helpers/logger' -import { CONFIG } from '@server/initializers/config' -import { buildRateLimiter } from '@server/middlewares' -import { optionalAuthenticate } from '@server/middlewares/auth' -import { getCompleteLocale, is18nLocale } from '../../shared/core-utils/i18n' -import { HttpStatusCode } from '../../shared/models/http/http-error-codes' -import { PluginType } from '../../shared/models/plugins/plugin.type' -import { isProdInstance } from '../helpers/core-utils' -import { PLUGIN_GLOBAL_CSS_PATH } from '../initializers/constants' -import { PluginManager, RegisteredPlugin } from '../lib/plugins/plugin-manager' -import { getExternalAuthValidator, getPluginValidator, pluginStaticDirectoryValidator } from '../middlewares/validators/plugins' -import { serveThemeCSSValidator } from '../middlewares/validators/themes' +import { getCompleteLocale, is18nLocale } from '@peertube/peertube-core-utils' +import { HttpStatusCode, PluginType } from '@peertube/peertube-models' +import { isProdInstance } from '@peertube/peertube-node-utils' +import { logger } from '@server/helpers/logger.js' +import { CONFIG } from '@server/initializers/config.js' +import { optionalAuthenticate } from '@server/middlewares/auth.js' +import { buildRateLimiter } from '@server/middlewares/index.js' +import { PLUGIN_GLOBAL_CSS_PATH } from '../initializers/constants.js' +import { PluginManager, RegisteredPlugin } from '../lib/plugins/plugin-manager.js' +import { getExternalAuthValidator, getPluginValidator, pluginStaticDirectoryValidator } from '../middlewares/validators/plugins.js' +import { serveThemeCSSValidator } from '../middlewares/validators/themes.js' const sendFileOptions = { maxAge: '30 days', diff --git a/server/controllers/services.ts b/server/server/controllers/services.ts similarity index 94% rename from server/controllers/services.ts rename to server/server/controllers/services.ts index 0fd63a30f..b59f0f337 100644 --- a/server/controllers/services.ts +++ b/server/server/controllers/services.ts @@ -1,10 +1,9 @@ import express from 'express' -import { MChannelSummary } from '@server/types/models' -import { escapeHTML } from '@shared/core-utils/renderer' -import { EMBED_SIZE, PREVIEWS_SIZE, THUMBNAILS_SIZE, WEBSERVER } from '../initializers/constants' -import { apiRateLimiter, asyncMiddleware, oembedValidator } from '../middlewares' -import { accountNameWithHostGetValidator } from '../middlewares/validators' -import { forceNumber } from '@shared/core-utils' +import { escapeHTML, forceNumber } from '@peertube/peertube-core-utils' +import { MChannelSummary } from '@server/types/models/index.js' +import { EMBED_SIZE, PREVIEWS_SIZE, THUMBNAILS_SIZE, WEBSERVER } from '../initializers/constants.js' +import { apiRateLimiter, asyncMiddleware, oembedValidator } from '../middlewares/index.js' +import { accountNameWithHostGetValidator } from '../middlewares/validators/index.js' const servicesRouter = express.Router() diff --git a/server/controllers/shared/m3u8-playlist.ts b/server/server/controllers/shared/m3u8-playlist.ts similarity index 100% rename from server/controllers/shared/m3u8-playlist.ts rename to server/server/controllers/shared/m3u8-playlist.ts diff --git a/server/controllers/sitemap.ts b/server/server/controllers/sitemap.ts similarity index 87% rename from server/controllers/sitemap.ts rename to server/server/controllers/sitemap.ts index 07f4c554e..69aea6167 100644 --- a/server/controllers/sitemap.ts +++ b/server/server/controllers/sitemap.ts @@ -1,15 +1,15 @@ import express from 'express' -import { truncate } from 'lodash' +import truncate from 'lodash-es/truncate.js' import { ErrorLevel, SitemapStream, streamToPromise } from 'sitemap' -import { logger } from '@server/helpers/logger' -import { getServerActor } from '@server/models/application/application' -import { buildNSFWFilter } from '../helpers/express-utils' -import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' -import { apiRateLimiter, asyncMiddleware } from '../middlewares' -import { cacheRoute } from '../middlewares/cache/cache' -import { AccountModel } from '../models/account/account' -import { VideoModel } from '../models/video/video' -import { VideoChannelModel } from '../models/video/video-channel' +import { logger } from '@server/helpers/logger.js' +import { getServerActor } from '@server/models/application/application.js' +import { buildNSFWFilter } from '../helpers/express-utils.js' +import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants.js' +import { apiRateLimiter, asyncMiddleware } from '../middlewares/index.js' +import { cacheRoute } from '../middlewares/cache/cache.js' +import { AccountModel } from '../models/account/account.js' +import { VideoModel } from '../models/video/video.js' +import { VideoChannelModel } from '../models/video/video-channel.js' const sitemapRouter = express.Router() diff --git a/server/controllers/static.ts b/server/server/controllers/static.ts similarity index 92% rename from server/controllers/static.ts rename to server/server/controllers/static.ts index 97caa8292..06807a9d5 100644 --- a/server/controllers/static.ts +++ b/server/server/controllers/static.ts @@ -1,19 +1,19 @@ import cors from 'cors' import express from 'express' -import { readFile } from 'fs-extra' +import { readFile } from 'fs/promises' import { join } from 'path' -import { injectQueryToPlaylistUrls } from '@server/lib/hls' +import { injectQueryToPlaylistUrls } from '@server/lib/hls.js' import { asyncMiddleware, ensureCanAccessPrivateVideoHLSFiles, ensureCanAccessVideoPrivateWebVideoFiles, handleStaticError, optionalAuthenticate -} from '@server/middlewares' -import { HttpStatusCode } from '@shared/models' -import { CONFIG } from '../initializers/config' -import { DIRECTORIES, STATIC_MAX_AGE, STATIC_PATHS } from '../initializers/constants' -import { buildReinjectVideoFileTokenQuery, doReinjectVideoFileToken } from './shared/m3u8-playlist' +} from '@server/middlewares/index.js' +import { HttpStatusCode } from '@peertube/peertube-models' +import { CONFIG } from '../initializers/config.js' +import { DIRECTORIES, STATIC_MAX_AGE, STATIC_PATHS } from '../initializers/constants.js' +import { buildReinjectVideoFileTokenQuery, doReinjectVideoFileToken } from './shared/m3u8-playlist.js' const staticRouter = express.Router() diff --git a/server/controllers/tracker.ts b/server/server/controllers/tracker.ts similarity index 95% rename from server/controllers/tracker.ts rename to server/server/controllers/tracker.ts index 9a8aa88bc..e8d29f976 100644 --- a/server/controllers/tracker.ts +++ b/server/server/controllers/tracker.ts @@ -4,11 +4,11 @@ import { createServer } from 'http' import { LRUCache } from 'lru-cache' import proxyAddr from 'proxy-addr' import { WebSocketServer } from 'ws' -import { logger } from '../helpers/logger' -import { CONFIG } from '../initializers/config' -import { LRU_CACHE, TRACKER_RATE_LIMITS } from '../initializers/constants' -import { VideoFileModel } from '../models/video/video-file' -import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' +import { logger } from '../helpers/logger.js' +import { CONFIG } from '../initializers/config.js' +import { LRU_CACHE, TRACKER_RATE_LIMITS } from '../initializers/constants.js' +import { VideoFileModel } from '../models/video/video-file.js' +import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist.js' const trackerRouter = express.Router() diff --git a/server/controllers/well-known.ts b/server/server/controllers/well-known.ts similarity index 93% rename from server/controllers/well-known.ts rename to server/server/controllers/well-known.ts index 322cf6ea2..b6bcd79ef 100644 --- a/server/controllers/well-known.ts +++ b/server/server/controllers/well-known.ts @@ -1,11 +1,11 @@ import cors from 'cors' import express from 'express' import { join } from 'path' -import { asyncMiddleware, buildRateLimiter, handleStaticError, webfingerValidator } from '@server/middlewares' -import { root } from '@shared/core-utils' -import { CONFIG } from '../initializers/config' -import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' -import { cacheRoute } from '../middlewares/cache/cache' +import { asyncMiddleware, buildRateLimiter, handleStaticError, webfingerValidator } from '@server/middlewares/index.js' +import { root } from '@peertube/peertube-node-utils' +import { CONFIG } from '../initializers/config.js' +import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants.js' +import { cacheRoute } from '../middlewares/cache/cache.js' const wellKnownRouter = express.Router() diff --git a/server/lib/activitypub/context.ts b/server/server/helpers/activity-pub-utils.ts similarity index 78% rename from server/lib/activitypub/context.ts rename to server/server/helpers/activity-pub-utils.ts index 87eb498a3..acc5c304b 100644 --- a/server/lib/activitypub/context.ts +++ b/server/server/helpers/activity-pub-utils.ts @@ -1,17 +1,36 @@ -import { ContextType } from '@shared/models' -import { Hooks } from '../plugins/hooks' +import { ContextType } from '@peertube/peertube-models' +import { ACTIVITY_PUB } from '@server/initializers/constants.js' +import { buildDigest, signJsonLDObject } from './peertube-crypto.js' -async function activityPubContextify (data: T, type: ContextType) { - return { ...await getContextData(type), ...data } +type ContextFilter = (arg: T) => Promise + +export function buildGlobalHTTPHeaders (body: any) { + return { + 'digest': buildDigest(body), + 'content-type': 'application/activity+json', + 'accept': ACTIVITY_PUB.ACCEPT_HEADER + } +} + +export async function activityPubContextify (data: T, type: ContextType, contextFilter: ContextFilter) { + return { ...await getContextData(type, contextFilter), ...data } +} + +export async function signAndContextify ( + byActor: { url: string, privateKey: string }, + data: T, + contextType: ContextType | null, + contextFilter: ContextFilter +) { + const activity = contextType + ? await activityPubContextify(data, contextType, contextFilter) + : data + + return signJsonLDObject(byActor, activity) } // --------------------------------------------------------------------------- - -export { - getContextData, - activityPubContextify -} - +// Private // --------------------------------------------------------------------------- type ContextValue = { [ id: string ]: (string | { '@type': string, '@id': string }) } @@ -179,11 +198,10 @@ const contextStore: { [ id in ContextType ]: (string | { [ id: string ]: string Rate: buildContext() } -async function getContextData (type: ContextType) { - const contextData = await Hooks.wrapObject( - contextStore[type], - 'filter:activity-pub.activity.context.build.result' - ) +async function getContextData (type: ContextType, contextFilter: ContextFilter) { + const contextData = contextFilter + ? await contextFilter(contextStore[type]) + : contextStore[type] return { '@context': contextData } } diff --git a/server/helpers/actors.ts b/server/server/helpers/actors.ts similarity index 84% rename from server/helpers/actors.ts rename to server/server/helpers/actors.ts index c31fe6f8e..5be5c9ee7 100644 --- a/server/helpers/actors.ts +++ b/server/server/helpers/actors.ts @@ -1,4 +1,4 @@ -import { WEBSERVER } from '@server/initializers/constants' +import { WEBSERVER } from '@server/initializers/constants.js' function handleToNameAndHost (handle: string) { let [ name, host ] = handle.split('@') diff --git a/server/helpers/audit-logger.ts b/server/server/helpers/audit-logger.ts similarity index 86% rename from server/helpers/audit-logger.ts rename to server/server/helpers/audit-logger.ts index 7e8a03e8f..bf79ced01 100644 --- a/server/helpers/audit-logger.ts +++ b/server/server/helpers/audit-logger.ts @@ -1,13 +1,21 @@ +import { + AdminAbuse, + CustomConfig, + User, + VideoChannel, + VideoChannelSync, + VideoComment, + VideoDetails, + VideoImport +} from '@peertube/peertube-models' +import { AUDIT_LOG_FILENAME } from '@server/initializers/constants.js' import { diff } from 'deep-object-diff' import express from 'express' import flatten from 'flat' -import { chain } from 'lodash' import { join } from 'path' import { addColors, config, createLogger, format, transports } from 'winston' -import { AUDIT_LOG_FILENAME } from '@server/initializers/constants' -import { AdminAbuse, CustomConfig, User, VideoChannel, VideoChannelSync, VideoComment, VideoDetails, VideoImport } from '@shared/models' -import { CONFIG } from '../initializers/config' -import { jsonLoggerFormat, labelFormatter } from './logger' +import { CONFIG } from '../initializers/config.js' +import { jsonLoggerFormat, labelFormatter } from './logger.js' function getAuditIdFromRes (res: express.Response) { return res.locals.oauth.token.User.username @@ -45,6 +53,7 @@ const auditLogger = createLogger({ function auditLoggerWrapper (domain: string, user: string, action: AUDIT_TYPE, entity: EntityAuditView, oldEntity: EntityAuditView = null) { let entityInfos: object + if (action === AUDIT_TYPE.UPDATE && oldEntity) { const oldEntityKeys = oldEntity.toLogKeys() const diffObject = diff(oldEntityKeys, entity.toLogKeys()) @@ -56,6 +65,7 @@ function auditLoggerWrapper (domain: string, user: string, action: AUDIT_TYPE, e } else { entityInfos = { ...entity.toLogKeys() } } + auditLogger.log('audit', JSON.stringify({ user, domain, @@ -79,17 +89,18 @@ function auditLoggerFactory (domain: string) { } abstract class EntityAuditView { - constructor (private readonly keysToKeep: string[], private readonly prefix: string, private readonly entityInfos: object) { } + constructor (private readonly keysToKeep: Set, private readonly prefix: string, private readonly entityInfos: object) { } toLogKeys (): object { - return chain(flatten(this.entityInfos, { delimiter: '-', safe: true })) - .pick(this.keysToKeep) - .mapKeys((_value, key) => `${this.prefix}-${key}`) - .value() + const obj = flatten(this.entityInfos, { delimiter: '-', safe: true }) + + return Object.keys(obj) + .filter(key => this.keysToKeep.has(key)) + .reduce((p, k) => ({ ...p, [`${this.prefix}-${k}`]: obj[k] }), {}) } } -const videoKeysToKeep = [ +const videoKeysToKeep = new Set([ 'tags', 'uuid', 'id', @@ -118,25 +129,25 @@ const videoKeysToKeep = [ 'support', 'commentsEnabled', 'downloadEnabled' -] +]) class VideoAuditView extends EntityAuditView { constructor (video: VideoDetails) { super(videoKeysToKeep, 'video', video) } } -const videoImportKeysToKeep = [ +const videoImportKeysToKeep = new Set([ 'id', 'targetUrl', 'video-name' -] +]) class VideoImportAuditView extends EntityAuditView { constructor (videoImport: VideoImport) { super(videoImportKeysToKeep, 'video-import', videoImport) } } -const commentKeysToKeep = [ +const commentKeysToKeep = new Set([ 'id', 'text', 'threadId', @@ -148,14 +159,14 @@ const commentKeysToKeep = [ 'account-id', 'account-uuid', 'account-name' -] +]) class CommentAuditView extends EntityAuditView { constructor (comment: VideoComment) { super(commentKeysToKeep, 'comment', comment) } } -const userKeysToKeep = [ +const userKeysToKeep = new Set([ 'id', 'username', 'email', @@ -177,14 +188,14 @@ const userKeysToKeep = [ 'account-displayName', 'account-description', 'videoChannels' -] +]) class UserAuditView extends EntityAuditView { constructor (user: User) { super(userKeysToKeep, 'user', user) } } -const channelKeysToKeep = [ +const channelKeysToKeep = new Set([ 'id', 'uuid', 'name', @@ -203,26 +214,26 @@ const channelKeysToKeep = [ 'ownerAccount-uuid', 'ownerAccount-name', 'ownerAccount-displayedName' -] +]) class VideoChannelAuditView extends EntityAuditView { constructor (channel: VideoChannel) { super(channelKeysToKeep, 'channel', channel) } } -const abuseKeysToKeep = [ +const abuseKeysToKeep = new Set([ 'id', 'reason', 'reporterAccount', 'createdAt' -] +]) class AbuseAuditView extends EntityAuditView { constructor (abuse: AdminAbuse) { super(abuseKeysToKeep, 'abuse', abuse) } } -const customConfigKeysToKeep = [ +const customConfigKeysToKeep = new Set([ 'instance-name', 'instance-shortDescription', 'instance-description', @@ -243,7 +254,7 @@ const customConfigKeysToKeep = [ 'transcoding-enabled', 'transcoding-threads', 'transcoding-resolutions' -] +]) class CustomConfigAuditView extends EntityAuditView { constructor (customConfig: CustomConfig) { const infos: any = customConfig @@ -260,12 +271,12 @@ class CustomConfigAuditView extends EntityAuditView { } } -const channelSyncKeysToKeep = [ +const channelSyncKeysToKeep = new Set([ 'id', 'externalChannelUrl', 'channel-id', 'channel-name' -] +]) class VideoChannelSyncAuditView extends EntityAuditView { constructor (channelSync: VideoChannelSync) { super(channelSyncKeysToKeep, 'channelSync', channelSync) diff --git a/server/helpers/captions-utils.ts b/server/server/helpers/captions-utils.ts similarity index 78% rename from server/helpers/captions-utils.ts rename to server/server/helpers/captions-utils.ts index f6e5b9784..f165cb447 100644 --- a/server/helpers/captions-utils.ts +++ b/server/server/helpers/captions-utils.ts @@ -1,10 +1,10 @@ -import { createReadStream, createWriteStream, move, remove } from 'fs-extra' +import { createReadStream, createWriteStream } from 'fs' +import { move, remove } from 'fs-extra/esm' import { join } from 'path' -import srt2vtt from 'srt-to-vtt' import { Transform } from 'stream' -import { MVideoCaption } from '@server/types/models' -import { CONFIG } from '../initializers/config' -import { pipelinePromise } from './core-utils' +import { MVideoCaption } from '@server/types/models/index.js' +import { CONFIG } from '../initializers/config.js' +import { pipelinePromise } from './core-utils.js' async function moveAndProcessCaptionFile (physicalFile: { filename: string, path: string }, videoCaption: MVideoCaption) { const videoCaptionsDir = CONFIG.STORAGE.CAPTIONS_DIR @@ -31,7 +31,7 @@ export { // --------------------------------------------------------------------------- -function convertSrtToVtt (source: string, destination: string) { +async function convertSrtToVtt (source: string, destination: string) { const fixVTT = new Transform({ transform: (chunk, _encoding, cb) => { let block: string = chunk.toString() @@ -44,9 +44,11 @@ function convertSrtToVtt (source: string, destination: string) { } }) + const srt2vtt = await import('srt-to-vtt') + return pipelinePromise( createReadStream(source), - srt2vtt(), + srt2vtt.default(), fixVTT, createWriteStream(destination) ) diff --git a/server/helpers/core-utils.ts b/server/server/helpers/core-utils.ts similarity index 92% rename from server/helpers/core-utils.ts rename to server/server/helpers/core-utils.ts index 242c49e89..6dc09d317 100644 --- a/server/helpers/core-utils.ts +++ b/server/server/helpers/core-utils.ts @@ -5,13 +5,13 @@ Useful to avoid circular dependencies. */ +import { promisify1, promisify2, promisify3 } from '@peertube/peertube-core-utils' import { exec, ExecOptions } from 'child_process' import { ED25519KeyPairOptions, generateKeyPair, randomBytes, RSAKeyPairOptions, scrypt } from 'crypto' -import { truncate } from 'lodash' +import truncate from 'lodash-es/truncate.js' import { pipeline } from 'stream' import { URL } from 'url' import { promisify } from 'util' -import { promisify1, promisify2, promisify3 } from '@shared/core-utils' const objectConverter = (oldObject: any, keyConverter: (e: string) => string, valueConverter: (e: any) => any) => { if (!oldObject || typeof oldObject !== 'object') { @@ -161,28 +161,6 @@ function sanitizeHost (host: string, remoteScheme: string) { // --------------------------------------------------------------------------- -function isTestInstance () { - return process.env.NODE_ENV === 'test' -} - -function isDevInstance () { - return process.env.NODE_ENV === 'dev' -} - -function isTestOrDevInstance () { - return isTestInstance() || isDevInstance() -} - -function isProdInstance () { - return process.env.NODE_ENV === 'production' -} - -function getAppNumber () { - return process.env.NODE_APP_INSTANCE || '' -} - -// --------------------------------------------------------------------------- - // Consistent with .length, lodash truncate function is not function peertubeTruncate (str: string, options: { length: number, separator?: RegExp, omission?: string }) { const truncatedStr = truncate(str, options) @@ -284,11 +262,6 @@ const pipelinePromise = promisify(pipeline) // --------------------------------------------------------------------------- export { - isTestInstance, - isTestOrDevInstance, - isProdInstance, - getAppNumber, - objectConverter, mapToJSON, diff --git a/server/helpers/custom-jsonld-signature.ts b/server/server/helpers/custom-jsonld-signature.ts similarity index 93% rename from server/helpers/custom-jsonld-signature.ts rename to server/server/helpers/custom-jsonld-signature.ts index 3c706e372..0bbe682da 100644 --- a/server/helpers/custom-jsonld-signature.ts +++ b/server/server/helpers/custom-jsonld-signature.ts @@ -1,7 +1,6 @@ import AsyncLRU from 'async-lru' -import { logger } from './logger' - -import jsonld = require('jsonld') +import jsonld from 'jsonld' +import { logger } from './logger.js' const CACHE = { 'https://w3id.org/security/v1': { @@ -56,7 +55,7 @@ const CACHE = { } } -const nodeDocumentLoader = jsonld.documentLoaders.node() +const nodeDocumentLoader = (jsonld as any).documentLoaders.node() const lru = new AsyncLRU({ max: 10, @@ -75,10 +74,10 @@ const lru = new AsyncLRU({ .then(value => cb(null, value)) .catch(err => cb(err)) } -}) +}); /* eslint-disable no-import-assign */ -jsonld.documentLoader = (url) => { +(jsonld as any).documentLoader = (url) => { return new Promise((res, rej) => { lru.get(url, (err, value) => { if (err) return rej(err) diff --git a/server/helpers/custom-validators/abuses.ts b/server/server/helpers/custom-validators/abuses.ts similarity index 74% rename from server/helpers/custom-validators/abuses.ts rename to server/server/helpers/custom-validators/abuses.ts index 94719641a..4c4ae8bf7 100644 --- a/server/helpers/custom-validators/abuses.ts +++ b/server/server/helpers/custom-validators/abuses.ts @@ -1,14 +1,14 @@ import validator from 'validator' -import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' -import { AbuseCreate, AbuseFilter, AbusePredefinedReasonsString, AbuseVideoIs } from '@shared/models' -import { ABUSE_STATES, CONSTRAINTS_FIELDS } from '../../initializers/constants' -import { exists, isArray } from './misc' +import { abusePredefinedReasonsMap } from '@peertube/peertube-core-utils' +import { AbuseCreate, AbuseFilter, AbusePredefinedReasonsString, AbuseVideoIs } from '@peertube/peertube-models' +import { ABUSE_STATES, CONSTRAINTS_FIELDS } from '../../initializers/constants.js' +import { exists, isArray } from './misc.js' const ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.ABUSES const ABUSE_MESSAGES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.ABUSE_MESSAGES function isAbuseReasonValid (value: string) { - return exists(value) && validator.isLength(value, ABUSES_CONSTRAINTS_FIELDS.REASON) + return exists(value) && validator.default.isLength(value, ABUSES_CONSTRAINTS_FIELDS.REASON) } function isAbusePredefinedReasonValid (value: AbusePredefinedReasonsString) { @@ -24,7 +24,7 @@ function areAbusePredefinedReasonsValid (value: AbusePredefinedReasonsString[]) } function isAbuseTimestampValid (value: number) { - return value === null || (exists(value) && validator.isInt('' + value, { min: 0 })) + return value === null || (exists(value) && validator.default.isInt('' + value, { min: 0 })) } function isAbuseTimestampCoherent (endAt: number, { req }) { @@ -34,7 +34,7 @@ function isAbuseTimestampCoherent (endAt: number, { req }) { } function isAbuseModerationCommentValid (value: string) { - return exists(value) && validator.isLength(value, ABUSES_CONSTRAINTS_FIELDS.MODERATION_COMMENT) + return exists(value) && validator.default.isLength(value, ABUSES_CONSTRAINTS_FIELDS.MODERATION_COMMENT) } function isAbuseStateValid (value: string) { @@ -49,7 +49,7 @@ function isAbuseVideoIsValid (value: AbuseVideoIs) { } function isAbuseMessageValid (value: string) { - return exists(value) && validator.isLength(value, ABUSE_MESSAGES_CONSTRAINTS_FIELDS.MESSAGE) + return exists(value) && validator.default.isLength(value, ABUSE_MESSAGES_CONSTRAINTS_FIELDS.MESSAGE) } // --------------------------------------------------------------------------- diff --git a/server/helpers/custom-validators/accounts.ts b/server/server/helpers/custom-validators/accounts.ts similarity index 91% rename from server/helpers/custom-validators/accounts.ts rename to server/server/helpers/custom-validators/accounts.ts index f676669ea..48fa1594e 100644 --- a/server/helpers/custom-validators/accounts.ts +++ b/server/server/helpers/custom-validators/accounts.ts @@ -1,5 +1,5 @@ -import { isUserDescriptionValid, isUserUsernameValid } from './users' -import { exists } from './misc' +import { isUserDescriptionValid, isUserUsernameValid } from './users.js' +import { exists } from './misc.js' function isAccountNameValid (value: string) { return isUserUsernameValid(value) diff --git a/server/helpers/custom-validators/activitypub/activity.ts b/server/server/helpers/custom-validators/activitypub/activity.ts similarity index 88% rename from server/helpers/custom-validators/activitypub/activity.ts rename to server/server/helpers/custom-validators/activitypub/activity.ts index 90a918523..05399ebdf 100644 --- a/server/helpers/custom-validators/activitypub/activity.ts +++ b/server/server/helpers/custom-validators/activitypub/activity.ts @@ -1,14 +1,14 @@ import validator from 'validator' -import { Activity, ActivityType } from '../../../../shared/models/activitypub' -import { isAbuseReasonValid } from '../abuses' -import { exists } from '../misc' -import { sanitizeAndCheckActorObject } from './actor' -import { isCacheFileObjectValid } from './cache-file' -import { isActivityPubUrlValid, isBaseActivityValid, isObjectValid } from './misc' -import { isPlaylistObjectValid } from './playlist' -import { sanitizeAndCheckVideoCommentObject } from './video-comments' -import { sanitizeAndCheckVideoTorrentObject } from './videos' -import { isWatchActionObjectValid } from './watch-action' +import { Activity, ActivityType } from '@peertube/peertube-models' +import { isAbuseReasonValid } from '../abuses.js' +import { exists } from '../misc.js' +import { sanitizeAndCheckActorObject } from './actor.js' +import { isCacheFileObjectValid } from './cache-file.js' +import { isActivityPubUrlValid, isBaseActivityValid, isObjectValid } from './misc.js' +import { isPlaylistObjectValid } from './playlist.js' +import { sanitizeAndCheckVideoCommentObject } from './video-comments.js' +import { sanitizeAndCheckVideoTorrentObject } from './videos.js' +import { isWatchActionObjectValid } from './watch-action.js' function isRootActivityValid (activity: any) { return isCollection(activity) || isActivity(activity) @@ -16,7 +16,7 @@ function isRootActivityValid (activity: any) { function isCollection (activity: any) { return (activity.type === 'Collection' || activity.type === 'OrderedCollection') && - validator.isInt(activity.totalItems, { min: 0 }) && + validator.default.isInt(activity.totalItems, { min: 0 }) && Array.isArray(activity.items) } diff --git a/server/helpers/custom-validators/activitypub/actor.ts b/server/server/helpers/custom-validators/activitypub/actor.ts similarity index 87% rename from server/helpers/custom-validators/activitypub/actor.ts rename to server/server/helpers/custom-validators/activitypub/actor.ts index f43c35b23..71ddbc323 100644 --- a/server/helpers/custom-validators/activitypub/actor.ts +++ b/server/server/helpers/custom-validators/activitypub/actor.ts @@ -1,9 +1,9 @@ import validator from 'validator' -import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' -import { exists, isArray, isDateValid } from '../misc' -import { isActivityPubUrlValid, isBaseActivityValid, setValidAttributedTo } from './misc' -import { isHostValid } from '../servers' -import { peertubeTruncate } from '@server/helpers/core-utils' +import { CONSTRAINTS_FIELDS } from '../../../initializers/constants.js' +import { exists, isArray, isDateValid } from '../misc.js' +import { isActivityPubUrlValid, isBaseActivityValid, setValidAttributedTo } from './misc.js' +import { isHostValid } from '../servers.js' +import { peertubeTruncate } from '@server/helpers/core-utils.js' function isActorEndpointsObjectValid (endpointObject: any) { if (endpointObject?.sharedInbox) { @@ -29,13 +29,13 @@ function isActorPublicKeyValid (publicKey: string) { typeof publicKey === 'string' && publicKey.startsWith('-----BEGIN PUBLIC KEY-----') && publicKey.includes('-----END PUBLIC KEY-----') && - validator.isLength(publicKey, CONSTRAINTS_FIELDS.ACTORS.PUBLIC_KEY) + validator.default.isLength(publicKey, CONSTRAINTS_FIELDS.ACTORS.PUBLIC_KEY) } const actorNameAlphabet = '[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\\-_.:]' const actorNameRegExp = new RegExp(`^${actorNameAlphabet}+$`) function isActorPreferredUsernameValid (preferredUsername: string) { - return exists(preferredUsername) && validator.matches(preferredUsername, actorNameRegExp) + return exists(preferredUsername) && validator.default.matches(preferredUsername, actorNameRegExp) } function isActorPrivateKeyValid (privateKey: string) { @@ -44,15 +44,15 @@ function isActorPrivateKeyValid (privateKey: string) { (privateKey.startsWith('-----BEGIN RSA PRIVATE KEY-----') || privateKey.startsWith('-----BEGIN PRIVATE KEY-----')) && // Sometimes there is a \n at the end, so just assert the string contains the end mark (privateKey.includes('-----END RSA PRIVATE KEY-----') || privateKey.includes('-----END PRIVATE KEY-----')) && - validator.isLength(privateKey, CONSTRAINTS_FIELDS.ACTORS.PRIVATE_KEY) + validator.default.isLength(privateKey, CONSTRAINTS_FIELDS.ACTORS.PRIVATE_KEY) } function isActorFollowingCountValid (value: string) { - return exists(value) && validator.isInt('' + value, { min: 0 }) + return exists(value) && validator.default.isInt('' + value, { min: 0 }) } function isActorFollowersCountValid (value: string) { - return exists(value) && validator.isInt('' + value, { min: 0 }) + return exists(value) && validator.default.isInt('' + value, { min: 0 }) } function isActorDeleteActivityValid (activity: any) { diff --git a/server/helpers/custom-validators/activitypub/cache-file.ts b/server/server/helpers/custom-validators/activitypub/cache-file.ts similarity index 76% rename from server/helpers/custom-validators/activitypub/cache-file.ts rename to server/server/helpers/custom-validators/activitypub/cache-file.ts index c5b3b4d9f..2b1408eb7 100644 --- a/server/helpers/custom-validators/activitypub/cache-file.ts +++ b/server/server/helpers/custom-validators/activitypub/cache-file.ts @@ -1,7 +1,7 @@ -import { isActivityPubUrlValid } from './misc' -import { isRemoteVideoUrlValid } from './videos' -import { exists, isDateValid } from '../misc' -import { CacheFileObject } from '../../../../shared/models/activitypub/objects' +import { CacheFileObject } from '@peertube/peertube-models' +import { exists, isDateValid } from '../misc.js' +import { isActivityPubUrlValid } from './misc.js' +import { isRemoteVideoUrlValid } from './videos.js' function isCacheFileObjectValid (object: CacheFileObject) { return exists(object) && diff --git a/server/helpers/custom-validators/activitypub/misc.ts b/server/server/helpers/custom-validators/activitypub/misc.ts similarity index 87% rename from server/helpers/custom-validators/activitypub/misc.ts rename to server/server/helpers/custom-validators/activitypub/misc.ts index 7df47cf15..0daa824f6 100644 --- a/server/helpers/custom-validators/activitypub/misc.ts +++ b/server/server/helpers/custom-validators/activitypub/misc.ts @@ -1,7 +1,7 @@ import validator from 'validator' -import { CONFIG } from '@server/initializers/config' -import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' -import { exists } from '../misc' +import { CONFIG } from '@server/initializers/config.js' +import { CONSTRAINTS_FIELDS } from '../../../initializers/constants.js' +import { exists } from '../misc.js' function isUrlValid (url: string) { const isURLOptions = { @@ -17,11 +17,11 @@ function isUrlValid (url: string) { isURLOptions.require_tld = false } - return exists(url) && validator.isURL('' + url, isURLOptions) + return exists(url) && validator.default.isURL('' + url, isURLOptions) } function isActivityPubUrlValid (url: string) { - return isUrlValid(url) && validator.isLength('' + url, CONSTRAINTS_FIELDS.ACTORS.URL) + return isUrlValid(url) && validator.default.isLength('' + url, CONSTRAINTS_FIELDS.ACTORS.URL) } function isBaseActivityValid (activity: any, type: string) { diff --git a/server/helpers/custom-validators/activitypub/playlist.ts b/server/server/helpers/custom-validators/activitypub/playlist.ts similarity index 63% rename from server/helpers/custom-validators/activitypub/playlist.ts rename to server/server/helpers/custom-validators/activitypub/playlist.ts index 49bcadcfd..7c338992b 100644 --- a/server/helpers/custom-validators/activitypub/playlist.ts +++ b/server/server/helpers/custom-validators/activitypub/playlist.ts @@ -1,13 +1,13 @@ import validator from 'validator' -import { PlaylistElementObject, PlaylistObject } from '@shared/models' -import { exists, isDateValid, isUUIDValid } from '../misc' -import { isVideoPlaylistNameValid } from '../video-playlists' -import { isActivityPubUrlValid } from './misc' +import { PlaylistElementObject, PlaylistObject } from '@peertube/peertube-models' +import { exists, isDateValid, isUUIDValid } from '../misc.js' +import { isVideoPlaylistNameValid } from '../video-playlists.js' +import { isActivityPubUrlValid } from './misc.js' function isPlaylistObjectValid (object: PlaylistObject) { return exists(object) && object.type === 'Playlist' && - validator.isInt(object.totalItems + '') && + validator.default.isInt(object.totalItems + '') && isVideoPlaylistNameValid(object.name) && isUUIDValid(object.uuid) && isDateValid(object.published) && @@ -17,7 +17,7 @@ function isPlaylistObjectValid (object: PlaylistObject) { function isPlaylistElementObjectValid (object: PlaylistElementObject) { return exists(object) && object.type === 'PlaylistElement' && - validator.isInt(object.position + '') && + validator.default.isInt(object.position + '') && isActivityPubUrlValid(object.url) } diff --git a/server/helpers/custom-validators/activitypub/signature.ts b/server/server/helpers/custom-validators/activitypub/signature.ts similarity index 86% rename from server/helpers/custom-validators/activitypub/signature.ts rename to server/server/helpers/custom-validators/activitypub/signature.ts index cfb65361e..2ce67875d 100644 --- a/server/helpers/custom-validators/activitypub/signature.ts +++ b/server/server/helpers/custom-validators/activitypub/signature.ts @@ -1,5 +1,5 @@ -import { exists } from '../misc' -import { isActivityPubUrlValid } from './misc' +import { exists } from '../misc.js' +import { isActivityPubUrlValid } from './misc.js' function isSignatureTypeValid (signatureType: string) { return exists(signatureType) && signatureType === 'RsaSignature2017' diff --git a/server/helpers/custom-validators/activitypub/video-comments.ts b/server/server/helpers/custom-validators/activitypub/video-comments.ts similarity index 85% rename from server/helpers/custom-validators/activitypub/video-comments.ts rename to server/server/helpers/custom-validators/activitypub/video-comments.ts index ea852c491..a024476dc 100644 --- a/server/helpers/custom-validators/activitypub/video-comments.ts +++ b/server/server/helpers/custom-validators/activitypub/video-comments.ts @@ -1,7 +1,7 @@ import validator from 'validator' -import { ACTIVITY_PUB } from '../../../initializers/constants' -import { exists, isArray, isDateValid } from '../misc' -import { isActivityPubUrlValid } from './misc' +import { ACTIVITY_PUB } from '../../../initializers/constants.js' +import { exists, isArray, isDateValid } from '../misc.js' +import { isActivityPubUrlValid } from './misc.js' function sanitizeAndCheckVideoCommentObject (comment: any) { if (!comment) return false @@ -38,7 +38,7 @@ export { // --------------------------------------------------------------------------- function isCommentContentValid (content: any) { - return exists(content) && validator.isLength('' + content, { min: 1 }) + return exists(content) && validator.default.isLength('' + content, { min: 1 }) } function normalizeComment (comment: any) { diff --git a/server/helpers/custom-validators/activitypub/videos.ts b/server/server/helpers/custom-validators/activitypub/videos.ts similarity index 84% rename from server/helpers/custom-validators/activitypub/videos.ts rename to server/server/helpers/custom-validators/activitypub/videos.ts index 07e25b8ba..b7298c474 100644 --- a/server/helpers/custom-validators/activitypub/videos.ts +++ b/server/server/helpers/custom-validators/activitypub/videos.ts @@ -1,11 +1,17 @@ import validator from 'validator' -import { logger } from '@server/helpers/logger' -import { ActivityPubStoryboard, ActivityTrackerUrlObject, ActivityVideoFileMetadataUrlObject, VideoObject } from '@shared/models' -import { LiveVideoLatencyMode, VideoState } from '../../../../shared/models/videos' -import { ACTIVITY_PUB, CONSTRAINTS_FIELDS } from '../../../initializers/constants' -import { peertubeTruncate } from '../../core-utils' -import { isArray, isBooleanValid, isDateValid, isUUIDValid } from '../misc' -import { isLiveLatencyModeValid } from '../video-lives' +import { + ActivityPubStoryboard, + ActivityTrackerUrlObject, + ActivityVideoFileMetadataUrlObject, + LiveVideoLatencyMode, + VideoObject, + VideoState +} from '@peertube/peertube-models' +import { logger } from '@server/helpers/logger.js' +import { ACTIVITY_PUB, CONSTRAINTS_FIELDS } from '../../../initializers/constants.js' +import { peertubeTruncate } from '../../core-utils.js' +import { isArray, isBooleanValid, isDateValid, isUUIDValid } from '../misc.js' +import { isLiveLatencyModeValid } from '../video-lives.js' import { isVideoDescriptionValid, isVideoDurationValid, @@ -13,8 +19,8 @@ import { isVideoStateValid, isVideoTagValid, isVideoViewsValid -} from '../videos' -import { isActivityPubUrlValid, isActivityPubVideoDurationValid, isBaseActivityValid, setValidAttributedTo } from './misc' +} from '../videos.js' +import { isActivityPubUrlValid, isActivityPubVideoDurationValid, isBaseActivityValid, setValidAttributedTo } from './misc.js' function sanitizeAndCheckVideoTorrentUpdateActivity (activity: any) { return isBaseActivityValid(activity, 'Update') && @@ -87,21 +93,21 @@ function isRemoteVideoUrlValid (url: any) { ( ACTIVITY_PUB.URL_MIME_TYPES.VIDEO.includes(url.mediaType) && isActivityPubUrlValid(url.href) && - validator.isInt(url.height + '', { min: 0 }) && - validator.isInt(url.size + '', { min: 0 }) && - (!url.fps || validator.isInt(url.fps + '', { min: -1 })) + validator.default.isInt(url.height + '', { min: 0 }) && + validator.default.isInt(url.size + '', { min: 0 }) && + (!url.fps || validator.default.isInt(url.fps + '', { min: -1 })) ) || // Torrent link ( ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.includes(url.mediaType) && isActivityPubUrlValid(url.href) && - validator.isInt(url.height + '', { min: 0 }) + validator.default.isInt(url.height + '', { min: 0 }) ) || // Magnet link ( ACTIVITY_PUB.URL_MIME_TYPES.MAGNET.includes(url.mediaType) && - validator.isLength(url.href, { min: 5 }) && - validator.isInt(url.height + '', { min: 0 }) + validator.default.isLength(url.href, { min: 5 }) && + validator.default.isInt(url.height + '', { min: 0 }) ) || // HLS playlist link ( @@ -165,7 +171,7 @@ function setValidRemoteCaptions (video: any) { } function isRemoteNumberIdentifierValid (data: any) { - return validator.isInt(data.identifier, { min: 0 }) + return validator.default.isInt(data.identifier, { min: 0 }) } function isRemoteStringIdentifierValid (data: any) { @@ -184,8 +190,8 @@ function setValidRemoteIcon (video: any) { return icon.type === 'Image' && isActivityPubUrlValid(icon.url) && icon.mediaType === 'image/jpeg' && - validator.isInt(icon.width + '', { min: 0 }) && - validator.isInt(icon.height + '', { min: 0 }) + validator.default.isInt(icon.width + '', { min: 0 }) && + validator.default.isInt(icon.height + '', { min: 0 }) }) return video.icon.length !== 0 @@ -230,10 +236,10 @@ function isStorybordValid (preview: ActivityPubStoryboard) { preview.url = preview.url.filter(u => { return u.mediaType === 'image/jpeg' && isActivityPubUrlValid(u.href) && - validator.isInt(u.width + '', { min: 0 }) && - validator.isInt(u.height + '', { min: 0 }) && - validator.isInt(u.tileWidth + '', { min: 0 }) && - validator.isInt(u.tileHeight + '', { min: 0 }) && + validator.default.isInt(u.width + '', { min: 0 }) && + validator.default.isInt(u.height + '', { min: 0 }) && + validator.default.isInt(u.tileWidth + '', { min: 0 }) && + validator.default.isInt(u.tileHeight + '', { min: 0 }) && isActivityPubVideoDurationValid(u.tileDuration) }) diff --git a/server/helpers/custom-validators/activitypub/watch-action.ts b/server/server/helpers/custom-validators/activitypub/watch-action.ts similarity index 85% rename from server/helpers/custom-validators/activitypub/watch-action.ts rename to server/server/helpers/custom-validators/activitypub/watch-action.ts index b9ffa63f6..426aa3805 100644 --- a/server/helpers/custom-validators/activitypub/watch-action.ts +++ b/server/server/helpers/custom-validators/activitypub/watch-action.ts @@ -1,7 +1,7 @@ -import { WatchActionObject } from '@shared/models' -import { exists, isDateValid, isUUIDValid } from '../misc' -import { isVideoTimeValid } from '../video-view' -import { isActivityPubVideoDurationValid, isObjectValid } from './misc' +import { WatchActionObject } from '@peertube/peertube-models' +import { exists, isDateValid, isUUIDValid } from '../misc.js' +import { isVideoTimeValid } from '../video-view.js' +import { isActivityPubVideoDurationValid, isObjectValid } from './misc.js' function isWatchActionObjectValid (action: WatchActionObject) { return exists(action) && diff --git a/server/helpers/custom-validators/actor-images.ts b/server/server/helpers/custom-validators/actor-images.ts similarity index 93% rename from server/helpers/custom-validators/actor-images.ts rename to server/server/helpers/custom-validators/actor-images.ts index 89f5a2262..5d30003c5 100644 --- a/server/helpers/custom-validators/actor-images.ts +++ b/server/server/helpers/custom-validators/actor-images.ts @@ -1,7 +1,7 @@ import { UploadFilesForCheck } from 'express' -import { CONSTRAINTS_FIELDS } from '../../initializers/constants' -import { isFileValid } from './misc' +import { CONSTRAINTS_FIELDS } from '../../initializers/constants.js' +import { isFileValid } from './misc.js' const imageMimeTypes = CONSTRAINTS_FIELDS.ACTORS.IMAGE.EXTNAME .map(v => v.replace('.', '')) diff --git a/server/helpers/custom-validators/bulk.ts b/server/server/helpers/custom-validators/bulk.ts similarity index 100% rename from server/helpers/custom-validators/bulk.ts rename to server/server/helpers/custom-validators/bulk.ts diff --git a/server/helpers/custom-validators/feeds.ts b/server/server/helpers/custom-validators/feeds.ts similarity index 90% rename from server/helpers/custom-validators/feeds.ts rename to server/server/helpers/custom-validators/feeds.ts index fa35a7da6..c597b889f 100644 --- a/server/helpers/custom-validators/feeds.ts +++ b/server/server/helpers/custom-validators/feeds.ts @@ -1,4 +1,4 @@ -import { exists } from './misc' +import { exists } from './misc.js' function isValidRSSFeed (value: string) { if (!exists(value)) return false diff --git a/server/helpers/custom-validators/follows.ts b/server/server/helpers/custom-validators/follows.ts similarity index 87% rename from server/helpers/custom-validators/follows.ts rename to server/server/helpers/custom-validators/follows.ts index 0bec683c1..8e354dc25 100644 --- a/server/helpers/custom-validators/follows.ts +++ b/server/server/helpers/custom-validators/follows.ts @@ -1,5 +1,5 @@ -import { exists, isArray } from './misc' -import { FollowState } from '@shared/models' +import { exists, isArray } from './misc.js' +import { FollowState } from '@peertube/peertube-models' function isFollowStateValid (value: FollowState) { if (!exists(value)) return false diff --git a/server/helpers/custom-validators/jobs.ts b/server/server/helpers/custom-validators/jobs.ts similarity index 75% rename from server/helpers/custom-validators/jobs.ts rename to server/server/helpers/custom-validators/jobs.ts index c168b3e91..1da32c76a 100644 --- a/server/helpers/custom-validators/jobs.ts +++ b/server/server/helpers/custom-validators/jobs.ts @@ -1,6 +1,6 @@ -import { JobState } from '../../../shared/models' -import { exists } from './misc' -import { jobTypes } from '@server/lib/job-queue/job-queue' +import { JobState } from '@peertube/peertube-models' +import { jobTypes } from '@server/lib/job-queue/job-queue.js' +import { exists } from './misc.js' const jobStates: JobState[] = [ 'active', 'completed', 'failed', 'waiting', 'delayed', 'paused', 'waiting-children' ] diff --git a/server/helpers/custom-validators/logs.ts b/server/server/helpers/custom-validators/logs.ts similarity index 61% rename from server/helpers/custom-validators/logs.ts rename to server/server/helpers/custom-validators/logs.ts index 215dbb0e1..989ba09e5 100644 --- a/server/helpers/custom-validators/logs.ts +++ b/server/server/helpers/custom-validators/logs.ts @@ -1,7 +1,7 @@ import validator from 'validator' -import { CONSTRAINTS_FIELDS } from '@server/initializers/constants' -import { ClientLogLevel, ServerLogLevel } from '@shared/models' -import { exists } from './misc' +import { CONSTRAINTS_FIELDS } from '@server/initializers/constants.js' +import { ClientLogLevel, ServerLogLevel } from '@peertube/peertube-models' +import { exists } from './misc.js' const serverLogLevels = new Set([ 'debug', 'info', 'warn', 'error' ]) const clientLogLevels = new Set([ 'warn', 'error' ]) @@ -11,7 +11,7 @@ function isValidLogLevel (value: any) { } function isValidClientLogMessage (value: any) { - return typeof value === 'string' && validator.isLength(value, CONSTRAINTS_FIELDS.LOGS.CLIENT_MESSAGE) + return typeof value === 'string' && validator.default.isLength(value, CONSTRAINTS_FIELDS.LOGS.CLIENT_MESSAGE) } function isValidClientLogLevel (value: any) { @@ -19,15 +19,15 @@ function isValidClientLogLevel (value: any) { } function isValidClientLogStackTrace (value: any) { - return typeof value === 'string' && validator.isLength(value, CONSTRAINTS_FIELDS.LOGS.CLIENT_STACK_TRACE) + return typeof value === 'string' && validator.default.isLength(value, CONSTRAINTS_FIELDS.LOGS.CLIENT_STACK_TRACE) } function isValidClientLogMeta (value: any) { - return typeof value === 'string' && validator.isLength(value, CONSTRAINTS_FIELDS.LOGS.CLIENT_META) + return typeof value === 'string' && validator.default.isLength(value, CONSTRAINTS_FIELDS.LOGS.CLIENT_META) } function isValidClientLogUserAgent (value: any) { - return typeof value === 'string' && validator.isLength(value, CONSTRAINTS_FIELDS.LOGS.CLIENT_USER_AGENT) + return typeof value === 'string' && validator.default.isLength(value, CONSTRAINTS_FIELDS.LOGS.CLIENT_USER_AGENT) } // --------------------------------------------------------------------------- diff --git a/server/helpers/custom-validators/metrics.ts b/server/server/helpers/custom-validators/metrics.ts similarity index 100% rename from server/helpers/custom-validators/metrics.ts rename to server/server/helpers/custom-validators/metrics.ts diff --git a/server/helpers/custom-validators/misc.ts b/server/server/helpers/custom-validators/misc.ts similarity index 85% rename from server/helpers/custom-validators/misc.ts rename to server/server/helpers/custom-validators/misc.ts index 937ae0632..0be9ce2a3 100644 --- a/server/helpers/custom-validators/misc.ts +++ b/server/server/helpers/custom-validators/misc.ts @@ -2,7 +2,7 @@ import 'multer' import { UploadFilesForCheck } from 'express' import { sep } from 'path' import validator from 'validator' -import { isShortUUID, shortToUUID } from '@shared/extra-utils' +import { isShortUUID, shortToUUID } from '@peertube/peertube-node-utils' function exists (value: any) { return value !== undefined && value !== null @@ -32,7 +32,7 @@ function isArray (value: any): value is any[] { } function isNotEmptyIntArray (value: any) { - return Array.isArray(value) && value.every(v => validator.isInt('' + v)) && value.length !== 0 + return Array.isArray(value) && value.every(v => validator.default.isInt('' + v)) && value.length !== 0 } function isNotEmptyStringArray (value: any) { @@ -44,15 +44,15 @@ function isArrayOf (value: any, validator: (value: any) => boolean) { } function isDateValid (value: string) { - return exists(value) && validator.isISO8601(value) + return exists(value) && validator.default.isISO8601(value) } function isIdValid (value: string) { - return exists(value) && validator.isInt('' + value) + return exists(value) && validator.default.isInt('' + value) } function isUUIDValid (value: string) { - return exists(value) && validator.isUUID('' + value, 4) + return exists(value) && validator.default.isUUID('' + value, 4) } function areUUIDsValid (values: string[]) { @@ -64,11 +64,11 @@ function isIdOrUUIDValid (value: string) { } function isBooleanValid (value: any) { - return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value)) + return typeof value === 'boolean' || (typeof value === 'string' && validator.default.isBoolean(value)) } function isIntOrNull (value: any) { - return value === null || validator.isInt('' + value) + return value === null || validator.default.isInt('' + value) } // --------------------------------------------------------------------------- @@ -136,7 +136,7 @@ function toIntOrNull (value: string) { if (v === null || v === undefined) return v if (typeof v === 'number') return v - return validator.toInt('' + v) + return validator.default.toInt('' + v) } function toBooleanOrNull (value: any) { @@ -145,7 +145,7 @@ function toBooleanOrNull (value: any) { if (v === null || v === undefined) return v if (typeof v === 'boolean') return v - return validator.toBoolean('' + v) + return validator.default.toBoolean('' + v) } function toValueOrNull (value: string) { @@ -156,9 +156,9 @@ function toValueOrNull (value: string) { function toIntArray (value: any) { if (!value) return [] - if (isArray(value) === false) return [ validator.toInt(value) ] + if (isArray(value) === false) return [ validator.default.toInt(value) ] - return value.map(v => validator.toInt(v)) + return value.map(v => validator.default.toInt(v)) } // --------------------------------------------------------------------------- diff --git a/server/helpers/custom-validators/plugins.ts b/server/server/helpers/custom-validators/plugins.ts similarity index 85% rename from server/helpers/custom-validators/plugins.ts rename to server/server/helpers/custom-validators/plugins.ts index a20de0c4a..875482f53 100644 --- a/server/helpers/custom-validators/plugins.ts +++ b/server/server/helpers/custom-validators/plugins.ts @@ -1,9 +1,8 @@ import validator from 'validator' -import { PluginPackageJSON } from '../../../shared/models/plugins/plugin-package-json.model' -import { PluginType } from '../../../shared/models/plugins/plugin.type' -import { CONSTRAINTS_FIELDS } from '../../initializers/constants' -import { isUrlValid } from './activitypub/misc' -import { exists, isArray, isSafePath } from './misc' +import { PluginPackageJSON, PluginType, PluginType_Type } from '@peertube/peertube-models' +import { CONSTRAINTS_FIELDS } from '../../initializers/constants.js' +import { isUrlValid } from './activitypub/misc.js' +import { exists, isArray, isSafePath } from './misc.js' const PLUGINS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.PLUGINS @@ -14,19 +13,19 @@ function isPluginTypeValid (value: any) { function isPluginNameValid (value: string) { return exists(value) && - validator.isLength(value, PLUGINS_CONSTRAINTS_FIELDS.NAME) && - validator.matches(value, /^[a-z-0-9]+$/) + validator.default.isLength(value, PLUGINS_CONSTRAINTS_FIELDS.NAME) && + validator.default.matches(value, /^[a-z-0-9]+$/) } function isNpmPluginNameValid (value: string) { return exists(value) && - validator.isLength(value, PLUGINS_CONSTRAINTS_FIELDS.NAME) && - validator.matches(value, /^[a-z\-._0-9]+$/) && + validator.default.isLength(value, PLUGINS_CONSTRAINTS_FIELDS.NAME) && + validator.default.matches(value, /^[a-z\-._0-9]+$/) && (value.startsWith('peertube-plugin-') || value.startsWith('peertube-theme-')) } function isPluginDescriptionValid (value: string) { - return exists(value) && validator.isLength(value, PLUGINS_CONSTRAINTS_FIELDS.DESCRIPTION) + return exists(value) && validator.default.isLength(value, PLUGINS_CONSTRAINTS_FIELDS.DESCRIPTION) } function isPluginStableVersionValid (value: string) { @@ -34,7 +33,7 @@ function isPluginStableVersionValid (value: string) { const parts = (value + '').split('.') - return parts.length === 3 && parts.every(p => validator.isInt(p)) + return parts.length === 3 && parts.every(p => validator.default.isInt(p)) } function isPluginStableOrUnstableVersionValid (value: string) { @@ -97,7 +96,7 @@ function isThemeNameValid (name: string) { return isPluginNameValid(name) } -function isPackageJSONValid (packageJSON: PluginPackageJSON, pluginType: PluginType) { +function isPackageJSONValid (packageJSON: PluginPackageJSON, pluginType: PluginType_Type) { let result = true const badFields: string[] = [] diff --git a/server/helpers/custom-validators/runners/jobs.ts b/server/server/helpers/custom-validators/runners/jobs.ts similarity index 93% rename from server/helpers/custom-validators/runners/jobs.ts rename to server/server/helpers/custom-validators/runners/jobs.ts index 6349e79ba..78c6c2e1e 100644 --- a/server/helpers/custom-validators/runners/jobs.ts +++ b/server/server/helpers/custom-validators/runners/jobs.ts @@ -1,6 +1,6 @@ import { UploadFilesForCheck } from 'express' import validator from 'validator' -import { CONSTRAINTS_FIELDS, RUNNER_JOB_STATES } from '@server/initializers/constants' +import { CONSTRAINTS_FIELDS, RUNNER_JOB_STATES } from '@server/initializers/constants.js' import { LiveRTMPHLSTranscodingSuccess, RunnerJobSuccessPayload, @@ -10,8 +10,8 @@ import { VODAudioMergeTranscodingSuccess, VODHLSTranscodingSuccess, VODWebVideoTranscodingSuccess -} from '@shared/models' -import { exists, isArray, isFileValid, isSafeFilename } from '../misc' +} from '@peertube/peertube-models' +import { exists, isArray, isFileValid, isSafeFilename } from '../misc.js' const RUNNER_JOBS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.RUNNER_JOBS @@ -31,7 +31,7 @@ function isRunnerJobSuccessPayloadValid (value: RunnerJobSuccessPayload, type: R // --------------------------------------------------------------------------- function isRunnerJobProgressValid (value: string) { - return validator.isInt(value + '', RUNNER_JOBS_CONSTRAINTS_FIELDS.PROGRESS) + return validator.default.isInt(value + '', RUNNER_JOBS_CONSTRAINTS_FIELDS.PROGRESS) } function isRunnerJobUpdatePayloadValid (value: RunnerJobUpdatePayload, type: RunnerJobType, files: UploadFilesForCheck) { @@ -45,15 +45,15 @@ function isRunnerJobUpdatePayloadValid (value: RunnerJobUpdatePayload, type: Run // --------------------------------------------------------------------------- function isRunnerJobTokenValid (value: string) { - return exists(value) && validator.isLength(value, RUNNER_JOBS_CONSTRAINTS_FIELDS.TOKEN) + return exists(value) && validator.default.isLength(value, RUNNER_JOBS_CONSTRAINTS_FIELDS.TOKEN) } function isRunnerJobAbortReasonValid (value: string) { - return validator.isLength(value, RUNNER_JOBS_CONSTRAINTS_FIELDS.REASON) + return validator.default.isLength(value, RUNNER_JOBS_CONSTRAINTS_FIELDS.REASON) } function isRunnerJobErrorMessageValid (value: string) { - return validator.isLength(value, RUNNER_JOBS_CONSTRAINTS_FIELDS.ERROR_MESSAGE) + return validator.default.isLength(value, RUNNER_JOBS_CONSTRAINTS_FIELDS.ERROR_MESSAGE) } function isRunnerJobStateValid (value: any) { diff --git a/server/helpers/custom-validators/runners/runners.ts b/server/server/helpers/custom-validators/runners/runners.ts similarity index 57% rename from server/helpers/custom-validators/runners/runners.ts rename to server/server/helpers/custom-validators/runners/runners.ts index 953fac3b5..821622a2b 100644 --- a/server/helpers/custom-validators/runners/runners.ts +++ b/server/server/helpers/custom-validators/runners/runners.ts @@ -1,23 +1,23 @@ import validator from 'validator' -import { CONSTRAINTS_FIELDS } from '@server/initializers/constants' -import { exists } from '../misc' +import { CONSTRAINTS_FIELDS } from '@server/initializers/constants.js' +import { exists } from '../misc.js' const RUNNERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.RUNNERS function isRunnerRegistrationTokenValid (value: string) { - return exists(value) && validator.isLength(value, RUNNERS_CONSTRAINTS_FIELDS.TOKEN) + return exists(value) && validator.default.isLength(value, RUNNERS_CONSTRAINTS_FIELDS.TOKEN) } function isRunnerTokenValid (value: string) { - return exists(value) && validator.isLength(value, RUNNERS_CONSTRAINTS_FIELDS.TOKEN) + return exists(value) && validator.default.isLength(value, RUNNERS_CONSTRAINTS_FIELDS.TOKEN) } function isRunnerNameValid (value: string) { - return exists(value) && validator.isLength(value, RUNNERS_CONSTRAINTS_FIELDS.NAME) + return exists(value) && validator.default.isLength(value, RUNNERS_CONSTRAINTS_FIELDS.NAME) } function isRunnerDescriptionValid (value: string) { - return exists(value) && validator.isLength(value, RUNNERS_CONSTRAINTS_FIELDS.DESCRIPTION) + return exists(value) && validator.default.isLength(value, RUNNERS_CONSTRAINTS_FIELDS.DESCRIPTION) } // --------------------------------------------------------------------------- diff --git a/server/helpers/custom-validators/search.ts b/server/server/helpers/custom-validators/search.ts similarity index 75% rename from server/helpers/custom-validators/search.ts rename to server/server/helpers/custom-validators/search.ts index 6dba5d14e..cb950c8dd 100644 --- a/server/helpers/custom-validators/search.ts +++ b/server/server/helpers/custom-validators/search.ts @@ -1,10 +1,10 @@ import validator from 'validator' -import { SearchTargetType } from '@shared/models/search/search-target-query.model' -import { isArray, exists } from './misc' -import { CONFIG } from '@server/initializers/config' +import { SearchTargetType } from '@peertube/peertube-models' +import { CONFIG } from '@server/initializers/config.js' +import { exists, isArray } from './misc.js' function isNumberArray (value: any) { - return isArray(value) && value.every(v => validator.isInt('' + v)) + return isArray(value) && value.every(v => validator.default.isInt('' + v)) } function isStringArray (value: any) { diff --git a/server/helpers/custom-validators/servers.ts b/server/server/helpers/custom-validators/servers.ts similarity index 68% rename from server/helpers/custom-validators/servers.ts rename to server/server/helpers/custom-validators/servers.ts index b2aa03b77..5f884e911 100644 --- a/server/helpers/custom-validators/servers.ts +++ b/server/server/helpers/custom-validators/servers.ts @@ -1,7 +1,7 @@ import validator from 'validator' -import { CONFIG } from '@server/initializers/config' -import { CONSTRAINTS_FIELDS } from '../../initializers/constants' -import { exists, isArray } from './misc' +import { CONFIG } from '@server/initializers/config.js' +import { CONSTRAINTS_FIELDS } from '../../initializers/constants.js' +import { exists, isArray } from './misc.js' function isHostValid (host: string) { const isURLOptions = { @@ -14,7 +14,7 @@ function isHostValid (host: string) { isURLOptions.require_tld = false } - return exists(host) && validator.isURL(host, isURLOptions) && host.split('://').length === 1 + return exists(host) && validator.default.isURL(host, isURLOptions) && host.split('://').length === 1 } function isEachUniqueHostValid (hosts: string[]) { @@ -25,11 +25,11 @@ function isEachUniqueHostValid (hosts: string[]) { } function isValidContactBody (value: any) { - return exists(value) && validator.isLength(value, CONSTRAINTS_FIELDS.CONTACT_FORM.BODY) + return exists(value) && validator.default.isLength(value, CONSTRAINTS_FIELDS.CONTACT_FORM.BODY) } function isValidContactFromName (value: any) { - return exists(value) && validator.isLength(value, CONSTRAINTS_FIELDS.CONTACT_FORM.FROM_NAME) + return exists(value) && validator.default.isLength(value, CONSTRAINTS_FIELDS.CONTACT_FORM.FROM_NAME) } // --------------------------------------------------------------------------- diff --git a/server/helpers/custom-validators/user-notifications.ts b/server/server/helpers/custom-validators/user-notifications.ts similarity index 70% rename from server/helpers/custom-validators/user-notifications.ts rename to server/server/helpers/custom-validators/user-notifications.ts index 2de13ca09..151f96522 100644 --- a/server/helpers/custom-validators/user-notifications.ts +++ b/server/server/helpers/custom-validators/user-notifications.ts @@ -1,14 +1,14 @@ import validator from 'validator' -import { UserNotificationSettingValue } from '@shared/models' -import { exists } from './misc' +import { UserNotificationSettingValue } from '@peertube/peertube-models' +import { exists } from './misc.js' function isUserNotificationTypeValid (value: any) { - return exists(value) && validator.isInt('' + value) + return exists(value) && validator.default.isInt('' + value) } function isUserNotificationSettingValid (value: any) { return exists(value) && - validator.isInt('' + value) && + validator.default.isInt('' + value) && ( value === UserNotificationSettingValue.NONE || value === UserNotificationSettingValue.WEB || diff --git a/server/helpers/custom-validators/user-registration.ts b/server/server/helpers/custom-validators/user-registration.ts similarity index 67% rename from server/helpers/custom-validators/user-registration.ts rename to server/server/helpers/custom-validators/user-registration.ts index 9da0bb08a..7d8c8e592 100644 --- a/server/helpers/custom-validators/user-registration.ts +++ b/server/server/helpers/custom-validators/user-registration.ts @@ -1,6 +1,6 @@ import validator from 'validator' -import { CONSTRAINTS_FIELDS, USER_REGISTRATION_STATES } from '../../initializers/constants' -import { exists } from './misc' +import { CONSTRAINTS_FIELDS, USER_REGISTRATION_STATES } from '../../initializers/constants.js' +import { exists } from './misc.js' const USER_REGISTRATIONS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USER_REGISTRATIONS @@ -9,11 +9,11 @@ function isRegistrationStateValid (value: string) { } function isRegistrationModerationResponseValid (value: string) { - return exists(value) && validator.isLength(value, USER_REGISTRATIONS_CONSTRAINTS_FIELDS.MODERATOR_MESSAGE) + return exists(value) && validator.default.isLength(value, USER_REGISTRATIONS_CONSTRAINTS_FIELDS.MODERATOR_MESSAGE) } function isRegistrationReasonValid (value: string) { - return exists(value) && validator.isLength(value, USER_REGISTRATIONS_CONSTRAINTS_FIELDS.REASON_MESSAGE) + return exists(value) && validator.default.isLength(value, USER_REGISTRATIONS_CONSTRAINTS_FIELDS.REASON_MESSAGE) } // --------------------------------------------------------------------------- diff --git a/server/helpers/custom-validators/users.ts b/server/server/helpers/custom-validators/users.ts similarity index 67% rename from server/helpers/custom-validators/users.ts rename to server/server/helpers/custom-validators/users.ts index f02b3ba65..84c49ff66 100644 --- a/server/helpers/custom-validators/users.ts +++ b/server/server/helpers/custom-validators/users.ts @@ -1,13 +1,13 @@ import validator from 'validator' -import { UserRole } from '@shared/models' -import { isEmailEnabled } from '../../initializers/config' -import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers/constants' -import { exists, isArray, isBooleanValid } from './misc' +import { UserRole } from '@peertube/peertube-models' +import { isEmailEnabled } from '../../initializers/config.js' +import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers/constants.js' +import { exists, isArray, isBooleanValid } from './misc.js' const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS function isUserPasswordValid (value: string) { - return validator.isLength(value, USERS_CONSTRAINTS_FIELDS.PASSWORD) + return validator.default.isLength(value, USERS_CONSTRAINTS_FIELDS.PASSWORD) } function isUserPasswordValidOrEmpty (value: string) { @@ -18,25 +18,25 @@ function isUserPasswordValidOrEmpty (value: string) { } function isUserVideoQuotaValid (value: string) { - return exists(value) && validator.isInt(value + '', USERS_CONSTRAINTS_FIELDS.VIDEO_QUOTA) + return exists(value) && validator.default.isInt(value + '', USERS_CONSTRAINTS_FIELDS.VIDEO_QUOTA) } function isUserVideoQuotaDailyValid (value: string) { - return exists(value) && validator.isInt(value + '', USERS_CONSTRAINTS_FIELDS.VIDEO_QUOTA_DAILY) + return exists(value) && validator.default.isInt(value + '', USERS_CONSTRAINTS_FIELDS.VIDEO_QUOTA_DAILY) } function isUserUsernameValid (value: string) { return exists(value) && - validator.matches(value, new RegExp(`^[a-z0-9_]+([a-z0-9_.-]+[a-z0-9_]+)?$`)) && - validator.isLength(value, USERS_CONSTRAINTS_FIELDS.USERNAME) + validator.default.matches(value, new RegExp(`^[a-z0-9_]+([a-z0-9_.-]+[a-z0-9_]+)?$`)) && + validator.default.isLength(value, USERS_CONSTRAINTS_FIELDS.USERNAME) } function isUserDisplayNameValid (value: string) { - return value === null || (exists(value) && validator.isLength(value, CONSTRAINTS_FIELDS.USERS.NAME)) + return value === null || (exists(value) && validator.default.isLength(value, CONSTRAINTS_FIELDS.USERS.NAME)) } function isUserDescriptionValid (value: string) { - return value === null || (exists(value) && validator.isLength(value, CONSTRAINTS_FIELDS.USERS.DESCRIPTION)) + return value === null || (exists(value) && validator.default.isLength(value, CONSTRAINTS_FIELDS.USERS.DESCRIPTION)) } function isUserEmailVerifiedValid (value: any) { @@ -65,7 +65,7 @@ function isUserVideoLanguages (value: any) { } function isUserAdminFlagsValid (value: any) { - return exists(value) && validator.isInt('' + value) + return exists(value) && validator.default.isInt('' + value) } function isUserBlockedValid (value: any) { @@ -89,11 +89,13 @@ function isUserNoModal (value: any) { } function isUserBlockedReasonValid (value: any) { - return value === null || (exists(value) && validator.isLength(value, CONSTRAINTS_FIELDS.USERS.BLOCKED_REASON)) + return value === null || (exists(value) && validator.default.isLength(value, CONSTRAINTS_FIELDS.USERS.BLOCKED_REASON)) } function isUserRoleValid (value: any) { - return exists(value) && validator.isInt('' + value) && [ UserRole.ADMINISTRATOR, UserRole.MODERATOR, UserRole.USER ].includes(value) + return exists(value) && + validator.default.isInt('' + value) && + [ UserRole.ADMINISTRATOR, UserRole.MODERATOR, UserRole.USER ].includes(value) } // --------------------------------------------------------------------------- diff --git a/server/helpers/custom-validators/video-blacklist.ts b/server/server/helpers/custom-validators/video-blacklist.ts similarity index 73% rename from server/helpers/custom-validators/video-blacklist.ts rename to server/server/helpers/custom-validators/video-blacklist.ts index 34fcec38e..15a13ae5f 100644 --- a/server/helpers/custom-validators/video-blacklist.ts +++ b/server/server/helpers/custom-validators/video-blacklist.ts @@ -1,12 +1,12 @@ import validator from 'validator' -import { exists } from './misc' -import { CONSTRAINTS_FIELDS } from '../../initializers/constants' -import { VideoBlacklistType } from '../../../shared/models/videos' +import { VideoBlacklistType } from '@peertube/peertube-models' +import { CONSTRAINTS_FIELDS } from '../../initializers/constants.js' +import { exists } from './misc.js' const VIDEO_BLACKLIST_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_BLACKLIST function isVideoBlacklistReasonValid (value: string) { - return value === null || validator.isLength(value, VIDEO_BLACKLIST_CONSTRAINTS_FIELDS.REASON) + return value === null || validator.default.isLength(value, VIDEO_BLACKLIST_CONSTRAINTS_FIELDS.REASON) } function isVideoBlacklistTypeValid (value: any) { diff --git a/server/helpers/custom-validators/video-captions.ts b/server/server/helpers/custom-validators/video-captions.ts similarity index 84% rename from server/helpers/custom-validators/video-captions.ts rename to server/server/helpers/custom-validators/video-captions.ts index 0e24655a0..dcd9fc2c1 100644 --- a/server/helpers/custom-validators/video-captions.ts +++ b/server/server/helpers/custom-validators/video-captions.ts @@ -1,9 +1,9 @@ import { UploadFilesForCheck } from 'express' -import { readFile } from 'fs-extra' -import { getFileSize } from '@shared/extra-utils' -import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_LANGUAGES } from '../../initializers/constants' -import { logger } from '../logger' -import { exists, isFileValid } from './misc' +import { readFile } from 'fs/promises' +import { getFileSize } from '@peertube/peertube-node-utils' +import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_LANGUAGES } from '../../initializers/constants.js' +import { logger } from '../logger.js' +import { exists, isFileValid } from './misc.js' function isVideoCaptionLanguageValid (value: any) { return exists(value) && VIDEO_LANGUAGES[value] !== undefined diff --git a/server/helpers/custom-validators/video-channel-syncs.ts b/server/server/helpers/custom-validators/video-channel-syncs.ts similarity index 80% rename from server/helpers/custom-validators/video-channel-syncs.ts rename to server/server/helpers/custom-validators/video-channel-syncs.ts index c5a9afa96..a07d8ed52 100644 --- a/server/helpers/custom-validators/video-channel-syncs.ts +++ b/server/server/helpers/custom-validators/video-channel-syncs.ts @@ -1,5 +1,5 @@ -import { VIDEO_CHANNEL_SYNC_STATE } from '@server/initializers/constants' -import { exists } from './misc' +import { VIDEO_CHANNEL_SYNC_STATE } from '@server/initializers/constants.js' +import { exists } from './misc.js' export function isVideoChannelSyncStateValid (value: any) { return exists(value) && VIDEO_CHANNEL_SYNC_STATE[value] !== undefined diff --git a/server/helpers/custom-validators/video-channels.ts b/server/server/helpers/custom-validators/video-channels.ts similarity index 63% rename from server/helpers/custom-validators/video-channels.ts rename to server/server/helpers/custom-validators/video-channels.ts index 249083f39..2ea3afd2d 100644 --- a/server/helpers/custom-validators/video-channels.ts +++ b/server/server/helpers/custom-validators/video-channels.ts @@ -1,7 +1,7 @@ import validator from 'validator' -import { CONSTRAINTS_FIELDS } from '../../initializers/constants' -import { exists } from './misc' -import { isUserUsernameValid } from './users' +import { CONSTRAINTS_FIELDS } from '../../initializers/constants.js' +import { exists } from './misc.js' +import { isUserUsernameValid } from './users.js' const VIDEO_CHANNELS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_CHANNELS @@ -11,15 +11,15 @@ function isVideoChannelUsernameValid (value: string) { } function isVideoChannelDescriptionValid (value: string) { - return value === null || validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.DESCRIPTION) + return value === null || validator.default.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.DESCRIPTION) } function isVideoChannelDisplayNameValid (value: string) { - return exists(value) && validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.NAME) + return exists(value) && validator.default.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.NAME) } function isVideoChannelSupportValid (value: string) { - return value === null || (exists(value) && validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.SUPPORT)) + return value === null || (exists(value) && validator.default.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.SUPPORT)) } // --------------------------------------------------------------------------- diff --git a/server/helpers/custom-validators/video-comments.ts b/server/server/helpers/custom-validators/video-comments.ts similarity index 76% rename from server/helpers/custom-validators/video-comments.ts rename to server/server/helpers/custom-validators/video-comments.ts index 94bdf237a..104583663 100644 --- a/server/helpers/custom-validators/video-comments.ts +++ b/server/server/helpers/custom-validators/video-comments.ts @@ -1,10 +1,10 @@ import validator from 'validator' -import { CONSTRAINTS_FIELDS } from '../../initializers/constants' +import { CONSTRAINTS_FIELDS } from '../../initializers/constants.js' const VIDEO_COMMENTS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_COMMENTS function isValidVideoCommentText (value: string) { - return value === null || validator.isLength(value, VIDEO_COMMENTS_CONSTRAINTS_FIELDS.TEXT) + return value === null || validator.default.isLength(value, VIDEO_COMMENTS_CONSTRAINTS_FIELDS.TEXT) } // --------------------------------------------------------------------------- diff --git a/server/helpers/custom-validators/video-imports.ts b/server/server/helpers/custom-validators/video-imports.ts similarity index 84% rename from server/helpers/custom-validators/video-imports.ts rename to server/server/helpers/custom-validators/video-imports.ts index da8962cb6..7d6bba932 100644 --- a/server/helpers/custom-validators/video-imports.ts +++ b/server/server/helpers/custom-validators/video-imports.ts @@ -1,8 +1,8 @@ import 'multer' import { UploadFilesForCheck } from 'express' import validator from 'validator' -import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_IMPORT_STATES } from '../../initializers/constants' -import { exists, isFileValid } from './misc' +import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_IMPORT_STATES } from '../../initializers/constants.js' +import { exists, isFileValid } from './misc.js' function isVideoImportTargetUrlValid (url: string) { const isURLOptions = { @@ -14,8 +14,8 @@ function isVideoImportTargetUrlValid (url: string) { } return exists(url) && - validator.isURL('' + url, isURLOptions) && - validator.isLength('' + url, CONSTRAINTS_FIELDS.VIDEO_IMPORTS.URL) + validator.default.isURL('' + url, isURLOptions) && + validator.default.isLength('' + url, CONSTRAINTS_FIELDS.VIDEO_IMPORTS.URL) } function isVideoImportStateValid (value: any) { diff --git a/server/helpers/custom-validators/video-lives.ts b/server/server/helpers/custom-validators/video-lives.ts similarity index 81% rename from server/helpers/custom-validators/video-lives.ts rename to server/server/helpers/custom-validators/video-lives.ts index 69d08ae68..1a9268113 100644 --- a/server/helpers/custom-validators/video-lives.ts +++ b/server/server/helpers/custom-validators/video-lives.ts @@ -1,4 +1,4 @@ -import { LiveVideoLatencyMode } from '@shared/models' +import { LiveVideoLatencyMode } from '@peertube/peertube-models' function isLiveLatencyModeValid (value: any) { return [ LiveVideoLatencyMode.DEFAULT, LiveVideoLatencyMode.SMALL_LATENCY, LiveVideoLatencyMode.HIGH_LATENCY ].includes(value) diff --git a/server/helpers/custom-validators/video-ownership.ts b/server/server/helpers/custom-validators/video-ownership.ts similarity index 76% rename from server/helpers/custom-validators/video-ownership.ts rename to server/server/helpers/custom-validators/video-ownership.ts index cf15b385a..5961ed97c 100644 --- a/server/helpers/custom-validators/video-ownership.ts +++ b/server/server/helpers/custom-validators/video-ownership.ts @@ -1,7 +1,7 @@ import { Response } from 'express' -import { MUserId } from '@server/types/models' -import { MVideoChangeOwnershipFull } from '@server/types/models/video/video-change-ownership' -import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' +import { HttpStatusCode } from '@peertube/peertube-models' +import { MUserId } from '@server/types/models/index.js' +import { MVideoChangeOwnershipFull } from '@server/types/models/video/video-change-ownership.js' function checkUserCanTerminateOwnershipChange (user: MUserId, videoChangeOwnership: MVideoChangeOwnershipFull, res: Response) { if (videoChangeOwnership.NextOwner.userId === user.id) { diff --git a/server/helpers/custom-validators/video-playlists.ts b/server/server/helpers/custom-validators/video-playlists.ts similarity index 60% rename from server/helpers/custom-validators/video-playlists.ts rename to server/server/helpers/custom-validators/video-playlists.ts index 180018fc5..f3b30bf50 100644 --- a/server/helpers/custom-validators/video-playlists.ts +++ b/server/server/helpers/custom-validators/video-playlists.ts @@ -1,23 +1,23 @@ -import { exists } from './misc' +import { exists } from './misc.js' import validator from 'validator' -import { CONSTRAINTS_FIELDS, VIDEO_PLAYLIST_PRIVACIES, VIDEO_PLAYLIST_TYPES } from '../../initializers/constants' +import { CONSTRAINTS_FIELDS, VIDEO_PLAYLIST_PRIVACIES, VIDEO_PLAYLIST_TYPES } from '../../initializers/constants.js' const PLAYLISTS_CONSTRAINT_FIELDS = CONSTRAINTS_FIELDS.VIDEO_PLAYLISTS function isVideoPlaylistNameValid (value: any) { - return exists(value) && validator.isLength(value, PLAYLISTS_CONSTRAINT_FIELDS.NAME) + return exists(value) && validator.default.isLength(value, PLAYLISTS_CONSTRAINT_FIELDS.NAME) } function isVideoPlaylistDescriptionValid (value: any) { - return value === null || (exists(value) && validator.isLength(value, PLAYLISTS_CONSTRAINT_FIELDS.DESCRIPTION)) + return value === null || (exists(value) && validator.default.isLength(value, PLAYLISTS_CONSTRAINT_FIELDS.DESCRIPTION)) } function isVideoPlaylistPrivacyValid (value: number) { - return validator.isInt(value + '') && VIDEO_PLAYLIST_PRIVACIES[value] !== undefined + return validator.default.isInt(value + '') && VIDEO_PLAYLIST_PRIVACIES[value] !== undefined } function isVideoPlaylistTimestampValid (value: any) { - return value === null || (exists(value) && validator.isInt('' + value, { min: 0 })) + return value === null || (exists(value) && validator.default.isInt('' + value, { min: 0 })) } function isVideoPlaylistTypeValid (value: any) { diff --git a/server/helpers/custom-validators/video-rates.ts b/server/server/helpers/custom-validators/video-rates.ts similarity index 100% rename from server/helpers/custom-validators/video-rates.ts rename to server/server/helpers/custom-validators/video-rates.ts diff --git a/server/helpers/custom-validators/video-redundancies.ts b/server/server/helpers/custom-validators/video-redundancies.ts similarity index 87% rename from server/helpers/custom-validators/video-redundancies.ts rename to server/server/helpers/custom-validators/video-redundancies.ts index 50a559c4f..91ab35f4c 100644 --- a/server/helpers/custom-validators/video-redundancies.ts +++ b/server/server/helpers/custom-validators/video-redundancies.ts @@ -1,4 +1,4 @@ -import { exists } from './misc' +import { exists } from './misc.js' function isVideoRedundancyTarget (value: any) { return exists(value) && diff --git a/server/helpers/custom-validators/video-stats.ts b/server/server/helpers/custom-validators/video-stats.ts similarity index 82% rename from server/helpers/custom-validators/video-stats.ts rename to server/server/helpers/custom-validators/video-stats.ts index 1e22f0654..7bd30c8e2 100644 --- a/server/helpers/custom-validators/video-stats.ts +++ b/server/server/helpers/custom-validators/video-stats.ts @@ -1,4 +1,4 @@ -import { VideoStatsTimeserieMetric } from '@shared/models' +import { VideoStatsTimeserieMetric } from '@peertube/peertube-models' const validMetrics = new Set([ 'viewers', diff --git a/server/helpers/custom-validators/video-studio.ts b/server/server/helpers/custom-validators/video-studio.ts similarity index 80% rename from server/helpers/custom-validators/video-studio.ts rename to server/server/helpers/custom-validators/video-studio.ts index 68dfec8dd..de9467320 100644 --- a/server/helpers/custom-validators/video-studio.ts +++ b/server/server/helpers/custom-validators/video-studio.ts @@ -1,10 +1,10 @@ import validator from 'validator' -import { CONSTRAINTS_FIELDS } from '@server/initializers/constants' -import { buildTaskFileFieldname } from '@server/lib/video-studio' -import { VideoStudioTask } from '@shared/models' -import { isArray } from './misc' -import { isVideoFileMimeTypeValid, isVideoImageValid } from './videos' -import { forceNumber } from '@shared/core-utils' +import { CONSTRAINTS_FIELDS } from '@server/initializers/constants.js' +import { buildTaskFileFieldname } from '@server/lib/video-studio.js' +import { VideoStudioTask } from '@peertube/peertube-models' +import { isArray } from './misc.js' +import { isVideoFileMimeTypeValid, isVideoImageValid } from './videos.js' +import { forceNumber } from '@peertube/peertube-core-utils' function isValidStudioTasksArray (tasks: any) { if (!isArray(tasks)) return false @@ -20,8 +20,8 @@ function isStudioCutTaskValid (task: VideoStudioTask) { const { start, end } = task.options if (!start && !end) return false - if (start && !validator.isInt(start + '', CONSTRAINTS_FIELDS.VIDEO_STUDIO.CUT_TIME)) return false - if (end && !validator.isInt(end + '', CONSTRAINTS_FIELDS.VIDEO_STUDIO.CUT_TIME)) return false + if (start && !validator.default.isInt(start + '', CONSTRAINTS_FIELDS.VIDEO_STUDIO.CUT_TIME)) return false + if (end && !validator.default.isInt(end + '', CONSTRAINTS_FIELDS.VIDEO_STUDIO.CUT_TIME)) return false if (!start || !end) return true diff --git a/server/helpers/custom-validators/video-transcoding.ts b/server/server/helpers/custom-validators/video-transcoding.ts similarity index 89% rename from server/helpers/custom-validators/video-transcoding.ts rename to server/server/helpers/custom-validators/video-transcoding.ts index 220530de4..aa09d273e 100644 --- a/server/helpers/custom-validators/video-transcoding.ts +++ b/server/server/helpers/custom-validators/video-transcoding.ts @@ -1,4 +1,4 @@ -import { exists } from './misc' +import { exists } from './misc.js' function isValidCreateTranscodingType (value: any) { return exists(value) && diff --git a/server/helpers/custom-validators/video-view.ts b/server/server/helpers/custom-validators/video-view.ts similarity index 85% rename from server/helpers/custom-validators/video-view.ts rename to server/server/helpers/custom-validators/video-view.ts index 091c92083..2edd47ec9 100644 --- a/server/helpers/custom-validators/video-view.ts +++ b/server/server/helpers/custom-validators/video-view.ts @@ -1,4 +1,4 @@ -import { exists } from './misc' +import { exists } from './misc.js' function isVideoTimeValid (value: number, videoDuration?: number) { if (value < 0) return false diff --git a/server/helpers/custom-validators/videos.ts b/server/server/helpers/custom-validators/videos.ts similarity index 78% rename from server/helpers/custom-validators/videos.ts rename to server/server/helpers/custom-validators/videos.ts index 00c6deed4..0dede6c85 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/server/helpers/custom-validators/videos.ts @@ -1,8 +1,8 @@ import { Request, Response, UploadFilesForCheck } from 'express' import { decode as magnetUriDecode } from 'magnet-uri' import validator from 'validator' -import { getVideoWithAttributes } from '@server/helpers/video' -import { HttpStatusCode, VideoInclude, VideoPrivacy, VideoRateType } from '@shared/models' +import { HttpStatusCode, VideoIncludeType, VideoPrivacy, VideoPrivacyType, VideoRateType } from '@peertube/peertube-models' +import { getVideoWithAttributes } from '@server/helpers/video.js' import { CONSTRAINTS_FIELDS, MIMETYPES, @@ -12,13 +12,13 @@ import { VIDEO_PRIVACIES, VIDEO_RATE_TYPES, VIDEO_STATES -} from '../../initializers/constants' -import { exists, isArray, isDateValid, isFileValid } from './misc' +} from '../../initializers/constants.js' +import { exists, isArray, isDateValid, isFileValid } from './misc.js' const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS -function isVideoIncludeValid (include: VideoInclude) { - return exists(include) && validator.isInt('' + include) +function isVideoIncludeValid (include: VideoIncludeType) { + return exists(include) && validator.default.isInt('' + include) } function isVideoCategoryValid (value: any) { @@ -35,39 +35,39 @@ function isVideoLicenceValid (value: any) { function isVideoLanguageValid (value: any) { return value === null || - (typeof value === 'string' && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.LANGUAGE)) + (typeof value === 'string' && validator.default.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.LANGUAGE)) } function isVideoDurationValid (value: string) { - return exists(value) && validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.DURATION) + return exists(value) && validator.default.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.DURATION) } function isVideoDescriptionValid (value: string) { - return value === null || (exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.DESCRIPTION)) + return value === null || (exists(value) && validator.default.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.DESCRIPTION)) } function isVideoSupportValid (value: string) { - return value === null || (exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.SUPPORT)) + return value === null || (exists(value) && validator.default.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.SUPPORT)) } function isVideoNameValid (value: string) { - return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.NAME) + return exists(value) && validator.default.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.NAME) } function isVideoTagValid (tag: string) { - return exists(tag) && validator.isLength(tag, VIDEOS_CONSTRAINTS_FIELDS.TAG) + return exists(tag) && validator.default.isLength(tag, VIDEOS_CONSTRAINTS_FIELDS.TAG) } function areVideoTagsValid (tags: string[]) { return tags === null || ( isArray(tags) && - validator.isInt(tags.length.toString(), VIDEOS_CONSTRAINTS_FIELDS.TAGS) && + validator.default.isInt(tags.length.toString(), VIDEOS_CONSTRAINTS_FIELDS.TAGS) && tags.every(tag => isVideoTagValid(tag)) ) } function isVideoViewsValid (value: string) { - return exists(value) && validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.VIEWS) + return exists(value) && validator.default.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.VIEWS) } const ratingTypes = new Set(Object.values(VIDEO_RATE_TYPES)) @@ -120,19 +120,19 @@ function isVideoOriginallyPublishedAtValid (value: string | null) { } function isVideoFileInfoHashValid (value: string | null | undefined) { - return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH) + return exists(value) && validator.default.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH) } function isVideoFileResolutionValid (value: string) { - return exists(value) && validator.isInt(value + '') + return exists(value) && validator.default.isInt(value + '') } function isVideoFPSResolutionValid (value: string) { - return value === null || validator.isInt(value + '') + return value === null || validator.default.isInt(value + '') } function isVideoFileSizeValid (value: string) { - return exists(value) && validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.FILE_SIZE) + return exists(value) && validator.default.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.FILE_SIZE) } function isVideoMagnetUriValid (value: string) { @@ -156,7 +156,7 @@ function isValidPasswordProtectedPrivacy (req: Request, res: Response) { return false } - let privacy: VideoPrivacy + let privacy: VideoPrivacyType const video = getVideoWithAttributes(res) if (exists(req.body?.privacy)) privacy = req.body.privacy diff --git a/server/helpers/custom-validators/webfinger.ts b/server/server/helpers/custom-validators/webfinger.ts similarity index 85% rename from server/helpers/custom-validators/webfinger.ts rename to server/server/helpers/custom-validators/webfinger.ts index dd914341e..ce10c2247 100644 --- a/server/helpers/custom-validators/webfinger.ts +++ b/server/server/helpers/custom-validators/webfinger.ts @@ -1,6 +1,6 @@ -import { REMOTE_SCHEME, WEBSERVER } from '../../initializers/constants' -import { sanitizeHost } from '../core-utils' -import { exists } from './misc' +import { REMOTE_SCHEME, WEBSERVER } from '../../initializers/constants.js' +import { sanitizeHost } from '../core-utils.js' +import { exists } from './misc.js' function isWebfingerLocalResourceValid (value: string) { if (!exists(value)) return false diff --git a/server/helpers/database-utils.ts b/server/server/helpers/database-utils.ts similarity index 97% rename from server/helpers/database-utils.ts rename to server/server/helpers/database-utils.ts index b6ba7fd75..b7276bb84 100644 --- a/server/helpers/database-utils.ts +++ b/server/server/helpers/database-utils.ts @@ -1,9 +1,9 @@ -import retry from 'async/retry' +import retry from 'async/retry.js' import Bluebird from 'bluebird' import { Transaction } from 'sequelize' import { Model } from 'sequelize-typescript' -import { sequelizeTypescript } from '@server/initializers/database' -import { logger } from './logger' +import { sequelizeTypescript } from '@server/initializers/database.js' +import { logger } from './logger.js' function retryTransactionWrapper ( functionToRetry: (arg1: A, arg2: B, arg3: C, arg4: D) => Promise, diff --git a/server/helpers/debounce.ts b/server/server/helpers/debounce.ts similarity index 100% rename from server/helpers/debounce.ts rename to server/server/helpers/debounce.ts diff --git a/server/helpers/decache.ts b/server/server/helpers/decache.ts similarity index 69% rename from server/helpers/decache.ts rename to server/server/helpers/decache.ts index 6be446ff6..cef3d639c 100644 --- a/server/helpers/decache.ts +++ b/server/server/helpers/decache.ts @@ -1,26 +1,27 @@ // Thanks: https://github.com/dwyl/decache // We reuse this file to also uncache plugin base path +import { Module } from 'module' import { extname } from 'path' -function decachePlugin (libraryPath: string) { - const moduleName = find(libraryPath) +function decachePlugin (require: NodeRequire, libraryPath: string) { + const moduleName = find(require, libraryPath) if (!moduleName) return - searchCache(moduleName, function (mod) { + searchCache(require, moduleName, function (mod) { delete require.cache[mod.id] removeCachedPath(mod.path) }) } -function decacheModule (name: string) { - const moduleName = find(name) +function decacheModule (require: NodeRequire, name: string) { + const moduleName = find(require, name) if (!moduleName) return - searchCache(moduleName, function (mod) { + searchCache(require, moduleName, function (mod) { delete require.cache[mod.id] removeCachedPath(mod.path) @@ -36,7 +37,7 @@ export { // --------------------------------------------------------------------------- -function find (moduleName: string) { +function find (require: NodeRequire, moduleName: string) { try { return require.resolve(moduleName) } catch { @@ -44,7 +45,7 @@ function find (moduleName: string) { } } -function searchCache (moduleName: string, callback: (current: NodeModule) => void) { +function searchCache (require: NodeRequire, moduleName: string, callback: (current: NodeModule) => void) { const resolvedModule = require.resolve(moduleName) let mod: NodeModule const visited = {} @@ -68,7 +69,7 @@ function searchCache (moduleName: string, callback: (current: NodeModule) => voi }; function removeCachedPath (pluginPath: string) { - const pathCache = (module.constructor as any)._pathCache as { [ id: string ]: string[] } + const pathCache = (Module as any)._pathCache as { [ id: string ]: string[] } Object.keys(pathCache).forEach(function (cacheKey) { if (cacheKey.includes(pluginPath)) { diff --git a/server/helpers/dns.ts b/server/server/helpers/dns.ts similarity index 87% rename from server/helpers/dns.ts rename to server/server/helpers/dns.ts index da8b666c2..52a0654d9 100644 --- a/server/helpers/dns.ts +++ b/server/server/helpers/dns.ts @@ -1,5 +1,5 @@ import { lookup } from 'dns' -import { parse as parseIP } from 'ipaddr.js' +import ipaddr from 'ipaddr.js' function dnsLookupAll (hostname: string) { return new Promise((res, rej) => { @@ -15,7 +15,7 @@ async function isResolvingToUnicastOnly (hostname: string) { const addresses = await dnsLookupAll(hostname) for (const address of addresses) { - const parsed = parseIP(address) + const parsed = ipaddr.parse(address) if (parsed.range() !== 'unicast') return false } diff --git a/server/helpers/express-utils.ts b/server/server/helpers/express-utils.ts similarity index 92% rename from server/helpers/express-utils.ts rename to server/server/helpers/express-utils.ts index 783097e55..773cad2b2 100644 --- a/server/helpers/express-utils.ts +++ b/server/server/helpers/express-utils.ts @@ -1,12 +1,12 @@ import express, { RequestHandler } from 'express' import multer, { diskStorage } from 'multer' -import { getLowercaseExtension } from '@shared/core-utils' -import { CONFIG } from '../initializers/config' -import { REMOTE_SCHEME } from '../initializers/constants' -import { isArray } from './custom-validators/misc' -import { logger } from './logger' -import { deleteFileAndCatch, generateRandomString } from './utils' -import { getExtFromMimetype } from './video' +import { getLowercaseExtension } from '@peertube/peertube-node-utils' +import { CONFIG } from '../initializers/config.js' +import { REMOTE_SCHEME } from '../initializers/constants.js' +import { isArray } from './custom-validators/misc.js' +import { logger } from './logger.js' +import { deleteFileAndCatch, generateRandomString } from './utils.js' +import { getExtFromMimetype } from './video.js' function buildNSFWFilter (res?: express.Response, paramNSFW?: string) { if (paramNSFW === 'true') return true diff --git a/server/helpers/ffmpeg/codecs.ts b/server/server/helpers/ffmpeg/codecs.ts similarity index 90% rename from server/helpers/ffmpeg/codecs.ts rename to server/server/helpers/ffmpeg/codecs.ts index 3bd7db396..ff98b8f99 100644 --- a/server/helpers/ffmpeg/codecs.ts +++ b/server/server/helpers/ffmpeg/codecs.ts @@ -1,7 +1,7 @@ import { FfprobeData } from 'fluent-ffmpeg' -import { getAudioStream, getVideoStream } from '@shared/ffmpeg' -import { logger } from '../logger' -import { forceNumber } from '@shared/core-utils' +import { getAudioStream, getVideoStream } from '@peertube/peertube-ffmpeg' +import { logger } from '../logger.js' +import { forceNumber } from '@peertube/peertube-core-utils' export async function getVideoStreamCodec (path: string) { const videoStream = await getVideoStream(path) diff --git a/server/helpers/ffmpeg/ffmpeg-image.ts b/server/server/helpers/ffmpeg/ffmpeg-image.ts similarity index 91% rename from server/helpers/ffmpeg/ffmpeg-image.ts rename to server/server/helpers/ffmpeg/ffmpeg-image.ts index 0bb0ff2c0..1f6c6a3c3 100644 --- a/server/helpers/ffmpeg/ffmpeg-image.ts +++ b/server/server/helpers/ffmpeg/ffmpeg-image.ts @@ -1,5 +1,5 @@ -import { FFmpegImage } from '@shared/ffmpeg' -import { getFFmpegCommandWrapperOptions } from './ffmpeg-options' +import { FFmpegImage } from '@peertube/peertube-ffmpeg' +import { getFFmpegCommandWrapperOptions } from './ffmpeg-options.js' export function processGIF (options: Parameters[0]) { return new FFmpegImage(getFFmpegCommandWrapperOptions('thumbnail')).processGIF(options) diff --git a/server/helpers/ffmpeg/ffmpeg-options.ts b/server/server/helpers/ffmpeg/ffmpeg-options.ts similarity index 78% rename from server/helpers/ffmpeg/ffmpeg-options.ts rename to server/server/helpers/ffmpeg/ffmpeg-options.ts index 64d7c4179..ec1b91f86 100644 --- a/server/helpers/ffmpeg/ffmpeg-options.ts +++ b/server/server/helpers/ffmpeg/ffmpeg-options.ts @@ -1,8 +1,8 @@ -import { logger } from '@server/helpers/logger' -import { CONFIG } from '@server/initializers/config' -import { FFMPEG_NICE } from '@server/initializers/constants' -import { FFmpegCommandWrapperOptions } from '@shared/ffmpeg' -import { AvailableEncoders } from '@shared/models' +import { logger } from '@server/helpers/logger.js' +import { CONFIG } from '@server/initializers/config.js' +import { FFMPEG_NICE } from '@server/initializers/constants.js' +import { FFmpegCommandWrapperOptions } from '@peertube/peertube-ffmpeg' +import { AvailableEncoders } from '@peertube/peertube-models' type CommandType = 'live' | 'vod' | 'thumbnail' diff --git a/server/helpers/ffmpeg/framerate.ts b/server/server/helpers/ffmpeg/framerate.ts similarity index 93% rename from server/helpers/ffmpeg/framerate.ts rename to server/server/helpers/ffmpeg/framerate.ts index 18cb0e0e2..8aef6f021 100644 --- a/server/helpers/ffmpeg/framerate.ts +++ b/server/server/helpers/ffmpeg/framerate.ts @@ -1,9 +1,8 @@ -import { VIDEO_TRANSCODING_FPS } from '@server/initializers/constants' -import { VideoResolution } from '@shared/models' +import { VIDEO_TRANSCODING_FPS } from '@server/initializers/constants.js' export function computeOutputFPS (options: { inputFPS: number - resolution: VideoResolution + resolution: number }) { const { resolution } = options diff --git a/server/server/helpers/ffmpeg/index.ts b/server/server/helpers/ffmpeg/index.ts new file mode 100644 index 000000000..69864926e --- /dev/null +++ b/server/server/helpers/ffmpeg/index.ts @@ -0,0 +1,4 @@ +export * from './codecs.js' +export * from './ffmpeg-image.js' +export * from './ffmpeg-options.js' +export * from './framerate.js' diff --git a/server/helpers/geo-ip.ts b/server/server/helpers/geo-ip.ts similarity index 87% rename from server/helpers/geo-ip.ts rename to server/server/helpers/geo-ip.ts index 9e44d660f..6a9cd2124 100644 --- a/server/helpers/geo-ip.ts +++ b/server/server/helpers/geo-ip.ts @@ -1,9 +1,10 @@ -import { pathExists, writeFile } from 'fs-extra' +import { pathExists } from 'fs-extra/esm' +import { writeFile } from 'fs/promises' import maxmind, { CountryResponse, Reader } from 'maxmind' import { join } from 'path' -import { CONFIG } from '@server/initializers/config' -import { logger, loggerTagsFactory } from './logger' -import { isBinaryResponse, peertubeGot } from './requests' +import { CONFIG } from '@server/initializers/config.js' +import { logger, loggerTagsFactory } from './logger.js' +import { isBinaryResponse, peertubeGot } from './requests.js' const lTags = loggerTagsFactory('geo-ip') diff --git a/server/helpers/image-utils.ts b/server/server/helpers/image-utils.ts similarity index 90% rename from server/helpers/image-utils.ts rename to server/server/helpers/image-utils.ts index 2a8bb6e6e..7c732235d 100644 --- a/server/helpers/image-utils.ts +++ b/server/server/helpers/image-utils.ts @@ -1,11 +1,12 @@ -import { copy, readFile, remove, rename } from 'fs-extra' -import Jimp, { read as jimpRead } from 'jimp' +import { copy, remove } from 'fs-extra/esm' +import { readFile, rename } from 'fs/promises' import { join } from 'path' import { ColorActionName } from '@jimp/plugin-color' -import { getLowercaseExtension } from '@shared/core-utils' -import { buildUUID } from '@shared/extra-utils' -import { convertWebPToJPG, generateThumbnailFromVideo, processGIF } from './ffmpeg' -import { logger, loggerTagsFactory } from './logger' +import { buildUUID, getLowercaseExtension } from '@peertube/peertube-node-utils' +import { convertWebPToJPG, generateThumbnailFromVideo, processGIF } from './ffmpeg/index.js' +import { logger, loggerTagsFactory } from './logger.js' + +import type Jimp from 'jimp' const lTags = loggerTagsFactory('image-utils') @@ -71,7 +72,9 @@ async function generateImageFromVideoFile (options: { async function getImageSize (path: string) { const inputBuffer = await readFile(path) - const image = await jimpRead(inputBuffer) + const Jimp = await import('jimp') + + const image = await Jimp.default.read(inputBuffer) return { width: image.getWidth(), @@ -96,8 +99,10 @@ async function jimpProcessor (path: string, destination: string, newSize: { widt let sourceImage: Jimp const inputBuffer = await readFile(path) + const Jimp = await import('jimp') + try { - sourceImage = await jimpRead(inputBuffer) + sourceImage = await Jimp.default.read(inputBuffer) } catch (err) { logger.debug('Cannot read %s with jimp. Try to convert the image using ffmpeg first.', path, { err }) @@ -105,7 +110,7 @@ async function jimpProcessor (path: string, destination: string, newSize: { widt await convertWebPToJPG({ path, destination: newName }) await rename(newName, path) - sourceImage = await jimpRead(path) + sourceImage = await Jimp.default.read(path) } await remove(destination) diff --git a/server/helpers/logger.ts b/server/server/helpers/logger.ts similarity index 95% rename from server/helpers/logger.ts rename to server/server/helpers/logger.ts index 6649db40f..1379d4864 100644 --- a/server/helpers/logger.ts +++ b/server/server/helpers/logger.ts @@ -1,13 +1,13 @@ -import { stat } from 'fs-extra' +import { stat } from 'fs/promises' import { join } from 'path' import { format as sqlFormat } from 'sql-formatter' import { createLogger, format, transports } from 'winston' import { FileTransportOptions } from 'winston/lib/winston/transports' import { context } from '@opentelemetry/api' -import { getSpanContext } from '@opentelemetry/api/build/src/trace/context-utils' -import { omit } from '@shared/core-utils' -import { CONFIG } from '../initializers/config' -import { LOG_FILENAME } from '../initializers/constants' +import { getSpanContext } from '@opentelemetry/api/build/src/trace/context-utils.js' +import { omit } from '@peertube/peertube-core-utils' +import { CONFIG } from '../initializers/config.js' +import { LOG_FILENAME } from '../initializers/constants.js' const label = CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT @@ -153,7 +153,7 @@ async function mtimeSortFilesDesc (files: string[], basePath: string) { // --------------------------------------------------------------------------- export { - LoggerTagsFn, + type LoggerTagsFn, buildLogger, timestampFormatter, diff --git a/server/helpers/markdown.ts b/server/server/helpers/markdown.ts similarity index 91% rename from server/helpers/markdown.ts rename to server/server/helpers/markdown.ts index a20ac22d4..e38e55502 100644 --- a/server/helpers/markdown.ts +++ b/server/server/helpers/markdown.ts @@ -1,12 +1,11 @@ -import { getDefaultSanitizeOptions, getTextOnlySanitizeOptions, TEXT_WITH_HTML_RULES } from '@shared/core-utils' +import MarkdownItClass from 'markdown-it' +import markdownItEmoji from 'markdown-it-emoji/light.js' +import sanitizeHtml from 'sanitize-html' +import { getDefaultSanitizeOptions, getTextOnlySanitizeOptions, TEXT_WITH_HTML_RULES } from '@peertube/peertube-core-utils' const defaultSanitizeOptions = getDefaultSanitizeOptions() const textOnlySanitizeOptions = getTextOnlySanitizeOptions() -const sanitizeHtml = require('sanitize-html') -const markdownItEmoji = require('markdown-it-emoji/light') -const MarkdownItClass = require('markdown-it') - const markdownItForSafeHtml = new MarkdownItClass('default', { linkify: true, breaks: true, html: true }) .enable(TEXT_WITH_HTML_RULES) .use(markdownItEmoji) diff --git a/server/helpers/memoize.ts b/server/server/helpers/memoize.ts similarity index 100% rename from server/helpers/memoize.ts rename to server/server/helpers/memoize.ts diff --git a/server/server/helpers/mentions.ts b/server/server/helpers/mentions.ts new file mode 100644 index 000000000..238e468ea --- /dev/null +++ b/server/server/helpers/mentions.ts @@ -0,0 +1,42 @@ +import { uniqify } from '@peertube/peertube-core-utils' +import { WEBSERVER } from '@server/initializers/constants.js' +import { actorNameAlphabet } from './custom-validators/activitypub/actor.js' +import { regexpCapture } from './regexp.js' + +export function extractMentions (text: string, isOwned: boolean) { + let result: string[] = [] + + const localMention = `@(${actorNameAlphabet}+)` + const remoteMention = `${localMention}@${WEBSERVER.HOST}` + + const mentionRegex = isOwned + ? '(?:(?:' + remoteMention + ')|(?:' + localMention + '))' // Include local mentions? + : '(?:' + remoteMention + ')' + + const firstMentionRegex = new RegExp(`^${mentionRegex} `, 'g') + const endMentionRegex = new RegExp(` ${mentionRegex}$`, 'g') + const remoteMentionsRegex = new RegExp(' ' + remoteMention + ' ', 'g') + + result = result.concat( + regexpCapture(text, firstMentionRegex) + .map(([ , username1, username2 ]) => username1 || username2), + + regexpCapture(text, endMentionRegex) + .map(([ , username1, username2 ]) => username1 || username2), + + regexpCapture(text, remoteMentionsRegex) + .map(([ , username ]) => username) + ) + + // Include local mentions + if (isOwned) { + const localMentionsRegex = new RegExp(' ' + localMention + ' ', 'g') + + result = result.concat( + regexpCapture(text, localMentionsRegex) + .map(([ , username ]) => username) + ) + } + + return uniqify(result) +} diff --git a/server/helpers/otp.ts b/server/server/helpers/otp.ts similarity index 84% rename from server/helpers/otp.ts rename to server/server/helpers/otp.ts index a32cc9621..673a043f6 100644 --- a/server/helpers/otp.ts +++ b/server/server/helpers/otp.ts @@ -1,7 +1,7 @@ import { Secret, TOTP } from 'otpauth' -import { CONFIG } from '@server/initializers/config' -import { WEBSERVER } from '@server/initializers/constants' -import { decrypt } from './peertube-crypto' +import { CONFIG } from '@server/initializers/config.js' +import { WEBSERVER } from '@server/initializers/constants.js' +import { decrypt } from './peertube-crypto.js' async function isOTPValid (options: { encryptedSecret: string diff --git a/server/helpers/peertube-crypto.ts b/server/server/helpers/peertube-crypto.ts similarity index 83% rename from server/helpers/peertube-crypto.ts rename to server/server/helpers/peertube-crypto.ts index 95e78a904..45f2da6bf 100644 --- a/server/helpers/peertube-crypto.ts +++ b/server/server/helpers/peertube-crypto.ts @@ -1,20 +1,12 @@ -import { compare, genSalt, hash } from 'bcrypt' +import httpSignature from '@peertube/http-signature' +import { sha256 } from '@peertube/peertube-node-utils' import { createCipheriv, createDecipheriv, createSign, createVerify } from 'crypto' import { Request } from 'express' -import { cloneDeep } from 'lodash' -import { promisify1, promisify2 } from '@shared/core-utils' -import { sha256 } from '@shared/extra-utils' -import { BCRYPT_SALT_SIZE, ENCRYPTION, HTTP_SIGNATURE, PRIVATE_RSA_KEY_SIZE } from '../initializers/constants' -import { MActor } from '../types/models' -import { generateRSAKeyPairPromise, randomBytesPromise, scryptPromise } from './core-utils' -import { jsonld } from './custom-jsonld-signature' -import { logger } from './logger' - -const bcryptComparePromise = promisify2(compare) -const bcryptGenSaltPromise = promisify1(genSalt) -const bcryptHashPromise = promisify2(hash) - -const httpSignature = require('@peertube/http-signature') +import cloneDeep from 'lodash-es/cloneDeep.js' +import { BCRYPT_SALT_SIZE, ENCRYPTION, HTTP_SIGNATURE, PRIVATE_RSA_KEY_SIZE } from '../initializers/constants.js' +import { MActor } from '../types/models/index.js' +import { generateRSAKeyPairPromise, randomBytesPromise, scryptPromise } from './core-utils.js' +import { logger } from './logger.js' function createPrivateAndPublicKeys () { logger.info('Generating a RSA key...') @@ -26,16 +18,20 @@ function createPrivateAndPublicKeys () { // User password checks // --------------------------------------------------------------------------- -function comparePassword (plainPassword: string, hashPassword: string) { - if (!plainPassword) return Promise.resolve(false) +async function comparePassword (plainPassword: string, hashPassword: string) { + if (!plainPassword) return false - return bcryptComparePromise(plainPassword, hashPassword) + const { compare } = await import('bcrypt') + + return compare(plainPassword, hashPassword) } async function cryptPassword (password: string) { - const salt = await bcryptGenSaltPromise(BCRYPT_SALT_SIZE) + const { genSalt, hash } = await import('bcrypt') - return bcryptHashPromise(password, salt) + const salt = await genSalt(BCRYPT_SALT_SIZE) + + return hash(password, salt) } // --------------------------------------------------------------------------- @@ -98,7 +94,7 @@ async function isJsonLDRSA2017Verified (fromActor: MActor, signedDocument: any) return verify.verify(fromActor.publicKey, signedDocument.signature.signatureValue, 'base64') } -async function signJsonLDObject (byActor: MActor, data: T) { +async function signJsonLDObject (byActor: { url: string, privateKey: string }, data: T) { const signature = { type: 'RsaSignature2017', creator: byActor.url, @@ -176,12 +172,16 @@ export { // --------------------------------------------------------------------------- -function hashObject (obj: any): Promise { - return jsonld.promises.normalize(obj, { +async function hashObject (obj: any): Promise { + const { jsonld } = await import('./custom-jsonld-signature.js') + + const res = await (jsonld as any).promises.normalize(obj, { safe: false, algorithm: 'URDNA2015', format: 'application/n-quads' - }).then(res => sha256(res)) + }) + + return sha256(res) } function createSignatureHash (signature: any) { diff --git a/server/helpers/promise-cache.ts b/server/server/helpers/promise-cache.ts similarity index 100% rename from server/helpers/promise-cache.ts rename to server/server/helpers/promise-cache.ts diff --git a/server/helpers/proxy.ts b/server/server/helpers/proxy.ts similarity index 100% rename from server/helpers/proxy.ts rename to server/server/helpers/proxy.ts diff --git a/server/helpers/query.ts b/server/server/helpers/query.ts similarity index 94% rename from server/helpers/query.ts rename to server/server/helpers/query.ts index c0f78368f..7bd63f40e 100644 --- a/server/helpers/query.ts +++ b/server/server/helpers/query.ts @@ -1,10 +1,10 @@ -import { pick } from '@shared/core-utils' +import { pick } from '@peertube/peertube-core-utils' import { VideoChannelsSearchQueryAfterSanitize, VideoPlaylistsSearchQueryAfterSanitize, VideosCommonQueryAfterSanitize, VideosSearchQueryAfterSanitize -} from '@shared/models' +} from '@peertube/peertube-models' function pickCommonVideoQuery (query: VideosCommonQueryAfterSanitize) { return pick(query, [ diff --git a/server/helpers/regexp.ts b/server/server/helpers/regexp.ts similarity index 100% rename from server/helpers/regexp.ts rename to server/server/helpers/regexp.ts diff --git a/server/helpers/requests.ts b/server/server/helpers/requests.ts similarity index 82% rename from server/helpers/requests.ts rename to server/server/helpers/requests.ts index 1625d6e49..c7dd1172b 100644 --- a/server/helpers/requests.ts +++ b/server/server/helpers/requests.ts @@ -1,15 +1,15 @@ -import { createWriteStream, remove } from 'fs-extra' -import got, { CancelableRequest, NormalizedOptions, Options as GotOptions, RequestError, Response } from 'got' +import httpSignature from '@peertube/http-signature' +import { createWriteStream } from 'fs' +import { remove } from 'fs-extra/esm' +import got, { CancelableRequest, OptionsInit, OptionsOfTextResponseBody, OptionsOfUnknownResponseBody, RequestError, Response } from 'got' import { HttpProxyAgent, HttpsProxyAgent } from 'hpagent' -import { ACTIVITY_PUB, BINARY_CONTENT_TYPES, PEERTUBE_VERSION, REQUEST_TIMEOUTS, WEBSERVER } from '../initializers/constants' -import { pipelinePromise } from './core-utils' -import { logger, loggerTagsFactory } from './logger' -import { getProxy, isProxyEnabled } from './proxy' +import { ACTIVITY_PUB, BINARY_CONTENT_TYPES, PEERTUBE_VERSION, REQUEST_TIMEOUTS, WEBSERVER } from '../initializers/constants.js' +import { pipelinePromise } from './core-utils.js' +import { logger, loggerTagsFactory } from './logger.js' +import { getProxy, isProxyEnabled } from './proxy.js' const lTags = loggerTagsFactory('request') -const httpSignature = require('@peertube/http-signature') - export interface PeerTubeRequestError extends Error { statusCode?: number responseBody?: any @@ -33,7 +33,7 @@ type PeerTubeRequestOptions = { jsonResponse?: boolean followRedirect?: boolean -} & Pick +} & Pick const peertubeGot = got.extend({ ...getAgent(), @@ -75,7 +75,7 @@ const peertubeGot = got.extend({ beforeRequest: [ options => { const headers = options.headers || {} - headers['host'] = options.url.host + headers['host'] = buildUrl(options.url).host }, options => { @@ -83,7 +83,7 @@ const peertubeGot = got.extend({ if (httpSignatureOptions) { const method = options.method ?? 'GET' - const path = options.path ?? options.url.pathname + const path = buildUrl(options.url).pathname if (!method || !path) { throw new Error(`Cannot sign request without method (${method}) or path (${path}) ${options}`) @@ -109,7 +109,7 @@ const peertubeGot = got.extend({ ], beforeRetry: [ - (_options: NormalizedOptions, error: RequestError, retryCount: number) => { + (error: RequestError, retryCount: number) => { logger.debug('Retrying request to %s.', error.request.requestUrl, { retryCount, error: buildRequestError(error), ...lTags() }) } ] @@ -117,7 +117,7 @@ const peertubeGot = got.extend({ }) function doRequest (url: string, options: PeerTubeRequestOptions = {}) { - const gotOptions = buildGotOptions(options) + const gotOptions = buildGotOptions(options) as OptionsOfTextResponseBody return peertubeGot(url, gotOptions) .catch(err => { throw buildRequestError(err) }) @@ -141,7 +141,7 @@ async function doRequestAndSaveToFile ( try { await pipelinePromise( - peertubeGot.stream(url, gotOptions), + peertubeGot.stream(url, { ...gotOptions, isStream: true }), outFile ) } catch (err) { @@ -187,7 +187,7 @@ function isBinaryResponse (result: Response) { // --------------------------------------------------------------------------- export { - PeerTubeRequestOptions, + type PeerTubeRequestOptions, doRequest, doJSONRequest, @@ -199,7 +199,7 @@ export { // --------------------------------------------------------------------------- -function buildGotOptions (options: PeerTubeRequestOptions) { +function buildGotOptions (options: PeerTubeRequestOptions): OptionsOfUnknownResponseBody { const { activityPub, bodyKBLimit = 1000 } = options const context = { bodyKBLimit, httpSignature: options.httpSignature } @@ -217,11 +217,15 @@ function buildGotOptions (options: PeerTubeRequestOptions) { return { method: options.method, dnsCache: true, - timeout: options.timeout ?? REQUEST_TIMEOUTS.DEFAULT, + timeout: { + request: options.timeout ?? REQUEST_TIMEOUTS.DEFAULT + }, json: options.json, searchParams: options.searchParams, followRedirect: options.followRedirect, - retry: 2, + retry: { + limit: 2 + }, headers, context } @@ -244,3 +248,11 @@ function buildRequestError (error: RequestError) { return newError } + +function buildUrl (url: string | URL) { + if (typeof url === 'string') { + return new URL(url) + } + + return url +} diff --git a/server/helpers/stream-replacer.ts b/server/server/helpers/stream-replacer.ts similarity index 100% rename from server/helpers/stream-replacer.ts rename to server/server/helpers/stream-replacer.ts diff --git a/server/helpers/token-generator.ts b/server/server/helpers/token-generator.ts similarity index 84% rename from server/helpers/token-generator.ts rename to server/server/helpers/token-generator.ts index 16313b818..c7d52c41a 100644 --- a/server/helpers/token-generator.ts +++ b/server/server/helpers/token-generator.ts @@ -1,4 +1,4 @@ -import { buildUUID } from '@shared/extra-utils' +import { buildUUID } from '@peertube/peertube-node-utils' function generateRunnerRegistrationToken () { return 'ptrrt-' + buildUUID() diff --git a/server/helpers/upload.ts b/server/server/helpers/upload.ts similarity index 82% rename from server/helpers/upload.ts rename to server/server/helpers/upload.ts index f5f476913..1a182a1f6 100644 --- a/server/helpers/upload.ts +++ b/server/server/helpers/upload.ts @@ -1,5 +1,5 @@ import { join } from 'path' -import { DIRECTORIES } from '@server/initializers/constants' +import { DIRECTORIES } from '@server/initializers/constants.js' function getResumableUploadPath (filename?: string) { if (filename) return join(DIRECTORIES.RESUMABLE_UPLOAD, filename) diff --git a/server/helpers/utils.ts b/server/server/helpers/utils.ts similarity index 86% rename from server/helpers/utils.ts rename to server/server/helpers/utils.ts index 5a4fe4fdd..850286b61 100644 --- a/server/helpers/utils.ts +++ b/server/server/helpers/utils.ts @@ -1,11 +1,11 @@ -import { remove } from 'fs-extra' +import { remove } from 'fs-extra/esm' import { Instance as ParseTorrent } from 'parse-torrent' import { join } from 'path' -import { sha256 } from '@shared/extra-utils' -import { ResultList } from '@shared/models' -import { CONFIG } from '../initializers/config' -import { randomBytesPromise } from './core-utils' -import { logger } from './logger' +import { sha256 } from '@peertube/peertube-node-utils' +import { ResultList } from '@peertube/peertube-models' +import { CONFIG } from '../initializers/config.js' +import { randomBytesPromise } from './core-utils.js' +import { logger } from './logger.js' function deleteFileAndCatch (path: string) { remove(path) diff --git a/server/helpers/version.ts b/server/server/helpers/version.ts similarity index 88% rename from server/helpers/version.ts rename to server/server/helpers/version.ts index 5b3bf59dd..2608a36b7 100644 --- a/server/helpers/version.ts +++ b/server/server/helpers/version.ts @@ -1,5 +1,5 @@ -import { execPromise, execPromise2 } from './core-utils' -import { logger } from './logger' +import { execPromise, execPromise2 } from './core-utils.js' +import { logger } from './logger.js' async function getServerCommit () { try { diff --git a/server/helpers/video.ts b/server/server/helpers/video.ts similarity index 78% rename from server/helpers/video.ts rename to server/server/helpers/video.ts index c688ef1e3..dc56a6697 100644 --- a/server/helpers/video.ts +++ b/server/server/helpers/video.ts @@ -1,8 +1,8 @@ import { Response } from 'express' -import { CONFIG } from '@server/initializers/config' -import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo } from '@server/types/models' -import { VideoPrivacy, VideoState } from '@shared/models' -import { forceNumber } from '@shared/core-utils' +import { forceNumber } from '@peertube/peertube-core-utils' +import { VideoPrivacy, VideoPrivacyType, VideoState, VideoStateType } from '@peertube/peertube-models' +import { CONFIG } from '@server/initializers/config.js' +import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo } from '@server/types/models/index.js' function getVideoWithAttributes (res: Response) { return res.locals.videoAPI || res.locals.videoAll || res.locals.onlyVideo @@ -14,14 +14,14 @@ function extractVideo (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) { : videoOrPlaylist } -function isPrivacyForFederation (privacy: VideoPrivacy) { +function isPrivacyForFederation (privacy: VideoPrivacyType) { const castedPrivacy = forceNumber(privacy) return castedPrivacy === VideoPrivacy.PUBLIC || (CONFIG.FEDERATION.VIDEOS.FEDERATE_UNLISTED === true && castedPrivacy === VideoPrivacy.UNLISTED) } -function isStateForFederation (state: VideoState) { +function isStateForFederation (state: VideoStateType) { const castedState = forceNumber(state) return castedState === VideoState.PUBLISHED || castedState === VideoState.WAITING_FOR_LIVE || castedState === VideoState.LIVE_ENDED diff --git a/server/helpers/webtorrent.ts b/server/server/helpers/webtorrent.ts similarity index 87% rename from server/helpers/webtorrent.ts rename to server/server/helpers/webtorrent.ts index f33a7bccd..29062dae3 100644 --- a/server/helpers/webtorrent.ts +++ b/server/server/helpers/webtorrent.ts @@ -1,24 +1,27 @@ -import { decode, encode } from 'bencode' +import bencode from 'bencode' import createTorrent from 'create-torrent' -import { createWriteStream, ensureDir, pathExists, readFile, remove, writeFile } from 'fs-extra' +import { createWriteStream } from 'fs' +import { ensureDir, pathExists, remove } from 'fs-extra/esm' +import { readFile, writeFile } from 'fs/promises' import { encode as magnetUriEncode } from 'magnet-uri' import parseTorrent from 'parse-torrent' import { dirname, join } from 'path' import { pipeline } from 'stream' -import WebTorrent, { Instance, TorrentFile } from 'webtorrent' -import { isArray } from '@server/helpers/custom-validators/misc' -import { WEBSERVER } from '@server/initializers/constants' -import { generateTorrentFileName } from '@server/lib/paths' -import { VideoPathManager } from '@server/lib/video-path-manager' -import { MVideo } from '@server/types/models/video/video' -import { MVideoFile, MVideoFileRedundanciesOpt } from '@server/types/models/video/video-file' -import { MStreamingPlaylistVideo } from '@server/types/models/video/video-streaming-playlist' -import { promisify2 } from '@shared/core-utils' -import { sha1 } from '@shared/extra-utils' -import { CONFIG } from '../initializers/config' -import { logger } from './logger' -import { generateVideoImportTmpPath } from './utils' -import { extractVideo } from './video' +import { promisify2 } from '@peertube/peertube-core-utils' +import { isArray } from '@server/helpers/custom-validators/misc.js' +import { WEBSERVER } from '@server/initializers/constants.js' +import { generateTorrentFileName } from '@server/lib/paths.js' +import { VideoPathManager } from '@server/lib/video-path-manager.js' +import { MVideoFile, MVideoFileRedundanciesOpt } from '@server/types/models/video/video-file.js' +import { MStreamingPlaylistVideo } from '@server/types/models/video/video-streaming-playlist.js' +import { MVideo } from '@server/types/models/video/video.js' +import { sha1 } from '@peertube/peertube-node-utils' +import { CONFIG } from '../initializers/config.js' +import { logger } from './logger.js' +import { generateVideoImportTmpPath } from './utils.js' +import { extractVideo } from './video.js' + +import type { Instance, TorrentFile } from 'webtorrent' const createTorrentPromise = promisify2(createTorrent) @@ -32,8 +35,10 @@ async function downloadWebTorrentVideo (target: { uri: string, torrentName?: str const directoryPath = join(CONFIG.STORAGE.TMP_DIR, 'webtorrent') await ensureDir(directoryPath) + // eslint-disable-next-line new-cap + const webtorrent = new (await import('webtorrent')).default() + return new Promise((res, rej) => { - const webtorrent = new WebTorrent() let file: TorrentFile const torrentId = target.uri || join(CONFIG.STORAGE.TORRENTS_DIR, target.torrentName) @@ -140,7 +145,7 @@ async function updateTorrentMetadata (videoOrPlaylist: MVideo | MStreamingPlayli } const torrentContent = await readFile(oldTorrentPath) - const decoded = decode(torrentContent) + const decoded = bencode.decode(torrentContent) decoded['announce-list'] = buildAnnounceList() decoded.announce = decoded['announce-list'][0][0] @@ -155,11 +160,11 @@ async function updateTorrentMetadata (videoOrPlaylist: MVideo | MStreamingPlayli logger.info('Updating torrent metadata %s -> %s.', oldTorrentPath, newTorrentPath) - await writeFile(newTorrentPath, encode(decoded)) + await writeFile(newTorrentPath, bencode.encode(decoded)) await remove(oldTorrentPath) videoFile.torrentFilename = newTorrentFilename - videoFile.infoHash = sha1(encode(decoded.info)) + videoFile.infoHash = sha1(bencode.encode(decoded.info)) } function generateMagnetUri ( diff --git a/server/server/helpers/youtube-dl/index.ts b/server/server/helpers/youtube-dl/index.ts new file mode 100644 index 000000000..29a07d93f --- /dev/null +++ b/server/server/helpers/youtube-dl/index.ts @@ -0,0 +1,3 @@ +export * from './youtube-dl-cli.js' +export * from './youtube-dl-info-builder.js' +export * from './youtube-dl-wrapper.js' diff --git a/server/helpers/youtube-dl/youtube-dl-cli.ts b/server/server/helpers/youtube-dl/youtube-dl-cli.ts similarity index 93% rename from server/helpers/youtube-dl/youtube-dl-cli.ts rename to server/server/helpers/youtube-dl/youtube-dl-cli.ts index 765038cea..007f061c6 100644 --- a/server/helpers/youtube-dl/youtube-dl-cli.ts +++ b/server/server/helpers/youtube-dl/youtube-dl-cli.ts @@ -1,12 +1,13 @@ import execa from 'execa' -import { ensureDir, pathExists, writeFile } from 'fs-extra' +import { ensureDir, pathExists } from 'fs-extra/esm' +import { writeFile } from 'fs/promises' +import { OptionsOfBufferResponseBody } from 'got' import { dirname, join } from 'path' -import { CONFIG } from '@server/initializers/config' -import { VideoResolution } from '@shared/models' -import { logger, loggerTagsFactory } from '../logger' -import { getProxy, isProxyEnabled } from '../proxy' -import { isBinaryResponse, peertubeGot } from '../requests' -import { OptionsOfBufferResponseBody } from 'got/dist/source' +import { VideoResolution, VideoResolutionType } from '@peertube/peertube-models' +import { CONFIG } from '@server/initializers/config.js' +import { logger, loggerTagsFactory } from '../logger.js' +import { getProxy, isProxyEnabled } from '../proxy.js' +import { isBinaryResponse, peertubeGot } from '../requests.js' const lTags = loggerTagsFactory('youtube-dl') @@ -67,7 +68,7 @@ export class YoutubeDLCLI { } } - static getYoutubeDLVideoFormat (enabledResolutions: VideoResolution[], useBestFormat: boolean) { + static getYoutubeDLVideoFormat (enabledResolutions: VideoResolutionType[], useBestFormat: boolean) { /** * list of format selectors in order or preference * see https://github.com/ytdl-org/youtube-dl#format-selection diff --git a/server/helpers/youtube-dl/youtube-dl-info-builder.ts b/server/server/helpers/youtube-dl/youtube-dl-info-builder.ts similarity index 94% rename from server/helpers/youtube-dl/youtube-dl-info-builder.ts rename to server/server/helpers/youtube-dl/youtube-dl-info-builder.ts index a74904e43..0287f6183 100644 --- a/server/helpers/youtube-dl/youtube-dl-info-builder.ts +++ b/server/server/helpers/youtube-dl/youtube-dl-info-builder.ts @@ -1,8 +1,8 @@ -import { CONSTRAINTS_FIELDS, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES } from '../../initializers/constants' -import { peertubeTruncate } from '../core-utils' -import { isUrlValid } from '../custom-validators/activitypub/misc' +import { CONSTRAINTS_FIELDS, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES } from '../../initializers/constants.js' +import { peertubeTruncate } from '../core-utils.js' +import { isUrlValid } from '../custom-validators/activitypub/misc.js' -type YoutubeDLInfo = { +export type YoutubeDLInfo = { name?: string description?: string category?: number @@ -18,7 +18,7 @@ type YoutubeDLInfo = { urls?: string[] } -class YoutubeDLInfoBuilder { +export class YoutubeDLInfoBuilder { private readonly info: any constructor (info: any) { @@ -196,10 +196,3 @@ class YoutubeDLInfoBuilder { return VIDEO_LANGUAGES[language] ? language : undefined } } - -// --------------------------------------------------------------------------- - -export { - YoutubeDLInfo, - YoutubeDLInfoBuilder -} diff --git a/server/helpers/youtube-dl/youtube-dl-wrapper.ts b/server/server/helpers/youtube-dl/youtube-dl-wrapper.ts similarity index 90% rename from server/helpers/youtube-dl/youtube-dl-wrapper.ts rename to server/server/helpers/youtube-dl/youtube-dl-wrapper.ts index ac3cd190e..d5acb371a 100644 --- a/server/helpers/youtube-dl/youtube-dl-wrapper.ts +++ b/server/server/helpers/youtube-dl/youtube-dl-wrapper.ts @@ -1,12 +1,14 @@ -import { move, pathExists, readdir, remove } from 'fs-extra' +import { move, pathExists, remove } from 'fs-extra/esm' +import { readdir } from 'fs/promises' import { dirname, join } from 'path' import { inspect } from 'util' -import { CONFIG } from '@server/initializers/config' -import { isVideoFileExtnameValid } from '../custom-validators/videos' -import { logger, loggerTagsFactory } from '../logger' -import { generateVideoImportTmpPath } from '../utils' -import { YoutubeDLCLI } from './youtube-dl-cli' -import { YoutubeDLInfo, YoutubeDLInfoBuilder } from './youtube-dl-info-builder' +import { VideoResolutionType } from '@peertube/peertube-models' +import { CONFIG } from '@server/initializers/config.js' +import { isVideoFileExtnameValid } from '../custom-validators/videos.js' +import { logger, loggerTagsFactory } from '../logger.js' +import { generateVideoImportTmpPath } from '../utils.js' +import { YoutubeDLCLI } from './youtube-dl-cli.js' +import { YoutubeDLInfo, YoutubeDLInfoBuilder } from './youtube-dl-info-builder.js' const lTags = loggerTagsFactory('youtube-dl') @@ -24,7 +26,7 @@ class YoutubeDLWrapper { constructor ( private readonly url: string, - private readonly enabledResolutions: number[], + private readonly enabledResolutions: VideoResolutionType[], private readonly useBestFormat: boolean ) { diff --git a/server/initializers/checker-after-init.ts b/server/server/initializers/checker-after-init.ts similarity index 93% rename from server/initializers/checker-after-init.ts rename to server/server/initializers/checker-after-init.ts index 4281e2bb5..afcf6176b 100644 --- a/server/initializers/checker-after-init.ts +++ b/server/server/initializers/checker-after-init.ts @@ -1,18 +1,18 @@ import config from 'config' -import { readFileSync, writeFileSync } from 'fs-extra' +import { readFileSync, writeFileSync } from 'fs' import { URL } from 'url' -import { uniqify } from '@shared/core-utils' -import { getFFmpegVersion } from '@shared/ffmpeg' -import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type' -import { RecentlyAddedStrategy } from '../../shared/models/redundancy' -import { isProdInstance, parseBytes, parseSemVersion } from '../helpers/core-utils' -import { isArray } from '../helpers/custom-validators/misc' -import { logger } from '../helpers/logger' -import { ApplicationModel, getServerActor } from '../models/application/application' -import { OAuthClientModel } from '../models/oauth/oauth-client' -import { UserModel } from '../models/user/user' -import { CONFIG, getLocalConfigFilePath, isEmailEnabled, reloadConfig } from './config' -import { WEBSERVER } from './constants' +import { uniqify } from '@peertube/peertube-core-utils' +import { getFFmpegVersion } from '@peertube/peertube-ffmpeg' +import { RecentlyAddedStrategy, VideoRedundancyConfigFilter } from '@peertube/peertube-models' +import { isProdInstance } from '@peertube/peertube-node-utils' +import { parseBytes, parseSemVersion } from '../helpers/core-utils.js' +import { isArray } from '../helpers/custom-validators/misc.js' +import { logger } from '../helpers/logger.js' +import { ApplicationModel, getServerActor } from '../models/application/application.js' +import { OAuthClientModel } from '../models/oauth/oauth-client.js' +import { UserModel } from '../models/user/user.js' +import { CONFIG, getLocalConfigFilePath, isEmailEnabled, reloadConfig } from './config.js' +import { WEBSERVER } from './constants.js' async function checkActivityPubUrls () { const actor = await getServerActor() @@ -124,6 +124,7 @@ function checkRemovedConfigKeys () { writeFileSync(localConfigPath, content.replace('"webtorrent"', '"web_videos"'), { encoding: 'utf-8' }) reloadConfig() + .catch(err => logger.error('Cannot reload configuration', { err })) } catch (err) { logger.error('Cannot write new configuration to file ' + localConfigPath, { err }) } diff --git a/server/initializers/checker-before-init.ts b/server/server/initializers/checker-before-init.ts similarity index 96% rename from server/initializers/checker-before-init.ts rename to server/server/initializers/checker-before-init.ts index 0139ded4f..f33da0914 100644 --- a/server/initializers/checker-before-init.ts +++ b/server/server/initializers/checker-before-init.ts @@ -1,10 +1,7 @@ -import { IConfig } from 'config' -import { promisify0 } from '@shared/core-utils' -import { parseSemVersion } from '../helpers/core-utils' -import { logger } from '../helpers/logger' - -// Special behaviour for config because we can reload it -const config: IConfig = require('config') +import config from 'config' +import { promisify0 } from '@peertube/peertube-core-utils' +import { parseSemVersion } from '../helpers/core-utils.js' +import { logger } from '../helpers/logger.js' // ONLY USE CORE MODULES IN THIS FILE! @@ -126,7 +123,7 @@ function checkMissedConfig () { async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) { if (CONFIG.TRANSCODING.ENABLED === false) return undefined - const Ffmpeg = require('fluent-ffmpeg') + const Ffmpeg = (await import('fluent-ffmpeg')).default const getAvailableCodecsPromise = promisify0(Ffmpeg.getAvailableCodecs) const codecs = await getAvailableCodecsPromise() const canEncode = [ 'libx264' ] diff --git a/server/initializers/config.ts b/server/server/initializers/config.ts similarity index 97% rename from server/initializers/config.ts rename to server/server/initializers/config.ts index 3e3b8ad1f..dd196ea0c 100644 --- a/server/initializers/config.ts +++ b/server/server/initializers/config.ts @@ -1,15 +1,19 @@ import bytes from 'bytes' import { IConfig } from 'config' +import { createRequire } from 'module' import { dirname, join } from 'path' -import { decacheModule } from '@server/helpers/decache' -import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type' -import { BroadcastMessageLevel } from '@shared/models/server' -import { buildPath, root } from '../../shared/core-utils' -import { VideoPrivacy, VideosRedundancyStrategy } from '../../shared/models' -import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' -import { parseBytes, parseDurationToMs } from '../helpers/core-utils' +import { + BroadcastMessageLevel, + NSFWPolicyType, + VideoPrivacyType, + VideoRedundancyConfigFilter, + VideosRedundancyStrategy +} from '@peertube/peertube-models' +import { decacheModule } from '@server/helpers/decache.js' +import { buildPath, root } from '@peertube/peertube-node-utils' +import { parseBytes, parseDurationToMs } from '../helpers/core-utils.js' -// Use a variable to reload the configuration if we need +const require = createRequire(import.meta.url) let config: IConfig = require('config') const configChangedHandlers: Function[] = [] @@ -89,7 +93,7 @@ const CONFIG = { PUBLISH: { DOWNLOAD_ENABLED: config.get('defaults.publish.download_enabled'), COMMENTS_ENABLED: config.get('defaults.publish.comments_enabled'), - PRIVACY: config.get('defaults.publish.privacy'), + PRIVACY: config.get('defaults.publish.privacy'), LICENCE: config.get('defaults.publish.licence') }, P2P: { @@ -620,10 +624,15 @@ function getLocalConfigFilePath () { return join(localConfigDir, filename + '.json') } +function getConfigModule () { + return config +} + // --------------------------------------------------------------------------- export { CONFIG, + getConfigModule, getLocalConfigFilePath, registerConfigChangedHandler, isEmailEnabled @@ -675,7 +684,7 @@ export function reloadConfig () { delete require.cache[fileName] } - decacheModule('config') + decacheModule(require, 'config') } purge() @@ -685,4 +694,6 @@ export function reloadConfig () { for (const configChangedHandler of configChangedHandlers) { configChangedHandler() } + + return Promise.resolve() } diff --git a/server/initializers/constants.ts b/server/server/initializers/constants.ts similarity index 95% rename from server/initializers/constants.ts rename to server/server/initializers/constants.ts index de5f11f8f..34392dbc8 100644 --- a/server/initializers/constants.ts +++ b/server/server/initializers/constants.ts @@ -1,29 +1,42 @@ -import { RepeatOptions } from 'bullmq' -import { Encoding, randomBytes } from 'crypto' -import { invert } from 'lodash' -import { join } from 'path' -import { randomInt, root } from '@shared/core-utils' +import { randomInt } from '@peertube/peertube-core-utils' import { AbuseState, + AbuseStateType, + ActivityPubActorType, + ActorImageType, + ActorImageType_Type, + FollowState, JobType, + NSFWPolicyType, RunnerJobState, + RunnerJobStateType, UserRegistrationState, + UserRegistrationStateType, VideoChannelSyncState, + VideoChannelSyncStateType, VideoImportState, + VideoImportStateType, + VideoPlaylistPrivacy, + VideoPlaylistPrivacyType, + VideoPlaylistType, + VideoPlaylistType_Type, VideoPrivacy, + VideoPrivacyType, VideoRateType, VideoResolution, VideoState, + VideoStateType, VideoTranscodingFPS -} from '../../shared/models' -import { ActivityPubActorType } from '../../shared/models/activitypub' -import { ActorImageType, FollowState } from '../../shared/models/actors' -import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' -import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model' -import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model' +} from '@peertube/peertube-models' +import { isTestInstance, isTestOrDevInstance, root } from '@peertube/peertube-node-utils' +import { RepeatOptions } from 'bullmq' +import { Encoding, randomBytes } from 'crypto' +import { readJsonSync } from 'fs-extra/esm' +import invert from 'lodash-es/invert.js' +import { join } from 'path' // Do not use barrels, remain constants as independent as possible -import { isTestInstance, isTestOrDevInstance, parseDurationToMs, sanitizeHost, sanitizeUrl } from '../helpers/core-utils' -import { CONFIG, registerConfigChangedHandler } from './config' +import { parseDurationToMs, sanitizeHost, sanitizeUrl } from '../helpers/core-utils.js' +import { CONFIG, registerConfigChangedHandler } from './config.js' // --------------------------------------------------------------------------- @@ -32,7 +45,7 @@ const LAST_MIGRATION_VERSION = 800 // --------------------------------------------------------------------------- const API_VERSION = 'v1' -const PEERTUBE_VERSION: string = require(join(root(), 'package.json')).version +const PEERTUBE_VERSION: string = readJsonSync(join(root(), 'package.json')).version const PAGINATION = { GLOBAL: { @@ -524,7 +537,7 @@ const VIDEO_LICENCES = { const VIDEO_LANGUAGES: { [id: string]: string } = {} -const VIDEO_PRIVACIES: { [ id in VideoPrivacy ]: string } = { +const VIDEO_PRIVACIES: { [ id in VideoPrivacyType ]: string } = { [VideoPrivacy.PUBLIC]: 'Public', [VideoPrivacy.UNLISTED]: 'Unlisted', [VideoPrivacy.PRIVATE]: 'Private', @@ -532,7 +545,7 @@ const VIDEO_PRIVACIES: { [ id in VideoPrivacy ]: string } = { [VideoPrivacy.PASSWORD_PROTECTED]: 'Password protected' } -const VIDEO_STATES: { [ id in VideoState ]: string } = { +const VIDEO_STATES: { [ id in VideoStateType ]: string } = { [VideoState.PUBLISHED]: 'Published', [VideoState.TO_TRANSCODE]: 'To transcode', [VideoState.TO_IMPORT]: 'To import', @@ -544,7 +557,7 @@ const VIDEO_STATES: { [ id in VideoState ]: string } = { [VideoState.TO_EDIT]: 'To edit*' } -const VIDEO_IMPORT_STATES: { [ id in VideoImportState ]: string } = { +const VIDEO_IMPORT_STATES: { [ id in VideoImportStateType ]: string } = { [VideoImportState.FAILED]: 'Failed', [VideoImportState.PENDING]: 'Pending', [VideoImportState.SUCCESS]: 'Success', @@ -553,37 +566,37 @@ const VIDEO_IMPORT_STATES: { [ id in VideoImportState ]: string } = { [VideoImportState.PROCESSING]: 'Processing' } -const VIDEO_CHANNEL_SYNC_STATE: { [ id in VideoChannelSyncState ]: string } = { +const VIDEO_CHANNEL_SYNC_STATE: { [ id in VideoChannelSyncStateType ]: string } = { [VideoChannelSyncState.FAILED]: 'Failed', [VideoChannelSyncState.SYNCED]: 'Synchronized', [VideoChannelSyncState.PROCESSING]: 'Processing', [VideoChannelSyncState.WAITING_FIRST_RUN]: 'Waiting first run' } -const ABUSE_STATES: { [ id in AbuseState ]: string } = { +const ABUSE_STATES: { [ id in AbuseStateType ]: string } = { [AbuseState.PENDING]: 'Pending', [AbuseState.REJECTED]: 'Rejected', [AbuseState.ACCEPTED]: 'Accepted' } -const USER_REGISTRATION_STATES: { [ id in UserRegistrationState ]: string } = { +const USER_REGISTRATION_STATES: { [ id in UserRegistrationStateType ]: string } = { [UserRegistrationState.PENDING]: 'Pending', [UserRegistrationState.REJECTED]: 'Rejected', [UserRegistrationState.ACCEPTED]: 'Accepted' } -const VIDEO_PLAYLIST_PRIVACIES: { [ id in VideoPlaylistPrivacy ]: string } = { +const VIDEO_PLAYLIST_PRIVACIES: { [ id in VideoPlaylistPrivacyType ]: string } = { [VideoPlaylistPrivacy.PUBLIC]: 'Public', [VideoPlaylistPrivacy.UNLISTED]: 'Unlisted', [VideoPlaylistPrivacy.PRIVATE]: 'Private' } -const VIDEO_PLAYLIST_TYPES: { [ id in VideoPlaylistType ]: string } = { +const VIDEO_PLAYLIST_TYPES: { [ id in VideoPlaylistType_Type ]: string } = { [VideoPlaylistType.REGULAR]: 'Regular', [VideoPlaylistType.WATCH_LATER]: 'Watch later' } -const RUNNER_JOB_STATES: { [ id in RunnerJobState ]: string } = { +const RUNNER_JOB_STATES: { [ id in RunnerJobStateType ]: string } = { [RunnerJobState.PROCESSING]: 'Processing', [RunnerJobState.COMPLETED]: 'Completed', [RunnerJobState.COMPLETING]: 'Completing', @@ -808,7 +821,7 @@ const PREVIEWS_SIZE = { height: 480, minWidth: 400 } -const ACTOR_IMAGES_SIZE: { [key in ActorImageType]: { width: number, height: number }[] } = { +const ACTOR_IMAGES_SIZE: { [key in ActorImageType_Type]: { width: number, height: number }[] } = { [ActorImageType.AVATAR]: [ { width: 120, @@ -1326,12 +1339,14 @@ function buildMimetypesRegex (obj: { [id: string]: string | string[] }) { .join('|') } -function loadLanguages () { - Object.assign(VIDEO_LANGUAGES, buildLanguages()) +async function loadLanguages () { + if (Object.keys(VIDEO_LANGUAGES).length !== 0) return + + Object.assign(VIDEO_LANGUAGES, await buildLanguages()) } -function buildLanguages () { - const iso639 = require('iso-639-3') +async function buildLanguages () { + const { iso6393 } = await import('iso-639-3') const languages: { [id: string]: string } = {} @@ -1366,7 +1381,7 @@ function buildLanguages () { } // Only add ISO639-1 languages and some sign languages (ISO639-3) - iso639 + iso6393 .filter(l => { return (l.iso6391 !== undefined && l.type === 'living') || additionalLanguages[l.iso6393] === true diff --git a/server/initializers/database.ts b/server/server/initializers/database.ts similarity index 75% rename from server/initializers/database.ts rename to server/server/initializers/database.ts index bc120e398..fe399a633 100644 --- a/server/initializers/database.ts +++ b/server/server/initializers/database.ts @@ -1,65 +1,66 @@ +import pg from 'pg' import { QueryTypes, Transaction } from 'sequelize' import { Sequelize as SequelizeTypescript } from 'sequelize-typescript' -import { ActorCustomPageModel } from '@server/models/account/actor-custom-page' -import { RunnerModel } from '@server/models/runner/runner' -import { RunnerJobModel } from '@server/models/runner/runner-job' -import { RunnerRegistrationTokenModel } from '@server/models/runner/runner-registration-token' -import { TrackerModel } from '@server/models/server/tracker' -import { VideoTrackerModel } from '@server/models/server/video-tracker' -import { UserModel } from '@server/models/user/user' -import { UserNotificationModel } from '@server/models/user/user-notification' -import { UserRegistrationModel } from '@server/models/user/user-registration' -import { UserVideoHistoryModel } from '@server/models/user/user-video-history' -import { StoryboardModel } from '@server/models/video/storyboard' -import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync' -import { VideoJobInfoModel } from '@server/models/video/video-job-info' -import { VideoLiveReplaySettingModel } from '@server/models/video/video-live-replay-setting' -import { VideoLiveSessionModel } from '@server/models/video/video-live-session' -import { VideoSourceModel } from '@server/models/video/video-source' -import { LocalVideoViewerModel } from '@server/models/view/local-video-viewer' -import { LocalVideoViewerWatchSectionModel } from '@server/models/view/local-video-viewer-watch-section' -import { isTestOrDevInstance } from '../helpers/core-utils' -import { logger } from '../helpers/logger' -import { AbuseModel } from '../models/abuse/abuse' -import { AbuseMessageModel } from '../models/abuse/abuse-message' -import { VideoAbuseModel } from '../models/abuse/video-abuse' -import { VideoCommentAbuseModel } from '../models/abuse/video-comment-abuse' -import { AccountModel } from '../models/account/account' -import { AccountBlocklistModel } from '../models/account/account-blocklist' -import { AccountVideoRateModel } from '../models/account/account-video-rate' -import { ActorModel } from '../models/actor/actor' -import { ActorFollowModel } from '../models/actor/actor-follow' -import { ActorImageModel } from '../models/actor/actor-image' -import { ApplicationModel } from '../models/application/application' -import { OAuthClientModel } from '../models/oauth/oauth-client' -import { OAuthTokenModel } from '../models/oauth/oauth-token' -import { VideoRedundancyModel } from '../models/redundancy/video-redundancy' -import { PluginModel } from '../models/server/plugin' -import { ServerModel } from '../models/server/server' -import { ServerBlocklistModel } from '../models/server/server-blocklist' -import { UserNotificationSettingModel } from '../models/user/user-notification-setting' -import { ScheduleVideoUpdateModel } from '../models/video/schedule-video-update' -import { TagModel } from '../models/video/tag' -import { ThumbnailModel } from '../models/video/thumbnail' -import { VideoModel } from '../models/video/video' -import { VideoBlacklistModel } from '../models/video/video-blacklist' -import { VideoCaptionModel } from '../models/video/video-caption' -import { VideoChangeOwnershipModel } from '../models/video/video-change-ownership' -import { VideoChannelModel } from '../models/video/video-channel' -import { VideoCommentModel } from '../models/video/video-comment' -import { VideoFileModel } from '../models/video/video-file' -import { VideoImportModel } from '../models/video/video-import' -import { VideoLiveModel } from '../models/video/video-live' -import { VideoPlaylistModel } from '../models/video/video-playlist' -import { VideoPlaylistElementModel } from '../models/video/video-playlist-element' -import { VideoShareModel } from '../models/video/video-share' -import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' -import { VideoTagModel } from '../models/video/video-tag' -import { VideoViewModel } from '../models/view/video-view' -import { CONFIG } from './config' -import { VideoPasswordModel } from '@server/models/video/video-password' +import { isTestOrDevInstance } from '@peertube/peertube-node-utils' +import { ActorCustomPageModel } from '@server/models/account/actor-custom-page.js' +import { RunnerJobModel } from '@server/models/runner/runner-job.js' +import { RunnerRegistrationTokenModel } from '@server/models/runner/runner-registration-token.js' +import { RunnerModel } from '@server/models/runner/runner.js' +import { TrackerModel } from '@server/models/server/tracker.js' +import { VideoTrackerModel } from '@server/models/server/video-tracker.js' +import { UserNotificationModel } from '@server/models/user/user-notification.js' +import { UserRegistrationModel } from '@server/models/user/user-registration.js' +import { UserVideoHistoryModel } from '@server/models/user/user-video-history.js' +import { UserModel } from '@server/models/user/user.js' +import { StoryboardModel } from '@server/models/video/storyboard.js' +import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync.js' +import { VideoJobInfoModel } from '@server/models/video/video-job-info.js' +import { VideoLiveReplaySettingModel } from '@server/models/video/video-live-replay-setting.js' +import { VideoLiveSessionModel } from '@server/models/video/video-live-session.js' +import { VideoPasswordModel } from '@server/models/video/video-password.js' +import { VideoSourceModel } from '@server/models/video/video-source.js' +import { LocalVideoViewerWatchSectionModel } from '@server/models/view/local-video-viewer-watch-section.js' +import { LocalVideoViewerModel } from '@server/models/view/local-video-viewer.js' +import { logger } from '../helpers/logger.js' +import { AbuseMessageModel } from '../models/abuse/abuse-message.js' +import { AbuseModel } from '../models/abuse/abuse.js' +import { VideoAbuseModel } from '../models/abuse/video-abuse.js' +import { VideoCommentAbuseModel } from '../models/abuse/video-comment-abuse.js' +import { AccountBlocklistModel } from '../models/account/account-blocklist.js' +import { AccountVideoRateModel } from '../models/account/account-video-rate.js' +import { AccountModel } from '../models/account/account.js' +import { ActorFollowModel } from '../models/actor/actor-follow.js' +import { ActorImageModel } from '../models/actor/actor-image.js' +import { ActorModel } from '../models/actor/actor.js' +import { ApplicationModel } from '../models/application/application.js' +import { OAuthClientModel } from '../models/oauth/oauth-client.js' +import { OAuthTokenModel } from '../models/oauth/oauth-token.js' +import { VideoRedundancyModel } from '../models/redundancy/video-redundancy.js' +import { PluginModel } from '../models/server/plugin.js' +import { ServerBlocklistModel } from '../models/server/server-blocklist.js' +import { ServerModel } from '../models/server/server.js' +import { UserNotificationSettingModel } from '../models/user/user-notification-setting.js' +import { ScheduleVideoUpdateModel } from '../models/video/schedule-video-update.js' +import { TagModel } from '../models/video/tag.js' +import { ThumbnailModel } from '../models/video/thumbnail.js' +import { VideoBlacklistModel } from '../models/video/video-blacklist.js' +import { VideoCaptionModel } from '../models/video/video-caption.js' +import { VideoChangeOwnershipModel } from '../models/video/video-change-ownership.js' +import { VideoChannelModel } from '../models/video/video-channel.js' +import { VideoCommentModel } from '../models/video/video-comment.js' +import { VideoFileModel } from '../models/video/video-file.js' +import { VideoImportModel } from '../models/video/video-import.js' +import { VideoLiveModel } from '../models/video/video-live.js' +import { VideoPlaylistElementModel } from '../models/video/video-playlist-element.js' +import { VideoPlaylistModel } from '../models/video/video-playlist.js' +import { VideoShareModel } from '../models/video/video-share.js' +import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist.js' +import { VideoTagModel } from '../models/video/video-tag.js' +import { VideoModel } from '../models/video/video.js' +import { VideoViewModel } from '../models/view/video-view.js' +import { CONFIG } from './config.js' -require('pg').defaults.parseInt8 = true // Avoid BIGINT to be converted to string +pg.defaults.parseInt8 = true // Avoid BIGINT to be converted to string const dbname = CONFIG.DATABASE.DBNAME const username = CONFIG.DATABASE.USERNAME diff --git a/server/initializers/installer.ts b/server/server/initializers/installer.ts similarity index 89% rename from server/initializers/installer.ts rename to server/server/initializers/installer.ts index 2406a5936..ff25f1909 100644 --- a/server/initializers/installer.ts +++ b/server/server/initializers/installer.ts @@ -1,19 +1,20 @@ -import { ensureDir, readdir, remove } from 'fs-extra' +import { ensureDir, remove } from 'fs-extra/esm' +import { readdir } from 'fs/promises' import passwordGenerator from 'password-generator' import { join } from 'path' -import { isTestOrDevInstance } from '@server/helpers/core-utils' -import { generateRunnerRegistrationToken } from '@server/helpers/token-generator' -import { getNodeABIVersion } from '@server/helpers/version' -import { RunnerRegistrationTokenModel } from '@server/models/runner/runner-registration-token' -import { UserRole } from '@shared/models' -import { logger } from '../helpers/logger' -import { buildUser, createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user' -import { ApplicationModel } from '../models/application/application' -import { OAuthClientModel } from '../models/oauth/oauth-client' -import { applicationExist, clientsExist, usersExist } from './checker-after-init' -import { CONFIG } from './config' -import { DIRECTORIES, FILES_CACHE, LAST_MIGRATION_VERSION } from './constants' -import { sequelizeTypescript } from './database' +import { UserRole } from '@peertube/peertube-models' +import { isTestOrDevInstance } from '@peertube/peertube-node-utils' +import { generateRunnerRegistrationToken } from '@server/helpers/token-generator.js' +import { getNodeABIVersion } from '@server/helpers/version.js' +import { RunnerRegistrationTokenModel } from '@server/models/runner/runner-registration-token.js' +import { logger } from '../helpers/logger.js' +import { buildUser, createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user.js' +import { ApplicationModel } from '../models/application/application.js' +import { OAuthClientModel } from '../models/oauth/oauth-client.js' +import { applicationExist, clientsExist, usersExist } from './checker-after-init.js' +import { CONFIG } from './config.js' +import { DIRECTORIES, FILES_CACHE, LAST_MIGRATION_VERSION } from './constants.js' +import { sequelizeTypescript } from './database.js' async function installApplication () { try { diff --git a/server/initializers/migrations/0505-user-last-login-date.ts b/server/server/initializers/migrations/0505-user-last-login-date.ts similarity index 100% rename from server/initializers/migrations/0505-user-last-login-date.ts rename to server/server/initializers/migrations/0505-user-last-login-date.ts diff --git a/server/initializers/migrations/0510-video-file-metadata.ts b/server/server/initializers/migrations/0510-video-file-metadata.ts similarity index 100% rename from server/initializers/migrations/0510-video-file-metadata.ts rename to server/server/initializers/migrations/0510-video-file-metadata.ts diff --git a/server/initializers/migrations/0515-video-abuse-reason-timestamps.ts b/server/server/initializers/migrations/0515-video-abuse-reason-timestamps.ts similarity index 100% rename from server/initializers/migrations/0515-video-abuse-reason-timestamps.ts rename to server/server/initializers/migrations/0515-video-abuse-reason-timestamps.ts diff --git a/server/initializers/migrations/0520-abuses-split.ts b/server/server/initializers/migrations/0520-abuses-split.ts similarity index 100% rename from server/initializers/migrations/0520-abuses-split.ts rename to server/server/initializers/migrations/0520-abuses-split.ts diff --git a/server/initializers/migrations/0525-abuse-messages.ts b/server/server/initializers/migrations/0525-abuse-messages.ts similarity index 100% rename from server/initializers/migrations/0525-abuse-messages.ts rename to server/server/initializers/migrations/0525-abuse-messages.ts diff --git a/server/initializers/migrations/0530-playlist-multiple-video.ts b/server/server/initializers/migrations/0530-playlist-multiple-video.ts similarity index 96% rename from server/initializers/migrations/0530-playlist-multiple-video.ts rename to server/server/initializers/migrations/0530-playlist-multiple-video.ts index 51a8c06b0..a53b93fd7 100644 --- a/server/initializers/migrations/0530-playlist-multiple-video.ts +++ b/server/server/initializers/migrations/0530-playlist-multiple-video.ts @@ -1,5 +1,5 @@ import * as Sequelize from 'sequelize' -import { WEBSERVER } from '../constants' +import { WEBSERVER } from '../constants.js' async function up (utils: { transaction: Sequelize.Transaction diff --git a/server/initializers/migrations/0535-video-live.ts b/server/server/initializers/migrations/0535-video-live.ts similarity index 100% rename from server/initializers/migrations/0535-video-live.ts rename to server/server/initializers/migrations/0535-video-live.ts diff --git a/server/initializers/migrations/0540-video-file-infohash.ts b/server/server/initializers/migrations/0540-video-file-infohash.ts similarity index 100% rename from server/initializers/migrations/0540-video-file-infohash.ts rename to server/server/initializers/migrations/0540-video-file-infohash.ts diff --git a/server/initializers/migrations/0545-video-live-save-replay.ts b/server/server/initializers/migrations/0545-video-live-save-replay.ts similarity index 100% rename from server/initializers/migrations/0545-video-live-save-replay.ts rename to server/server/initializers/migrations/0545-video-live-save-replay.ts diff --git a/server/initializers/migrations/0550-actor-follow-cleanup.ts b/server/server/initializers/migrations/0550-actor-follow-cleanup.ts similarity index 100% rename from server/initializers/migrations/0550-actor-follow-cleanup.ts rename to server/server/initializers/migrations/0550-actor-follow-cleanup.ts diff --git a/server/initializers/migrations/0555-actor-follow-url.ts b/server/server/initializers/migrations/0555-actor-follow-url.ts similarity index 100% rename from server/initializers/migrations/0555-actor-follow-url.ts rename to server/server/initializers/migrations/0555-actor-follow-url.ts diff --git a/server/initializers/migrations/0560-user-feed-token.ts b/server/server/initializers/migrations/0560-user-feed-token.ts similarity index 95% rename from server/initializers/migrations/0560-user-feed-token.ts rename to server/server/initializers/migrations/0560-user-feed-token.ts index 4c85b04f7..f2ec9c91d 100644 --- a/server/initializers/migrations/0560-user-feed-token.ts +++ b/server/server/initializers/migrations/0560-user-feed-token.ts @@ -1,5 +1,5 @@ import * as Sequelize from 'sequelize' -import { buildUUID } from '@shared/extra-utils' +import { buildUUID } from '@peertube/peertube-node-utils' async function up (utils: { transaction: Sequelize.Transaction diff --git a/server/initializers/migrations/0565-actor-follow-local-url.ts b/server/server/initializers/migrations/0565-actor-follow-local-url.ts similarity index 100% rename from server/initializers/migrations/0565-actor-follow-local-url.ts rename to server/server/initializers/migrations/0565-actor-follow-local-url.ts diff --git a/server/initializers/migrations/0570-permanent-live.ts b/server/server/initializers/migrations/0570-permanent-live.ts similarity index 100% rename from server/initializers/migrations/0570-permanent-live.ts rename to server/server/initializers/migrations/0570-permanent-live.ts diff --git a/server/initializers/migrations/0575-duplicate-thumbnail.ts b/server/server/initializers/migrations/0575-duplicate-thumbnail.ts similarity index 100% rename from server/initializers/migrations/0575-duplicate-thumbnail.ts rename to server/server/initializers/migrations/0575-duplicate-thumbnail.ts diff --git a/server/initializers/migrations/0580-caption-filename.ts b/server/server/initializers/migrations/0580-caption-filename.ts similarity index 100% rename from server/initializers/migrations/0580-caption-filename.ts rename to server/server/initializers/migrations/0580-caption-filename.ts diff --git a/server/initializers/migrations/0585-video-file-names.ts b/server/server/initializers/migrations/0585-video-file-names.ts similarity index 100% rename from server/initializers/migrations/0585-video-file-names.ts rename to server/server/initializers/migrations/0585-video-file-names.ts diff --git a/server/initializers/migrations/0590-trackers.ts b/server/server/initializers/migrations/0590-trackers.ts similarity index 100% rename from server/initializers/migrations/0590-trackers.ts rename to server/server/initializers/migrations/0590-trackers.ts diff --git a/server/initializers/migrations/0595-remote-url.ts b/server/server/initializers/migrations/0595-remote-url.ts similarity index 100% rename from server/initializers/migrations/0595-remote-url.ts rename to server/server/initializers/migrations/0595-remote-url.ts diff --git a/server/initializers/migrations/0600-duplicate-video-files.ts b/server/server/initializers/migrations/0600-duplicate-video-files.ts similarity index 100% rename from server/initializers/migrations/0600-duplicate-video-files.ts rename to server/server/initializers/migrations/0600-duplicate-video-files.ts diff --git a/server/initializers/migrations/0605-actor-missing-keys.ts b/server/server/initializers/migrations/0605-actor-missing-keys.ts similarity index 93% rename from server/initializers/migrations/0605-actor-missing-keys.ts rename to server/server/initializers/migrations/0605-actor-missing-keys.ts index aa89a500c..3ef95ea22 100644 --- a/server/initializers/migrations/0605-actor-missing-keys.ts +++ b/server/server/initializers/migrations/0605-actor-missing-keys.ts @@ -1,6 +1,6 @@ import * as Sequelize from 'sequelize' -import { generateRSAKeyPairPromise } from '../../helpers/core-utils' -import { PRIVATE_RSA_KEY_SIZE } from '../constants' +import { generateRSAKeyPairPromise } from '../../helpers/core-utils.js' +import { PRIVATE_RSA_KEY_SIZE } from '../constants.js' async function up (utils: { transaction: Sequelize.Transaction diff --git a/server/initializers/migrations/0610-views-index copy.ts b/server/server/initializers/migrations/0610-views-index copy.ts similarity index 100% rename from server/initializers/migrations/0610-views-index copy.ts rename to server/server/initializers/migrations/0610-views-index copy.ts diff --git a/server/initializers/migrations/0612-captions-unique.ts b/server/server/initializers/migrations/0612-captions-unique.ts similarity index 100% rename from server/initializers/migrations/0612-captions-unique.ts rename to server/server/initializers/migrations/0612-captions-unique.ts diff --git a/server/initializers/migrations/0615-latest-versions-notification-settings.ts b/server/server/initializers/migrations/0615-latest-versions-notification-settings.ts similarity index 100% rename from server/initializers/migrations/0615-latest-versions-notification-settings.ts rename to server/server/initializers/migrations/0615-latest-versions-notification-settings.ts diff --git a/server/initializers/migrations/0620-latest-versions-application.ts b/server/server/initializers/migrations/0620-latest-versions-application.ts similarity index 100% rename from server/initializers/migrations/0620-latest-versions-application.ts rename to server/server/initializers/migrations/0620-latest-versions-application.ts diff --git a/server/initializers/migrations/0625-latest-versions-notification.ts b/server/server/initializers/migrations/0625-latest-versions-notification.ts similarity index 100% rename from server/initializers/migrations/0625-latest-versions-notification.ts rename to server/server/initializers/migrations/0625-latest-versions-notification.ts diff --git a/server/initializers/migrations/0630-banner.ts b/server/server/initializers/migrations/0630-banner.ts similarity index 100% rename from server/initializers/migrations/0630-banner.ts rename to server/server/initializers/migrations/0630-banner.ts diff --git a/server/initializers/migrations/0635-actor-image-size.ts b/server/server/initializers/migrations/0635-actor-image-size.ts similarity index 100% rename from server/initializers/migrations/0635-actor-image-size.ts rename to server/server/initializers/migrations/0635-actor-image-size.ts diff --git a/server/initializers/migrations/0640-unique-keys.ts b/server/server/initializers/migrations/0640-unique-keys.ts similarity index 100% rename from server/initializers/migrations/0640-unique-keys.ts rename to server/server/initializers/migrations/0640-unique-keys.ts diff --git a/server/initializers/migrations/0645-actor-remote-creation-date.ts b/server/server/initializers/migrations/0645-actor-remote-creation-date.ts similarity index 100% rename from server/initializers/migrations/0645-actor-remote-creation-date.ts rename to server/server/initializers/migrations/0645-actor-remote-creation-date.ts diff --git a/server/initializers/migrations/0650-actor-custom-pages.ts b/server/server/initializers/migrations/0650-actor-custom-pages.ts similarity index 100% rename from server/initializers/migrations/0650-actor-custom-pages.ts rename to server/server/initializers/migrations/0650-actor-custom-pages.ts diff --git a/server/initializers/migrations/0655-streaming-playlist-filenames.ts b/server/server/initializers/migrations/0655-streaming-playlist-filenames.ts similarity index 100% rename from server/initializers/migrations/0655-streaming-playlist-filenames.ts rename to server/server/initializers/migrations/0655-streaming-playlist-filenames.ts diff --git a/server/initializers/migrations/0660-object-storage.ts b/server/server/initializers/migrations/0660-object-storage.ts similarity index 96% rename from server/initializers/migrations/0660-object-storage.ts rename to server/server/initializers/migrations/0660-object-storage.ts index 53cb89ce6..c9dc7780e 100644 --- a/server/initializers/migrations/0660-object-storage.ts +++ b/server/server/initializers/migrations/0660-object-storage.ts @@ -1,5 +1,5 @@ import * as Sequelize from 'sequelize' -import { VideoStorage } from '@shared/models' +import { VideoStorage } from '@peertube/peertube-models' async function up (utils: { transaction: Sequelize.Transaction diff --git a/server/initializers/migrations/0665-no-account-warning-modal.ts b/server/server/initializers/migrations/0665-no-account-warning-modal.ts similarity index 100% rename from server/initializers/migrations/0665-no-account-warning-modal.ts rename to server/server/initializers/migrations/0665-no-account-warning-modal.ts diff --git a/server/initializers/migrations/0670-pending-job-default.ts b/server/server/initializers/migrations/0670-pending-job-default.ts similarity index 100% rename from server/initializers/migrations/0670-pending-job-default.ts rename to server/server/initializers/migrations/0670-pending-job-default.ts diff --git a/server/initializers/migrations/0675-p2p-enabled.ts b/server/server/initializers/migrations/0675-p2p-enabled.ts similarity index 100% rename from server/initializers/migrations/0675-p2p-enabled.ts rename to server/server/initializers/migrations/0675-p2p-enabled.ts diff --git a/server/initializers/migrations/0680-files-storage-default.ts b/server/server/initializers/migrations/0680-files-storage-default.ts similarity index 100% rename from server/initializers/migrations/0680-files-storage-default.ts rename to server/server/initializers/migrations/0680-files-storage-default.ts diff --git a/server/initializers/migrations/0685-multiple-actor-images.ts b/server/server/initializers/migrations/0685-multiple-actor-images.ts similarity index 100% rename from server/initializers/migrations/0685-multiple-actor-images.ts rename to server/server/initializers/migrations/0685-multiple-actor-images.ts diff --git a/server/initializers/migrations/0690-live-latency-mode.ts b/server/server/initializers/migrations/0690-live-latency-mode.ts similarity index 93% rename from server/initializers/migrations/0690-live-latency-mode.ts rename to server/server/initializers/migrations/0690-live-latency-mode.ts index c31a61364..b7f50cf4b 100644 --- a/server/initializers/migrations/0690-live-latency-mode.ts +++ b/server/server/initializers/migrations/0690-live-latency-mode.ts @@ -1,4 +1,4 @@ -import { LiveVideoLatencyMode } from '@shared/models' +import { LiveVideoLatencyMode } from '@peertube/peertube-models' import * as Sequelize from 'sequelize' async function up (utils: { diff --git a/server/initializers/migrations/0695-remove-remote-rates.ts b/server/server/initializers/migrations/0695-remove-remote-rates.ts similarity index 100% rename from server/initializers/migrations/0695-remove-remote-rates.ts rename to server/server/initializers/migrations/0695-remove-remote-rates.ts diff --git a/server/initializers/migrations/0700-edition-finished-notification.ts b/server/server/initializers/migrations/0700-edition-finished-notification.ts similarity index 100% rename from server/initializers/migrations/0700-edition-finished-notification.ts rename to server/server/initializers/migrations/0700-edition-finished-notification.ts diff --git a/server/initializers/migrations/0705-local-video-viewers.ts b/server/server/initializers/migrations/0705-local-video-viewers.ts similarity index 100% rename from server/initializers/migrations/0705-local-video-viewers.ts rename to server/server/initializers/migrations/0705-local-video-viewers.ts diff --git a/server/initializers/migrations/0710-live-sessions.ts b/server/server/initializers/migrations/0710-live-sessions.ts similarity index 100% rename from server/initializers/migrations/0710-live-sessions.ts rename to server/server/initializers/migrations/0710-live-sessions.ts diff --git a/server/initializers/migrations/0715-video-source.ts b/server/server/initializers/migrations/0715-video-source.ts similarity index 100% rename from server/initializers/migrations/0715-video-source.ts rename to server/server/initializers/migrations/0715-video-source.ts diff --git a/server/initializers/migrations/0720-session-ending-processed.ts b/server/server/initializers/migrations/0720-session-ending-processed.ts similarity index 100% rename from server/initializers/migrations/0720-session-ending-processed.ts rename to server/server/initializers/migrations/0720-session-ending-processed.ts diff --git a/server/initializers/migrations/0725-node-version.ts b/server/server/initializers/migrations/0725-node-version.ts similarity index 100% rename from server/initializers/migrations/0725-node-version.ts rename to server/server/initializers/migrations/0725-node-version.ts diff --git a/server/initializers/migrations/0730-video-channel-sync.ts b/server/server/initializers/migrations/0730-video-channel-sync.ts similarity index 100% rename from server/initializers/migrations/0730-video-channel-sync.ts rename to server/server/initializers/migrations/0730-video-channel-sync.ts diff --git a/server/initializers/migrations/0735-video-channel-sync-import-foreign-key.ts b/server/server/initializers/migrations/0735-video-channel-sync-import-foreign-key.ts similarity index 100% rename from server/initializers/migrations/0735-video-channel-sync-import-foreign-key.ts rename to server/server/initializers/migrations/0735-video-channel-sync-import-foreign-key.ts diff --git a/server/initializers/migrations/0740-fix-old-enums.ts b/server/server/initializers/migrations/0740-fix-old-enums.ts similarity index 100% rename from server/initializers/migrations/0740-fix-old-enums.ts rename to server/server/initializers/migrations/0740-fix-old-enums.ts diff --git a/server/initializers/migrations/0745-user-otp.ts b/server/server/initializers/migrations/0745-user-otp.ts similarity index 100% rename from server/initializers/migrations/0745-user-otp.ts rename to server/server/initializers/migrations/0745-user-otp.ts diff --git a/server/initializers/migrations/0750-user-registration.ts b/server/server/initializers/migrations/0750-user-registration.ts similarity index 100% rename from server/initializers/migrations/0750-user-registration.ts rename to server/server/initializers/migrations/0750-user-registration.ts diff --git a/server/initializers/migrations/0755-unique-viewer-url.ts b/server/server/initializers/migrations/0755-unique-viewer-url.ts similarity index 100% rename from server/initializers/migrations/0755-unique-viewer-url.ts rename to server/server/initializers/migrations/0755-unique-viewer-url.ts diff --git a/server/initializers/migrations/0760-video-live-replay-setting.ts b/server/server/initializers/migrations/0760-video-live-replay-setting.ts similarity index 100% rename from server/initializers/migrations/0760-video-live-replay-setting.ts rename to server/server/initializers/migrations/0760-video-live-replay-setting.ts diff --git a/server/initializers/migrations/0765-remote-transcoding.ts b/server/server/initializers/migrations/0765-remote-transcoding.ts similarity index 100% rename from server/initializers/migrations/0765-remote-transcoding.ts rename to server/server/initializers/migrations/0765-remote-transcoding.ts diff --git a/server/initializers/migrations/0770-actor-preferred-username.ts b/server/server/initializers/migrations/0770-actor-preferred-username.ts similarity index 100% rename from server/initializers/migrations/0770-actor-preferred-username.ts rename to server/server/initializers/migrations/0770-actor-preferred-username.ts diff --git a/server/initializers/migrations/0775-add-user-is-email-public.ts b/server/server/initializers/migrations/0775-add-user-is-email-public.ts similarity index 100% rename from server/initializers/migrations/0775-add-user-is-email-public.ts rename to server/server/initializers/migrations/0775-add-user-is-email-public.ts diff --git a/server/initializers/migrations/0780-notification-registration.ts b/server/server/initializers/migrations/0780-notification-registration.ts similarity index 100% rename from server/initializers/migrations/0780-notification-registration.ts rename to server/server/initializers/migrations/0780-notification-registration.ts diff --git a/server/initializers/migrations/0785-video-password-protection.ts b/server/server/initializers/migrations/0785-video-password-protection.ts similarity index 100% rename from server/initializers/migrations/0785-video-password-protection.ts rename to server/server/initializers/migrations/0785-video-password-protection.ts diff --git a/server/initializers/migrations/0790-thumbnail-disk.ts b/server/server/initializers/migrations/0790-thumbnail-disk.ts similarity index 100% rename from server/initializers/migrations/0790-thumbnail-disk.ts rename to server/server/initializers/migrations/0790-thumbnail-disk.ts diff --git a/server/initializers/migrations/0795-duplicate-runner-name.ts b/server/server/initializers/migrations/0795-duplicate-runner-name.ts similarity index 100% rename from server/initializers/migrations/0795-duplicate-runner-name.ts rename to server/server/initializers/migrations/0795-duplicate-runner-name.ts diff --git a/server/initializers/migrations/0800-video-replace-file.ts b/server/server/initializers/migrations/0800-video-replace-file.ts similarity index 100% rename from server/initializers/migrations/0800-video-replace-file.ts rename to server/server/initializers/migrations/0800-video-replace-file.ts diff --git a/server/initializers/migrator.ts b/server/server/initializers/migrator.ts similarity index 86% rename from server/initializers/migrator.ts rename to server/server/initializers/migrator.ts index 7ac20127e..a6494fb16 100644 --- a/server/initializers/migrator.ts +++ b/server/server/initializers/migrator.ts @@ -1,9 +1,10 @@ -import { readdir } from 'fs-extra' +import { readdir } from 'fs/promises' import { join } from 'path' import { QueryTypes } from 'sequelize' -import { logger } from '../helpers/logger' -import { LAST_MIGRATION_VERSION } from './constants' -import { sequelizeTypescript } from './database' +import { currentDir } from '@peertube/peertube-node-utils' +import { logger } from '../helpers/logger.js' +import { LAST_MIGRATION_VERSION } from './constants.js' +import { sequelizeTypescript } from './database.js' async function migrate () { const tables = await sequelizeTypescript.getQueryInterface().showAllTables() @@ -58,7 +59,7 @@ export { // --------------------------------------------------------------------------- async function getMigrationScripts () { - const files = await readdir(join(__dirname, 'migrations')) + const files = await readdir(join(currentDir(import.meta.url), 'migrations')) const filesToMigrate: { version: string script: string @@ -88,7 +89,7 @@ async function executeMigration (actualVersion: number, entity: { version: strin const migrationScriptName = entity.script logger.info('Executing %s migration script.', migrationScriptName) - const migrationScript = require(join(__dirname, 'migrations', migrationScriptName)) + const migrationScript = await import(join(currentDir(import.meta.url), 'migrations', migrationScriptName)) return sequelizeTypescript.transaction(async t => { const options = { diff --git a/server/lib/activitypub/activity.ts b/server/server/lib/activitypub/activity.ts similarity index 91% rename from server/lib/activitypub/activity.ts rename to server/server/lib/activitypub/activity.ts index 391bcd9c6..ea4b3bd63 100644 --- a/server/lib/activitypub/activity.ts +++ b/server/server/lib/activitypub/activity.ts @@ -1,7 +1,7 @@ -import { doJSONRequest, PeerTubeRequestOptions } from '@server/helpers/requests' -import { CONFIG } from '@server/initializers/config' -import { ActivityObject, ActivityPubActor, ActivityType, APObjectId } from '@shared/models' -import { buildSignedRequestOptions } from './send' +import { doJSONRequest, PeerTubeRequestOptions } from '@server/helpers/requests.js' +import { CONFIG } from '@server/initializers/config.js' +import { ActivityObject, ActivityPubActor, ActivityType, APObjectId } from '@peertube/peertube-models' +import { buildSignedRequestOptions } from './send/index.js' export function getAPId (object: string | { id: string }) { if (typeof object === 'string') return object diff --git a/server/lib/activitypub/actors/get.ts b/server/server/lib/activitypub/actors/get.ts similarity index 88% rename from server/lib/activitypub/actors/get.ts rename to server/server/lib/activitypub/actors/get.ts index dd2bc9f03..d301aa8f1 100644 --- a/server/lib/activitypub/actors/get.ts +++ b/server/server/lib/activitypub/actors/get.ts @@ -1,14 +1,20 @@ -import { retryTransactionWrapper } from '@server/helpers/database-utils' -import { logger } from '@server/helpers/logger' -import { JobQueue } from '@server/lib/job-queue' -import { ActorLoadByUrlType, loadActorByUrl } from '@server/lib/model-loaders' -import { MActor, MActorAccountChannelId, MActorAccountChannelIdActor, MActorAccountId, MActorFullActor } from '@server/types/models' -import { arrayify } from '@shared/core-utils' -import { ActivityPubActor, APObjectId } from '@shared/models' -import { fetchAPObjectIfNeeded, getAPId } from '../activity' -import { checkUrlsSameHost } from '../url' -import { refreshActorIfNeeded } from './refresh' -import { APActorCreator, fetchRemoteActor } from './shared' +import { arrayify } from '@peertube/peertube-core-utils' +import { ActivityPubActor, APObjectId } from '@peertube/peertube-models' +import { retryTransactionWrapper } from '@server/helpers/database-utils.js' +import { logger } from '@server/helpers/logger.js' +import { JobQueue } from '@server/lib/job-queue/index.js' +import { ActorLoadByUrlType, loadActorByUrl } from '@server/lib/model-loaders/index.js' +import { + MActor, + MActorAccountChannelId, + MActorAccountChannelIdActor, + MActorAccountId, + MActorFullActor +} from '@server/types/models/index.js' +import { fetchAPObjectIfNeeded, getAPId } from '../activity.js' +import { checkUrlsSameHost } from '../url.js' +import { refreshActorIfNeeded } from './refresh.js' +import { APActorCreator, fetchRemoteActor } from './shared/index.js' function getOrCreateAPActor ( activityActor: string | ActivityPubActor, diff --git a/server/lib/activitypub/actors/image.ts b/server/server/lib/activitypub/actors/image.ts similarity index 83% rename from server/lib/activitypub/actors/image.ts rename to server/server/lib/activitypub/actors/image.ts index e1d29af5b..290f967b7 100644 --- a/server/lib/activitypub/actors/image.ts +++ b/server/server/lib/activitypub/actors/image.ts @@ -1,8 +1,8 @@ -import { Transaction } from 'sequelize/types' -import { logger } from '@server/helpers/logger' -import { ActorImageModel } from '@server/models/actor/actor-image' -import { MActorImage, MActorImages } from '@server/types/models' -import { ActorImageType } from '@shared/models' +import { ActorImageType, ActorImageType_Type } from '@peertube/peertube-models' +import { logger } from '@server/helpers/logger.js' +import { ActorImageModel } from '@server/models/actor/actor-image.js' +import { MActorImage, MActorImages } from '@server/types/models/index.js' +import { Transaction } from 'sequelize' type ImageInfo = { name: string @@ -12,7 +12,7 @@ type ImageInfo = { onDisk?: boolean } -async function updateActorImages (actor: MActorImages, type: ActorImageType, imagesInfo: ImageInfo[], t: Transaction) { +async function updateActorImages (actor: MActorImages, type: ActorImageType_Type, imagesInfo: ImageInfo[], t: Transaction) { const getAvatarsOrBanners = () => { const result = type === ActorImageType.AVATAR ? actor.Avatars @@ -60,7 +60,7 @@ async function updateActorImages (actor: MActorImages, type: ActorImageType, ima return actor } -async function deleteActorImages (actor: MActorImages, type: ActorImageType, t: Transaction) { +async function deleteActorImages (actor: MActorImages, type: ActorImageType_Type, t: Transaction) { try { const association = buildAssociationName(type) @@ -76,7 +76,7 @@ async function deleteActorImages (actor: MActorImages, type: ActorImageType, t: return actor } -async function safeDeleteActorImage (actor: MActorImages, toDelete: MActorImage, type: ActorImageType, t: Transaction) { +async function safeDeleteActorImage (actor: MActorImages, toDelete: MActorImage, type: ActorImageType_Type, t: Transaction) { try { await toDelete.destroy({ transaction: t }) @@ -90,7 +90,7 @@ async function safeDeleteActorImage (actor: MActorImages, toDelete: MActorImage, // --------------------------------------------------------------------------- export { - ImageInfo, + type ImageInfo, updateActorImages, deleteActorImages @@ -98,14 +98,14 @@ export { // --------------------------------------------------------------------------- -function addActorImage (actor: MActorImages, type: ActorImageType, imageModel: MActorImage) { +function addActorImage (actor: MActorImages, type: ActorImageType_Type, imageModel: MActorImage) { const association = buildAssociationName(type) if (!actor[association]) actor[association] = [] actor[association].push(imageModel) } -function buildAssociationName (type: ActorImageType) { +function buildAssociationName (type: ActorImageType_Type) { return type === ActorImageType.AVATAR ? 'Avatars' : 'Banners' diff --git a/server/server/lib/activitypub/actors/index.ts b/server/server/lib/activitypub/actors/index.ts new file mode 100644 index 000000000..9062e1394 --- /dev/null +++ b/server/server/lib/activitypub/actors/index.ts @@ -0,0 +1,6 @@ +export * from './get.js' +export * from './image.js' +export * from './keys.js' +export * from './refresh.js' +export * from './updater.js' +export * from './webfinger.js' diff --git a/server/lib/activitypub/actors/keys.ts b/server/server/lib/activitypub/actors/keys.ts similarity index 86% rename from server/lib/activitypub/actors/keys.ts rename to server/server/lib/activitypub/actors/keys.ts index c3d18abd8..bf7973756 100644 --- a/server/lib/activitypub/actors/keys.ts +++ b/server/server/lib/activitypub/actors/keys.ts @@ -1,5 +1,5 @@ -import { createPrivateAndPublicKeys } from '@server/helpers/peertube-crypto' -import { MActor } from '@server/types/models' +import { createPrivateAndPublicKeys } from '@server/helpers/peertube-crypto.js' +import { MActor } from '@server/types/models/index.js' // Set account keys, this could be long so process after the account creation and do not block the client async function generateAndSaveActorKeys (actor: T) { diff --git a/server/lib/activitypub/actors/refresh.ts b/server/server/lib/activitypub/actors/refresh.ts similarity index 85% rename from server/lib/activitypub/actors/refresh.ts rename to server/server/lib/activitypub/actors/refresh.ts index d15cb5e90..87f017ae8 100644 --- a/server/lib/activitypub/actors/refresh.ts +++ b/server/server/lib/activitypub/actors/refresh.ts @@ -1,13 +1,13 @@ -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { CachePromiseFactory } from '@server/helpers/promise-cache' -import { PeerTubeRequestError } from '@server/helpers/requests' -import { ActorLoadByUrlType } from '@server/lib/model-loaders' -import { ActorModel } from '@server/models/actor/actor' -import { MActorAccountChannelId, MActorFull } from '@server/types/models' -import { HttpStatusCode } from '@shared/models' -import { fetchRemoteActor } from './shared' -import { APActorUpdater } from './updater' -import { getUrlFromWebfinger } from './webfinger' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { CachePromiseFactory } from '@server/helpers/promise-cache.js' +import { PeerTubeRequestError } from '@server/helpers/requests.js' +import { ActorLoadByUrlType } from '@server/lib/model-loaders/index.js' +import { ActorModel } from '@server/models/actor/actor.js' +import { MActorAccountChannelId, MActorFull } from '@server/types/models/index.js' +import { HttpStatusCode } from '@peertube/peertube-models' +import { fetchRemoteActor } from './shared/index.js' +import { APActorUpdater } from './updater.js' +import { getUrlFromWebfinger } from './webfinger.js' type RefreshResult = Promise<{ actor: T | MActorFull, refreshed: boolean }> diff --git a/server/lib/activitypub/actors/shared/creator.ts b/server/server/lib/activitypub/actors/shared/creator.ts similarity index 88% rename from server/lib/activitypub/actors/shared/creator.ts rename to server/server/lib/activitypub/actors/shared/creator.ts index 500bc9912..426f918fb 100644 --- a/server/lib/activitypub/actors/shared/creator.ts +++ b/server/server/lib/activitypub/actors/shared/creator.ts @@ -1,14 +1,23 @@ import { Op, Transaction } from 'sequelize' -import { sequelizeTypescript } from '@server/initializers/database' -import { AccountModel } from '@server/models/account/account' -import { ActorModel } from '@server/models/actor/actor' -import { ServerModel } from '@server/models/server/server' -import { VideoChannelModel } from '@server/models/video/video-channel' -import { MAccount, MAccountDefault, MActor, MActorFullActor, MActorId, MActorImages, MChannel, MServer } from '@server/types/models' -import { ActivityPubActor, ActorImageType } from '@shared/models' -import { updateActorImages } from '../image' -import { getActorAttributesFromObject, getActorDisplayNameFromObject, getImagesInfoFromObject } from './object-to-model-attributes' -import { fetchActorFollowsCount } from './url-to-object' +import { ActivityPubActor, ActorImageType, ActorImageType_Type } from '@peertube/peertube-models' +import { sequelizeTypescript } from '@server/initializers/database.js' +import { AccountModel } from '@server/models/account/account.js' +import { ActorModel } from '@server/models/actor/actor.js' +import { ServerModel } from '@server/models/server/server.js' +import { VideoChannelModel } from '@server/models/video/video-channel.js' +import { + MAccount, + MAccountDefault, + MActor, + MActorFullActor, + MActorId, + MActorImages, + MChannel, + MServer +} from '@server/types/models/index.js' +import { updateActorImages } from '../image.js' +import { getActorAttributesFromObject, getActorDisplayNameFromObject, getImagesInfoFromObject } from './object-to-model-attributes.js' +import { fetchActorFollowsCount } from './url-to-object.js' export class APActorCreator { @@ -70,7 +79,7 @@ export class APActorCreator { return server as MServer } - private async setImageIfNeeded (actor: MActor, type: ActorImageType, t: Transaction) { + private async setImageIfNeeded (actor: MActor, type: ActorImageType_Type, t: Transaction) { const imagesInfo = getImagesInfoFromObject(this.actorObject, type) if (imagesInfo.length === 0) return diff --git a/server/server/lib/activitypub/actors/shared/index.ts b/server/server/lib/activitypub/actors/shared/index.ts new file mode 100644 index 000000000..d213a7986 --- /dev/null +++ b/server/server/lib/activitypub/actors/shared/index.ts @@ -0,0 +1,3 @@ +export * from './creator.js' +export * from './object-to-model-attributes.js' +export * from './url-to-object.js' diff --git a/server/lib/activitypub/actors/shared/object-to-model-attributes.ts b/server/server/lib/activitypub/actors/shared/object-to-model-attributes.ts similarity index 82% rename from server/lib/activitypub/actors/shared/object-to-model-attributes.ts rename to server/server/lib/activitypub/actors/shared/object-to-model-attributes.ts index 3ce332681..987c48085 100644 --- a/server/lib/activitypub/actors/shared/object-to-model-attributes.ts +++ b/server/server/lib/activitypub/actors/shared/object-to-model-attributes.ts @@ -1,10 +1,9 @@ -import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc' -import { MIMETYPES } from '@server/initializers/constants' -import { ActorModel } from '@server/models/actor/actor' -import { FilteredModelAttributes } from '@server/types' -import { getLowercaseExtension } from '@shared/core-utils' -import { buildUUID } from '@shared/extra-utils' -import { ActivityIconObject, ActivityPubActor, ActorImageType } from '@shared/models' +import { ActivityIconObject, ActivityPubActor, ActorImageType, ActorImageType_Type } from '@peertube/peertube-models' +import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc.js' +import { MIMETYPES } from '@server/initializers/constants.js' +import { ActorModel } from '@server/models/actor/actor.js' +import { FilteredModelAttributes } from '@server/types/index.js' +import { buildUUID, getLowercaseExtension } from '@peertube/peertube-node-utils' function getActorAttributesFromObject ( actorObject: ActivityPubActor, @@ -30,7 +29,7 @@ function getActorAttributesFromObject ( } } -function getImagesInfoFromObject (actorObject: ActivityPubActor, type: ActorImageType) { +function getImagesInfoFromObject (actorObject: ActivityPubActor, type: ActorImageType_Type) { const iconsOrImages = type === ActorImageType.AVATAR ? actorObject.icon : actorObject.image diff --git a/server/lib/activitypub/actors/shared/url-to-object.ts b/server/server/lib/activitypub/actors/shared/url-to-object.ts similarity index 88% rename from server/lib/activitypub/actors/shared/url-to-object.ts rename to server/server/lib/activitypub/actors/shared/url-to-object.ts index 73766bd50..6dc04e396 100644 --- a/server/lib/activitypub/actors/shared/url-to-object.ts +++ b/server/server/lib/activitypub/actors/shared/url-to-object.ts @@ -1,8 +1,8 @@ -import { sanitizeAndCheckActorObject } from '@server/helpers/custom-validators/activitypub/actor' -import { logger } from '@server/helpers/logger' -import { ActivityPubActor, ActivityPubOrderedCollection } from '@shared/models' -import { fetchAP } from '../../activity' -import { checkUrlsSameHost } from '../../url' +import { sanitizeAndCheckActorObject } from '@server/helpers/custom-validators/activitypub/actor.js' +import { logger } from '@server/helpers/logger.js' +import { ActivityPubActor, ActivityPubOrderedCollection } from '@peertube/peertube-models' +import { fetchAP } from '../../activity.js' +import { checkUrlsSameHost } from '../../url.js' async function fetchRemoteActor (actorUrl: string): Promise<{ statusCode: number, actorObject: ActivityPubActor }> { logger.info('Fetching remote actor %s.', actorUrl) diff --git a/server/lib/activitypub/actors/updater.ts b/server/server/lib/activitypub/actors/updater.ts similarity index 88% rename from server/lib/activitypub/actors/updater.ts rename to server/server/lib/activitypub/actors/updater.ts index 5a92e7a22..81953611a 100644 --- a/server/lib/activitypub/actors/updater.ts +++ b/server/server/lib/activitypub/actors/updater.ts @@ -1,13 +1,13 @@ -import { resetSequelizeInstance, runInReadCommittedTransaction } from '@server/helpers/database-utils' -import { logger } from '@server/helpers/logger' -import { AccountModel } from '@server/models/account/account' -import { VideoChannelModel } from '@server/models/video/video-channel' -import { MAccount, MActor, MActorFull, MChannel } from '@server/types/models' -import { ActivityPubActor, ActorImageType } from '@shared/models' -import { getOrCreateAPOwner } from './get' -import { updateActorImages } from './image' -import { fetchActorFollowsCount } from './shared' -import { getImagesInfoFromObject } from './shared/object-to-model-attributes' +import { resetSequelizeInstance, runInReadCommittedTransaction } from '@server/helpers/database-utils.js' +import { logger } from '@server/helpers/logger.js' +import { AccountModel } from '@server/models/account/account.js' +import { VideoChannelModel } from '@server/models/video/video-channel.js' +import { MAccount, MActor, MActorFull, MChannel } from '@server/types/models/index.js' +import { ActivityPubActor, ActorImageType } from '@peertube/peertube-models' +import { getOrCreateAPOwner } from './get.js' +import { updateActorImages } from './image.js' +import { fetchActorFollowsCount } from './shared/index.js' +import { getImagesInfoFromObject } from './shared/object-to-model-attributes.js' export class APActorUpdater { diff --git a/server/lib/activitypub/actors/webfinger.ts b/server/server/lib/activitypub/actors/webfinger.ts similarity index 86% rename from server/lib/activitypub/actors/webfinger.ts rename to server/server/lib/activitypub/actors/webfinger.ts index b20a724da..21d148a61 100644 --- a/server/lib/activitypub/actors/webfinger.ts +++ b/server/server/lib/activitypub/actors/webfinger.ts @@ -1,10 +1,10 @@ import WebFinger from 'webfinger.js' -import { isProdInstance } from '@server/helpers/core-utils' -import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc' -import { REQUEST_TIMEOUTS, WEBSERVER } from '@server/initializers/constants' -import { ActorModel } from '@server/models/actor/actor' -import { MActorFull } from '@server/types/models' -import { WebFingerData } from '@shared/models' +import { WebFingerData } from '@peertube/peertube-models' +import { isProdInstance } from '@peertube/peertube-node-utils' +import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc.js' +import { REQUEST_TIMEOUTS, WEBSERVER } from '@server/initializers/constants.js' +import { ActorModel } from '@server/models/actor/actor.js' +import { MActorFull } from '@server/types/models/index.js' const webfinger = new WebFinger({ webfist_fallback: false, diff --git a/server/lib/activitypub/audience.ts b/server/server/lib/activitypub/audience.ts similarity index 77% rename from server/lib/activitypub/audience.ts rename to server/server/lib/activitypub/audience.ts index 6f5491387..197acdb85 100644 --- a/server/lib/activitypub/audience.ts +++ b/server/server/lib/activitypub/audience.ts @@ -1,6 +1,6 @@ -import { ActivityAudience } from '../../../shared/models/activitypub' -import { ACTIVITY_PUB } from '../../initializers/constants' -import { MActorFollowersUrl } from '../../types/models' +import { ActivityAudience } from '@peertube/peertube-models' +import { ACTIVITY_PUB } from '../../initializers/constants.js' +import { MActorFollowersUrl } from '../../types/models/index.js' function getAudience (actorSender: MActorFollowersUrl, isPublic = true) { return buildAudience([ actorSender.followersUrl ], isPublic) diff --git a/server/lib/activitypub/cache-file.ts b/server/server/lib/activitypub/cache-file.ts similarity index 95% rename from server/lib/activitypub/cache-file.ts rename to server/server/lib/activitypub/cache-file.ts index c3acd7112..ef8bbace8 100644 --- a/server/lib/activitypub/cache-file.ts +++ b/server/server/lib/activitypub/cache-file.ts @@ -1,7 +1,7 @@ import { Transaction } from 'sequelize' -import { MActorId, MVideoRedundancy, MVideoWithAllFiles } from '@server/types/models' -import { CacheFileObject, VideoStreamingPlaylistType } from '@shared/models' -import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' +import { MActorId, MVideoRedundancy, MVideoWithAllFiles } from '@server/types/models/index.js' +import { CacheFileObject, VideoStreamingPlaylistType } from '@peertube/peertube-models' +import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy.js' async function createOrUpdateCacheFile (cacheFileObject: CacheFileObject, video: MVideoWithAllFiles, byActor: MActorId, t: Transaction) { const redundancyModel = await VideoRedundancyModel.loadByUrl(cacheFileObject.id, t) diff --git a/server/lib/activitypub/collection.ts b/server/server/lib/activitypub/collection.ts similarity index 82% rename from server/lib/activitypub/collection.ts rename to server/server/lib/activitypub/collection.ts index a176cab51..280c3a5e9 100644 --- a/server/lib/activitypub/collection.ts +++ b/server/server/lib/activitypub/collection.ts @@ -1,9 +1,9 @@ import Bluebird from 'bluebird' import validator from 'validator' -import { pageToStartAndCount } from '@server/helpers/core-utils' -import { ACTIVITY_PUB } from '@server/initializers/constants' -import { ResultList } from '@shared/models' -import { forceNumber } from '@shared/core-utils' +import { pageToStartAndCount } from '@server/helpers/core-utils.js' +import { ACTIVITY_PUB } from '@server/initializers/constants.js' +import { ResultList } from '@peertube/peertube-models' +import { forceNumber } from '@peertube/peertube-core-utils' type ActivityPubCollectionPaginationHandler = (start: number, count: number) => Bluebird> | Promise> @@ -13,7 +13,7 @@ async function activityPubCollectionPagination ( page?: any, size = ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE ) { - if (!page || !validator.isInt(page)) { + if (!page || !validator.default.isInt(page)) { // We just display the first page URL, we only need the total items const result = await handler(0, 1) diff --git a/server/server/lib/activitypub/context.ts b/server/server/lib/activitypub/context.ts new file mode 100644 index 000000000..8de565976 --- /dev/null +++ b/server/server/lib/activitypub/context.ts @@ -0,0 +1,10 @@ +import { Hooks } from '../plugins/hooks.js' + +export function getContextFilter () { + return (contextData: T) => { + return Hooks.wrapObject( + contextData, + 'filter:activity-pub.activity.context.build.result' + ) + } +} diff --git a/server/lib/activitypub/crawl.ts b/server/server/lib/activitypub/crawl.ts similarity index 89% rename from server/lib/activitypub/crawl.ts rename to server/server/lib/activitypub/crawl.ts index b8348e8cf..bc773279a 100644 --- a/server/lib/activitypub/crawl.ts +++ b/server/server/lib/activitypub/crawl.ts @@ -1,10 +1,10 @@ import Bluebird from 'bluebird' import { URL } from 'url' -import { retryTransactionWrapper } from '@server/helpers/database-utils' -import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub' -import { logger } from '../../helpers/logger' -import { ACTIVITY_PUB, WEBSERVER } from '../../initializers/constants' -import { fetchAP } from './activity' +import { ActivityPubOrderedCollection } from '@peertube/peertube-models' +import { retryTransactionWrapper } from '@server/helpers/database-utils.js' +import { logger } from '../../helpers/logger.js' +import { ACTIVITY_PUB, WEBSERVER } from '../../initializers/constants.js' +import { fetchAP } from './activity.js' type HandlerFunction = (items: T[]) => (Promise | Bluebird) type CleanerFunction = (startedDate: Date) => Promise diff --git a/server/lib/activitypub/follow.ts b/server/server/lib/activitypub/follow.ts similarity index 77% rename from server/lib/activitypub/follow.ts rename to server/server/lib/activitypub/follow.ts index f6e2a48fd..d6c60602b 100644 --- a/server/lib/activitypub/follow.ts +++ b/server/server/lib/activitypub/follow.ts @@ -1,11 +1,11 @@ import { Transaction } from 'sequelize' -import { getServerActor } from '@server/models/application/application' -import { logger } from '../../helpers/logger' -import { CONFIG } from '../../initializers/config' -import { SERVER_ACTOR_NAME } from '../../initializers/constants' -import { ServerModel } from '../../models/server/server' -import { MActorFollowActors } from '../../types/models' -import { JobQueue } from '../job-queue' +import { getServerActor } from '@server/models/application/application.js' +import { logger } from '../../helpers/logger.js' +import { CONFIG } from '../../initializers/config.js' +import { SERVER_ACTOR_NAME } from '../../initializers/constants.js' +import { ServerModel } from '../../models/server/server.js' +import { MActorFollowActors } from '../../types/models/index.js' +import { JobQueue } from '../job-queue/index.js' async function autoFollowBackIfNeeded (actorFollow: MActorFollowActors, transaction?: Transaction) { if (!CONFIG.FOLLOWINGS.INSTANCE.AUTO_FOLLOW_BACK.ENABLED) return diff --git a/server/lib/activitypub/inbox-manager.ts b/server/server/lib/activitypub/inbox-manager.ts similarity index 83% rename from server/lib/activitypub/inbox-manager.ts rename to server/server/lib/activitypub/inbox-manager.ts index 27778cc9d..ecf95d1ee 100644 --- a/server/lib/activitypub/inbox-manager.ts +++ b/server/server/lib/activitypub/inbox-manager.ts @@ -1,10 +1,10 @@ import PQueue from 'p-queue' -import { logger } from '@server/helpers/logger' -import { SCHEDULER_INTERVALS_MS } from '@server/initializers/constants' -import { MActorDefault, MActorSignature } from '@server/types/models' -import { Activity } from '@shared/models' -import { StatsManager } from '../stat-manager' -import { processActivities } from './process' +import { logger } from '@server/helpers/logger.js' +import { SCHEDULER_INTERVALS_MS } from '@server/initializers/constants.js' +import { MActorDefault, MActorSignature } from '@server/types/models/index.js' +import { Activity } from '@peertube/peertube-models' +import { StatsManager } from '../stat-manager.js' +import { processActivities } from './process/index.js' class InboxManager { diff --git a/server/lib/activitypub/local-video-viewer.ts b/server/server/lib/activitypub/local-video-viewer.ts similarity index 83% rename from server/lib/activitypub/local-video-viewer.ts rename to server/server/lib/activitypub/local-video-viewer.ts index bdd746791..accd0c894 100644 --- a/server/lib/activitypub/local-video-viewer.ts +++ b/server/server/lib/activitypub/local-video-viewer.ts @@ -1,9 +1,9 @@ import { Transaction } from 'sequelize' -import { LocalVideoViewerModel } from '@server/models/view/local-video-viewer' -import { LocalVideoViewerWatchSectionModel } from '@server/models/view/local-video-viewer-watch-section' -import { MVideo } from '@server/types/models' -import { WatchActionObject } from '@shared/models' -import { getDurationFromActivityStream } from './activity' +import { LocalVideoViewerModel } from '@server/models/view/local-video-viewer.js' +import { LocalVideoViewerWatchSectionModel } from '@server/models/view/local-video-viewer-watch-section.js' +import { MVideo } from '@server/types/models/index.js' +import { WatchActionObject } from '@peertube/peertube-models' +import { getDurationFromActivityStream } from './activity.js' async function createOrUpdateLocalVideoViewer (watchAction: WatchActionObject, video: MVideo, t: Transaction) { const stats = await LocalVideoViewerModel.loadByUrl(watchAction.id) diff --git a/server/lib/activitypub/outbox.ts b/server/server/lib/activitypub/outbox.ts similarity index 76% rename from server/lib/activitypub/outbox.ts rename to server/server/lib/activitypub/outbox.ts index 5eef76871..8e3cf6815 100644 --- a/server/lib/activitypub/outbox.ts +++ b/server/server/lib/activitypub/outbox.ts @@ -1,7 +1,7 @@ -import { logger } from '@server/helpers/logger' -import { ActorModel } from '@server/models/actor/actor' -import { getServerActor } from '@server/models/application/application' -import { JobQueue } from '../job-queue' +import { logger } from '@server/helpers/logger.js' +import { ActorModel } from '@server/models/actor/actor.js' +import { getServerActor } from '@server/models/application/application.js' +import { JobQueue } from '../job-queue/index.js' async function addFetchOutboxJob (actor: Pick) { // Don't fetch ourselves diff --git a/server/lib/activitypub/playlists/create-update.ts b/server/server/lib/activitypub/playlists/create-update.ts similarity index 87% rename from server/lib/activitypub/playlists/create-update.ts rename to server/server/lib/activitypub/playlists/create-update.ts index b24299f29..05fef5df1 100644 --- a/server/lib/activitypub/playlists/create-update.ts +++ b/server/server/lib/activitypub/playlists/create-update.ts @@ -1,31 +1,31 @@ -import { map } from 'bluebird' -import { isArray } from '@server/helpers/custom-validators/misc' -import { retryTransactionWrapper } from '@server/helpers/database-utils' -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { CRAWL_REQUEST_CONCURRENCY } from '@server/initializers/constants' -import { sequelizeTypescript } from '@server/initializers/database' -import { updateRemotePlaylistMiniatureFromUrl } from '@server/lib/thumbnail' -import { VideoPlaylistModel } from '@server/models/video/video-playlist' -import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element' -import { FilteredModelAttributes } from '@server/types' -import { MThumbnail, MVideoPlaylist, MVideoPlaylistFull, MVideoPlaylistVideosLength } from '@server/types/models' -import { PlaylistObject } from '@shared/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { getAPId } from '../activity' -import { getOrCreateAPActor } from '../actors' -import { crawlCollectionPage } from '../crawl' -import { getOrCreateAPVideo } from '../videos' +import Bluebird from 'bluebird' +import { isArray } from '@server/helpers/custom-validators/misc.js' +import { retryTransactionWrapper } from '@server/helpers/database-utils.js' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { CRAWL_REQUEST_CONCURRENCY } from '@server/initializers/constants.js' +import { sequelizeTypescript } from '@server/initializers/database.js' +import { updateRemotePlaylistMiniatureFromUrl } from '@server/lib/thumbnail.js' +import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element.js' +import { VideoPlaylistModel } from '@server/models/video/video-playlist.js' +import { FilteredModelAttributes } from '@server/types/index.js' +import { MThumbnail, MVideoPlaylist, MVideoPlaylistFull, MVideoPlaylistVideosLength } from '@server/types/models/index.js' +import { PlaylistObject } from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { getAPId } from '../activity.js' +import { getOrCreateAPActor } from '../actors/index.js' +import { crawlCollectionPage } from '../crawl.js' +import { getOrCreateAPVideo } from '../videos/index.js' import { fetchRemotePlaylistElement, fetchRemoteVideoPlaylist, playlistElementObjectToDBAttributes, playlistObjectToDBAttributes -} from './shared' +} from './shared/index.js' const lTags = loggerTagsFactory('ap', 'video-playlist') async function createAccountPlaylists (playlistUrls: string[]) { - await map(playlistUrls, async playlistUrl => { + await Bluebird.map(playlistUrls, async playlistUrl => { try { const exists = await VideoPlaylistModel.doesPlaylistExist(playlistUrl) if (exists === true) return @@ -141,7 +141,7 @@ async function rebuildVideoPlaylistElements (elementUrls: string[], playlist: MV async function buildElementsDBAttributes (elementUrls: string[], playlist: MVideoPlaylist) { const elementsToCreate: FilteredModelAttributes[] = [] - await map(elementUrls, async elementUrl => { + await Bluebird.map(elementUrls, async elementUrl => { try { const { elementObject } = await fetchRemotePlaylistElement(elementUrl) diff --git a/server/lib/activitypub/playlists/get.ts b/server/server/lib/activitypub/playlists/get.ts similarity index 73% rename from server/lib/activitypub/playlists/get.ts rename to server/server/lib/activitypub/playlists/get.ts index c34554d69..645ab5cdb 100644 --- a/server/lib/activitypub/playlists/get.ts +++ b/server/server/lib/activitypub/playlists/get.ts @@ -1,10 +1,10 @@ -import { VideoPlaylistModel } from '@server/models/video/video-playlist' -import { MVideoPlaylistFullSummary } from '@server/types/models' -import { APObjectId } from '@shared/models' -import { getAPId } from '../activity' -import { createOrUpdateVideoPlaylist } from './create-update' -import { scheduleRefreshIfNeeded } from './refresh' -import { fetchRemoteVideoPlaylist } from './shared' +import { VideoPlaylistModel } from '@server/models/video/video-playlist.js' +import { MVideoPlaylistFullSummary } from '@server/types/models/index.js' +import { APObjectId } from '@peertube/peertube-models' +import { getAPId } from '../activity.js' +import { createOrUpdateVideoPlaylist } from './create-update.js' +import { scheduleRefreshIfNeeded } from './refresh.js' +import { fetchRemoteVideoPlaylist } from './shared/index.js' async function getOrCreateAPVideoPlaylist (playlistObjectArg: APObjectId): Promise { const playlistUrl = getAPId(playlistObjectArg) diff --git a/server/server/lib/activitypub/playlists/index.ts b/server/server/lib/activitypub/playlists/index.ts new file mode 100644 index 000000000..5c0864ab4 --- /dev/null +++ b/server/server/lib/activitypub/playlists/index.ts @@ -0,0 +1,3 @@ +export * from './get.js' +export * from './create-update.js' +export * from './refresh.js' diff --git a/server/lib/activitypub/playlists/refresh.ts b/server/server/lib/activitypub/playlists/refresh.ts similarity index 82% rename from server/lib/activitypub/playlists/refresh.ts rename to server/server/lib/activitypub/playlists/refresh.ts index 33260ea02..033a5b64a 100644 --- a/server/lib/activitypub/playlists/refresh.ts +++ b/server/server/lib/activitypub/playlists/refresh.ts @@ -1,10 +1,10 @@ -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { PeerTubeRequestError } from '@server/helpers/requests' -import { JobQueue } from '@server/lib/job-queue' -import { MVideoPlaylist, MVideoPlaylistOwner } from '@server/types/models' -import { HttpStatusCode } from '@shared/models' -import { createOrUpdateVideoPlaylist } from './create-update' -import { fetchRemoteVideoPlaylist } from './shared' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { PeerTubeRequestError } from '@server/helpers/requests.js' +import { JobQueue } from '@server/lib/job-queue/index.js' +import { MVideoPlaylist, MVideoPlaylistOwner } from '@server/types/models/index.js' +import { HttpStatusCode } from '@peertube/peertube-models' +import { createOrUpdateVideoPlaylist } from './create-update.js' +import { fetchRemoteVideoPlaylist } from './shared/index.js' function scheduleRefreshIfNeeded (playlist: MVideoPlaylist) { if (!playlist.isOutdated()) return diff --git a/server/server/lib/activitypub/playlists/shared/index.ts b/server/server/lib/activitypub/playlists/shared/index.ts new file mode 100644 index 000000000..af333ce18 --- /dev/null +++ b/server/server/lib/activitypub/playlists/shared/index.ts @@ -0,0 +1,2 @@ +export * from './object-to-model-attributes.js' +export * from './url-to-object.js' diff --git a/server/lib/activitypub/playlists/shared/object-to-model-attributes.ts b/server/server/lib/activitypub/playlists/shared/object-to-model-attributes.ts similarity index 85% rename from server/lib/activitypub/playlists/shared/object-to-model-attributes.ts rename to server/server/lib/activitypub/playlists/shared/object-to-model-attributes.ts index 753b5e660..1964e04df 100644 --- a/server/lib/activitypub/playlists/shared/object-to-model-attributes.ts +++ b/server/server/lib/activitypub/playlists/shared/object-to-model-attributes.ts @@ -1,9 +1,9 @@ -import { ACTIVITY_PUB } from '@server/initializers/constants' -import { VideoPlaylistModel } from '@server/models/video/video-playlist' -import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element' -import { MVideoId, MVideoPlaylistId } from '@server/types/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { PlaylistElementObject, PlaylistObject, VideoPlaylistPrivacy } from '@shared/models' +import { ACTIVITY_PUB } from '@server/initializers/constants.js' +import { VideoPlaylistModel } from '@server/models/video/video-playlist.js' +import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element.js' +import { MVideoId, MVideoPlaylistId } from '@server/types/models/index.js' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { PlaylistElementObject, PlaylistObject, VideoPlaylistPrivacy } from '@peertube/peertube-models' function playlistObjectToDBAttributes (playlistObject: PlaylistObject, to: string[]) { const privacy = to.includes(ACTIVITY_PUB.PUBLIC) diff --git a/server/lib/activitypub/playlists/shared/url-to-object.ts b/server/server/lib/activitypub/playlists/shared/url-to-object.ts similarity index 84% rename from server/lib/activitypub/playlists/shared/url-to-object.ts rename to server/server/lib/activitypub/playlists/shared/url-to-object.ts index fd9fe5558..3e6adbcb0 100644 --- a/server/lib/activitypub/playlists/shared/url-to-object.ts +++ b/server/server/lib/activitypub/playlists/shared/url-to-object.ts @@ -1,9 +1,9 @@ -import { isPlaylistElementObjectValid, isPlaylistObjectValid } from '@server/helpers/custom-validators/activitypub/playlist' -import { isArray } from '@server/helpers/custom-validators/misc' -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { PlaylistElementObject, PlaylistObject } from '@shared/models' -import { fetchAP } from '../../activity' -import { checkUrlsSameHost } from '../../url' +import { isPlaylistElementObjectValid, isPlaylistObjectValid } from '@server/helpers/custom-validators/activitypub/playlist.js' +import { isArray } from '@server/helpers/custom-validators/misc.js' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { PlaylistElementObject, PlaylistObject } from '@peertube/peertube-models' +import { fetchAP } from '../../activity.js' +import { checkUrlsSameHost } from '../../url.js' async function fetchRemoteVideoPlaylist (playlistUrl: string): Promise<{ statusCode: number, playlistObject: PlaylistObject }> { const lTags = loggerTagsFactory('ap', 'video-playlist', playlistUrl) diff --git a/server/server/lib/activitypub/process/index.ts b/server/server/lib/activitypub/process/index.ts new file mode 100644 index 000000000..47160b9cb --- /dev/null +++ b/server/server/lib/activitypub/process/index.ts @@ -0,0 +1 @@ +export * from './process.js' diff --git a/server/lib/activitypub/process/process-accept.ts b/server/server/lib/activitypub/process/process-accept.ts similarity index 87% rename from server/lib/activitypub/process/process-accept.ts rename to server/server/lib/activitypub/process/process-accept.ts index 077b01eda..11092caaa 100644 --- a/server/lib/activitypub/process/process-accept.ts +++ b/server/server/lib/activitypub/process/process-accept.ts @@ -1,8 +1,8 @@ -import { ActivityAccept } from '../../../../shared/models/activitypub' -import { ActorFollowModel } from '../../../models/actor/actor-follow' -import { APProcessorOptions } from '../../../types/activitypub-processor.model' -import { MActorDefault, MActorSignature } from '../../../types/models' -import { addFetchOutboxJob } from '../outbox' +import { ActivityAccept } from '@peertube/peertube-models' +import { ActorFollowModel } from '../../../models/actor/actor-follow.js' +import { APProcessorOptions } from '../../../types/activitypub-processor.model.js' +import { MActorDefault, MActorSignature } from '../../../types/models/index.js' +import { addFetchOutboxJob } from '../outbox.js' async function processAcceptActivity (options: APProcessorOptions) { const { byActor: targetActor, inboxActor } = options diff --git a/server/lib/activitypub/process/process-announce.ts b/server/server/lib/activitypub/process/process-announce.ts similarity index 85% rename from server/lib/activitypub/process/process-announce.ts rename to server/server/lib/activitypub/process/process-announce.ts index 9cc87ee27..ed178f73c 100644 --- a/server/lib/activitypub/process/process-announce.ts +++ b/server/server/lib/activitypub/process/process-announce.ts @@ -1,14 +1,14 @@ -import { getAPId } from '@server/lib/activitypub/activity' -import { ActivityAnnounce } from '../../../../shared/models/activitypub' -import { retryTransactionWrapper } from '../../../helpers/database-utils' -import { logger } from '../../../helpers/logger' -import { sequelizeTypescript } from '../../../initializers/database' -import { VideoShareModel } from '../../../models/video/video-share' -import { APProcessorOptions } from '../../../types/activitypub-processor.model' -import { MActorSignature, MVideoAccountLightBlacklistAllFiles } from '../../../types/models' -import { Notifier } from '../../notifier' -import { forwardVideoRelatedActivity } from '../send/shared/send-utils' -import { getOrCreateAPVideo } from '../videos' +import { ActivityAnnounce } from '@peertube/peertube-models' +import { getAPId } from '@server/lib/activitypub/activity.js' +import { retryTransactionWrapper } from '../../../helpers/database-utils.js' +import { logger } from '../../../helpers/logger.js' +import { sequelizeTypescript } from '../../../initializers/database.js' +import { VideoShareModel } from '../../../models/video/video-share.js' +import { APProcessorOptions } from '../../../types/activitypub-processor.model.js' +import { MActorSignature, MVideoAccountLightBlacklistAllFiles } from '../../../types/models/index.js' +import { Notifier } from '../../notifier/index.js' +import { forwardVideoRelatedActivity } from '../send/shared/send-utils.js' +import { getOrCreateAPVideo } from '../videos/index.js' async function processAnnounceActivity (options: APProcessorOptions) { const { activity, byActor: actorAnnouncer } = options diff --git a/server/lib/activitypub/process/process-create.ts b/server/server/lib/activitypub/process/process-create.ts similarity index 88% rename from server/lib/activitypub/process/process-create.ts rename to server/server/lib/activitypub/process/process-create.ts index 5f980de65..7366fe935 100644 --- a/server/lib/activitypub/process/process-create.ts +++ b/server/server/lib/activitypub/process/process-create.ts @@ -1,6 +1,6 @@ -import { isBlockedByServerOrAccount } from '@server/lib/blocklist' -import { isRedundancyAccepted } from '@server/lib/redundancy' -import { VideoModel } from '@server/models/video/video' +import { isBlockedByServerOrAccount } from '@server/lib/blocklist.js' +import { isRedundancyAccepted } from '@server/lib/redundancy.js' +import { VideoModel } from '@server/models/video/video.js' import { AbuseObject, ActivityCreate, @@ -11,20 +11,20 @@ import { VideoCommentObject, VideoObject, WatchActionObject -} from '@shared/models' -import { retryTransactionWrapper } from '../../../helpers/database-utils' -import { logger } from '../../../helpers/logger' -import { sequelizeTypescript } from '../../../initializers/database' -import { APProcessorOptions } from '../../../types/activitypub-processor.model' -import { MActorSignature, MCommentOwnerVideo, MVideoAccountLightBlacklistAllFiles } from '../../../types/models' -import { Notifier } from '../../notifier' -import { fetchAPObjectIfNeeded } from '../activity' -import { createOrUpdateCacheFile } from '../cache-file' -import { createOrUpdateLocalVideoViewer } from '../local-video-viewer' -import { createOrUpdateVideoPlaylist } from '../playlists' -import { forwardVideoRelatedActivity } from '../send/shared/send-utils' -import { resolveThread } from '../video-comments' -import { getOrCreateAPVideo } from '../videos' +} from '@peertube/peertube-models' +import { retryTransactionWrapper } from '../../../helpers/database-utils.js' +import { logger } from '../../../helpers/logger.js' +import { sequelizeTypescript } from '../../../initializers/database.js' +import { APProcessorOptions } from '../../../types/activitypub-processor.model.js' +import { MActorSignature, MCommentOwnerVideo, MVideoAccountLightBlacklistAllFiles } from '../../../types/models/index.js' +import { Notifier } from '../../notifier/index.js' +import { fetchAPObjectIfNeeded } from '../activity.js' +import { createOrUpdateCacheFile } from '../cache-file.js' +import { createOrUpdateLocalVideoViewer } from '../local-video-viewer.js' +import { createOrUpdateVideoPlaylist } from '../playlists/index.js' +import { forwardVideoRelatedActivity } from '../send/shared/send-utils.js' +import { resolveThread } from '../video-comments.js' +import { getOrCreateAPVideo } from '../videos/index.js' async function processCreateActivity (options: APProcessorOptions>) { const { activity, byActor } = options diff --git a/server/lib/activitypub/process/process-delete.ts b/server/server/lib/activitypub/process/process-delete.ts similarity index 94% rename from server/lib/activitypub/process/process-delete.ts rename to server/server/lib/activitypub/process/process-delete.ts index ac0e7e235..932e4cf94 100644 --- a/server/lib/activitypub/process/process-delete.ts +++ b/server/server/lib/activitypub/process/process-delete.ts @@ -1,12 +1,12 @@ -import { ActivityDelete } from '../../../../shared/models/activitypub' -import { retryTransactionWrapper } from '../../../helpers/database-utils' -import { logger } from '../../../helpers/logger' -import { sequelizeTypescript } from '../../../initializers/database' -import { ActorModel } from '../../../models/actor/actor' -import { VideoModel } from '../../../models/video/video' -import { VideoCommentModel } from '../../../models/video/video-comment' -import { VideoPlaylistModel } from '../../../models/video/video-playlist' -import { APProcessorOptions } from '../../../types/activitypub-processor.model' +import { ActivityDelete } from '@peertube/peertube-models' +import { retryTransactionWrapper } from '../../../helpers/database-utils.js' +import { logger } from '../../../helpers/logger.js' +import { sequelizeTypescript } from '../../../initializers/database.js' +import { ActorModel } from '../../../models/actor/actor.js' +import { VideoCommentModel } from '../../../models/video/video-comment.js' +import { VideoPlaylistModel } from '../../../models/video/video-playlist.js' +import { VideoModel } from '../../../models/video/video.js' +import { APProcessorOptions } from '../../../types/activitypub-processor.model.js' import { MAccountActor, MActor, @@ -15,8 +15,8 @@ import { MChannelAccountActor, MChannelActor, MCommentOwnerVideo -} from '../../../types/models' -import { forwardVideoRelatedActivity } from '../send/shared/send-utils' +} from '../../../types/models/index.js' +import { forwardVideoRelatedActivity } from '../send/shared/send-utils.js' async function processDeleteActivity (options: APProcessorOptions) { const { activity, byActor } = options diff --git a/server/lib/activitypub/process/process-dislike.ts b/server/server/lib/activitypub/process/process-dislike.ts similarity index 88% rename from server/lib/activitypub/process/process-dislike.ts rename to server/server/lib/activitypub/process/process-dislike.ts index 4e270f917..8040cad93 100644 --- a/server/lib/activitypub/process/process-dislike.ts +++ b/server/server/lib/activitypub/process/process-dislike.ts @@ -1,11 +1,11 @@ -import { VideoModel } from '@server/models/video/video' -import { ActivityDislike } from '@shared/models' -import { retryTransactionWrapper } from '../../../helpers/database-utils' -import { sequelizeTypescript } from '../../../initializers/database' -import { AccountVideoRateModel } from '../../../models/account/account-video-rate' -import { APProcessorOptions } from '../../../types/activitypub-processor.model' -import { MActorSignature } from '../../../types/models' -import { federateVideoIfNeeded, getOrCreateAPVideo } from '../videos' +import { VideoModel } from '@server/models/video/video.js' +import { ActivityDislike } from '@peertube/peertube-models' +import { retryTransactionWrapper } from '../../../helpers/database-utils.js' +import { sequelizeTypescript } from '../../../initializers/database.js' +import { AccountVideoRateModel } from '../../../models/account/account-video-rate.js' +import { APProcessorOptions } from '../../../types/activitypub-processor.model.js' +import { MActorSignature } from '../../../types/models/index.js' +import { federateVideoIfNeeded, getOrCreateAPVideo } from '../videos/index.js' async function processDislikeActivity (options: APProcessorOptions) { const { activity, byActor } = options diff --git a/server/lib/activitypub/process/process-flag.ts b/server/server/lib/activitypub/process/process-flag.ts similarity index 85% rename from server/lib/activitypub/process/process-flag.ts rename to server/server/lib/activitypub/process/process-flag.ts index bea285670..348eaebc2 100644 --- a/server/lib/activitypub/process/process-flag.ts +++ b/server/server/lib/activitypub/process/process-flag.ts @@ -1,15 +1,15 @@ -import { createAccountAbuse, createVideoAbuse, createVideoCommentAbuse } from '@server/lib/moderation' -import { AccountModel } from '@server/models/account/account' -import { VideoModel } from '@server/models/video/video' -import { VideoCommentModel } from '@server/models/video/video-comment' -import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' -import { AbuseState, ActivityFlag } from '@shared/models' -import { retryTransactionWrapper } from '../../../helpers/database-utils' -import { logger } from '../../../helpers/logger' -import { sequelizeTypescript } from '../../../initializers/database' -import { getAPId } from '../../../lib/activitypub/activity' -import { APProcessorOptions } from '../../../types/activitypub-processor.model' -import { MAccountDefault, MActorSignature, MCommentOwnerVideo } from '../../../types/models' +import { createAccountAbuse, createVideoAbuse, createVideoCommentAbuse } from '@server/lib/moderation.js' +import { AccountModel } from '@server/models/account/account.js' +import { VideoCommentModel } from '@server/models/video/video-comment.js' +import { VideoModel } from '@server/models/video/video.js' +import { abusePredefinedReasonsMap } from '@peertube/peertube-core-utils' +import { AbuseState, ActivityFlag } from '@peertube/peertube-models' +import { retryTransactionWrapper } from '../../../helpers/database-utils.js' +import { logger } from '../../../helpers/logger.js' +import { sequelizeTypescript } from '../../../initializers/database.js' +import { getAPId } from '../../../lib/activitypub/activity.js' +import { APProcessorOptions } from '../../../types/activitypub-processor.model.js' +import { MAccountDefault, MActorSignature, MCommentOwnerVideo } from '../../../types/models/index.js' async function processFlagActivity (options: APProcessorOptions) { const { activity, byActor } = options diff --git a/server/lib/activitypub/process/process-follow.ts b/server/server/lib/activitypub/process/process-follow.ts similarity index 88% rename from server/lib/activitypub/process/process-follow.ts rename to server/server/lib/activitypub/process/process-follow.ts index 7def753d5..172308048 100644 --- a/server/lib/activitypub/process/process-follow.ts +++ b/server/server/lib/activitypub/process/process-follow.ts @@ -1,20 +1,20 @@ -import { Transaction } from 'sequelize/types' -import { isBlockedByServerOrAccount } from '@server/lib/blocklist' -import { AccountModel } from '@server/models/account/account' -import { getServerActor } from '@server/models/application/application' -import { ActivityFollow } from '../../../../shared/models/activitypub' -import { retryTransactionWrapper } from '../../../helpers/database-utils' -import { logger } from '../../../helpers/logger' -import { CONFIG } from '../../../initializers/config' -import { sequelizeTypescript } from '../../../initializers/database' -import { getAPId } from '../../../lib/activitypub/activity' -import { ActorModel } from '../../../models/actor/actor' -import { ActorFollowModel } from '../../../models/actor/actor-follow' -import { APProcessorOptions } from '../../../types/activitypub-processor.model' -import { MActorFollow, MActorFull, MActorId, MActorSignature } from '../../../types/models' -import { Notifier } from '../../notifier' -import { autoFollowBackIfNeeded } from '../follow' -import { sendAccept, sendReject } from '../send' +import { Transaction } from 'sequelize' +import { ActivityFollow } from '@peertube/peertube-models' +import { isBlockedByServerOrAccount } from '@server/lib/blocklist.js' +import { AccountModel } from '@server/models/account/account.js' +import { getServerActor } from '@server/models/application/application.js' +import { retryTransactionWrapper } from '../../../helpers/database-utils.js' +import { logger } from '../../../helpers/logger.js' +import { CONFIG } from '../../../initializers/config.js' +import { sequelizeTypescript } from '../../../initializers/database.js' +import { getAPId } from '../../../lib/activitypub/activity.js' +import { ActorFollowModel } from '../../../models/actor/actor-follow.js' +import { ActorModel } from '../../../models/actor/actor.js' +import { APProcessorOptions } from '../../../types/activitypub-processor.model.js' +import { MActorFollow, MActorFull, MActorId, MActorSignature } from '../../../types/models/index.js' +import { Notifier } from '../../notifier/index.js' +import { autoFollowBackIfNeeded } from '../follow.js' +import { sendAccept, sendReject } from '../send/index.js' async function processFollowActivity (options: APProcessorOptions) { const { activity, byActor } = options diff --git a/server/lib/activitypub/process/process-like.ts b/server/server/lib/activitypub/process/process-like.ts similarity index 85% rename from server/lib/activitypub/process/process-like.ts rename to server/server/lib/activitypub/process/process-like.ts index 580a05bcd..03637f9a7 100644 --- a/server/lib/activitypub/process/process-like.ts +++ b/server/server/lib/activitypub/process/process-like.ts @@ -1,12 +1,12 @@ -import { VideoModel } from '@server/models/video/video' -import { ActivityLike } from '../../../../shared/models/activitypub' -import { retryTransactionWrapper } from '../../../helpers/database-utils' -import { sequelizeTypescript } from '../../../initializers/database' -import { getAPId } from '../../../lib/activitypub/activity' -import { AccountVideoRateModel } from '../../../models/account/account-video-rate' -import { APProcessorOptions } from '../../../types/activitypub-processor.model' -import { MActorSignature } from '../../../types/models' -import { federateVideoIfNeeded, getOrCreateAPVideo } from '../videos' +import { ActivityLike } from '@peertube/peertube-models' +import { VideoModel } from '@server/models/video/video.js' +import { retryTransactionWrapper } from '../../../helpers/database-utils.js' +import { sequelizeTypescript } from '../../../initializers/database.js' +import { getAPId } from '../../../lib/activitypub/activity.js' +import { AccountVideoRateModel } from '../../../models/account/account-video-rate.js' +import { APProcessorOptions } from '../../../types/activitypub-processor.model.js' +import { MActorSignature } from '../../../types/models/index.js' +import { federateVideoIfNeeded, getOrCreateAPVideo } from '../videos/index.js' async function processLikeActivity (options: APProcessorOptions) { const { activity, byActor } = options diff --git a/server/lib/activitypub/process/process-reject.ts b/server/server/lib/activitypub/process/process-reject.ts similarity index 87% rename from server/lib/activitypub/process/process-reject.ts rename to server/server/lib/activitypub/process/process-reject.ts index db7ff24d8..76dc14489 100644 --- a/server/lib/activitypub/process/process-reject.ts +++ b/server/server/lib/activitypub/process/process-reject.ts @@ -1,8 +1,8 @@ -import { ActivityReject } from '../../../../shared/models/activitypub/activity' -import { sequelizeTypescript } from '../../../initializers/database' -import { ActorFollowModel } from '../../../models/actor/actor-follow' -import { APProcessorOptions } from '../../../types/activitypub-processor.model' -import { MActor } from '../../../types/models' +import { ActivityReject } from '@peertube/peertube-models' +import { sequelizeTypescript } from '../../../initializers/database.js' +import { ActorFollowModel } from '../../../models/actor/actor-follow.js' +import { APProcessorOptions } from '../../../types/activitypub-processor.model.js' +import { MActor } from '../../../types/models/index.js' async function processRejectActivity (options: APProcessorOptions) { const { byActor: targetActor, inboxActor } = options diff --git a/server/lib/activitypub/process/process-undo.ts b/server/server/lib/activitypub/process/process-undo.ts similarity index 93% rename from server/lib/activitypub/process/process-undo.ts rename to server/server/lib/activitypub/process/process-undo.ts index a9d8199de..20a167f7b 100644 --- a/server/lib/activitypub/process/process-undo.ts +++ b/server/server/lib/activitypub/process/process-undo.ts @@ -1,4 +1,3 @@ -import { VideoModel } from '@server/models/video/video' import { ActivityAnnounce, ActivityCreate, @@ -8,20 +7,21 @@ import { ActivityUndo, ActivityUndoObject, CacheFileObject -} from '../../../../shared/models/activitypub' -import { retryTransactionWrapper } from '../../../helpers/database-utils' -import { logger } from '../../../helpers/logger' -import { sequelizeTypescript } from '../../../initializers/database' -import { AccountVideoRateModel } from '../../../models/account/account-video-rate' -import { ActorModel } from '../../../models/actor/actor' -import { ActorFollowModel } from '../../../models/actor/actor-follow' -import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy' -import { VideoShareModel } from '../../../models/video/video-share' -import { APProcessorOptions } from '../../../types/activitypub-processor.model' -import { MActorSignature } from '../../../types/models' -import { fetchAPObjectIfNeeded } from '../activity' -import { forwardVideoRelatedActivity } from '../send/shared/send-utils' -import { federateVideoIfNeeded, getOrCreateAPVideo } from '../videos' +} from '@peertube/peertube-models' +import { VideoModel } from '@server/models/video/video.js' +import { retryTransactionWrapper } from '../../../helpers/database-utils.js' +import { logger } from '../../../helpers/logger.js' +import { sequelizeTypescript } from '../../../initializers/database.js' +import { AccountVideoRateModel } from '../../../models/account/account-video-rate.js' +import { ActorFollowModel } from '../../../models/actor/actor-follow.js' +import { ActorModel } from '../../../models/actor/actor.js' +import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy.js' +import { VideoShareModel } from '../../../models/video/video-share.js' +import { APProcessorOptions } from '../../../types/activitypub-processor.model.js' +import { MActorSignature } from '../../../types/models/index.js' +import { fetchAPObjectIfNeeded } from '../activity.js' +import { forwardVideoRelatedActivity } from '../send/shared/send-utils.js' +import { federateVideoIfNeeded, getOrCreateAPVideo } from '../videos/index.js' async function processUndoActivity (options: APProcessorOptions>) { const { activity, byActor } = options diff --git a/server/lib/activitypub/process/process-update.ts b/server/server/lib/activitypub/process/process-update.ts similarity index 80% rename from server/lib/activitypub/process/process-update.ts rename to server/server/lib/activitypub/process/process-update.ts index 304ed9de6..d92b347ab 100644 --- a/server/lib/activitypub/process/process-update.ts +++ b/server/server/lib/activitypub/process/process-update.ts @@ -1,21 +1,26 @@ -import { isRedundancyAccepted } from '@server/lib/redundancy' -import { ActivityUpdate, ActivityUpdateObject, CacheFileObject, VideoObject } from '../../../../shared/models/activitypub' -import { ActivityPubActor } from '../../../../shared/models/activitypub/activitypub-actor' -import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object' -import { isCacheFileObjectValid } from '../../../helpers/custom-validators/activitypub/cache-file' -import { sanitizeAndCheckVideoTorrentObject } from '../../../helpers/custom-validators/activitypub/videos' -import { retryTransactionWrapper } from '../../../helpers/database-utils' -import { logger } from '../../../helpers/logger' -import { sequelizeTypescript } from '../../../initializers/database' -import { ActorModel } from '../../../models/actor/actor' -import { APProcessorOptions } from '../../../types/activitypub-processor.model' -import { MActorFull, MActorSignature } from '../../../types/models' -import { fetchAPObjectIfNeeded } from '../activity' -import { APActorUpdater } from '../actors/updater' -import { createOrUpdateCacheFile } from '../cache-file' -import { createOrUpdateVideoPlaylist } from '../playlists' -import { forwardVideoRelatedActivity } from '../send/shared/send-utils' -import { APVideoUpdater, getOrCreateAPVideo } from '../videos' +import { + ActivityPubActor, + ActivityUpdate, + ActivityUpdateObject, + CacheFileObject, + PlaylistObject, + VideoObject +} from '@peertube/peertube-models' +import { isRedundancyAccepted } from '@server/lib/redundancy.js' +import { isCacheFileObjectValid } from '../../../helpers/custom-validators/activitypub/cache-file.js' +import { sanitizeAndCheckVideoTorrentObject } from '../../../helpers/custom-validators/activitypub/videos.js' +import { retryTransactionWrapper } from '../../../helpers/database-utils.js' +import { logger } from '../../../helpers/logger.js' +import { sequelizeTypescript } from '../../../initializers/database.js' +import { ActorModel } from '../../../models/actor/actor.js' +import { APProcessorOptions } from '../../../types/activitypub-processor.model.js' +import { MActorFull, MActorSignature } from '../../../types/models/index.js' +import { fetchAPObjectIfNeeded } from '../activity.js' +import { APActorUpdater } from '../actors/updater.js' +import { createOrUpdateCacheFile } from '../cache-file.js' +import { createOrUpdateVideoPlaylist } from '../playlists/index.js' +import { forwardVideoRelatedActivity } from '../send/shared/send-utils.js' +import { APVideoUpdater, getOrCreateAPVideo } from '../videos/index.js' async function processUpdateActivity (options: APProcessorOptions>) { const { activity, byActor } = options diff --git a/server/lib/activitypub/process/process-view.ts b/server/server/lib/activitypub/process/process-view.ts similarity index 84% rename from server/lib/activitypub/process/process-view.ts rename to server/server/lib/activitypub/process/process-view.ts index e49506d82..c96948e85 100644 --- a/server/lib/activitypub/process/process-view.ts +++ b/server/server/lib/activitypub/process/process-view.ts @@ -1,9 +1,9 @@ -import { VideoViewsManager } from '@server/lib/views/video-views-manager' -import { ActivityView } from '../../../../shared/models/activitypub' -import { APProcessorOptions } from '../../../types/activitypub-processor.model' -import { MActorSignature } from '../../../types/models' -import { forwardVideoRelatedActivity } from '../send/shared/send-utils' -import { getOrCreateAPVideo } from '../videos' +import { VideoViewsManager } from '@server/lib/views/video-views-manager.js' +import { ActivityView } from '@peertube/peertube-models' +import { APProcessorOptions } from '../../../types/activitypub-processor.model.js' +import { MActorSignature } from '../../../types/models/index.js' +import { forwardVideoRelatedActivity } from '../send/shared/send-utils.js' +import { getOrCreateAPVideo } from '../videos/index.js' async function processViewActivity (options: APProcessorOptions) { const { activity, byActor } = options diff --git a/server/lib/activitypub/process/process.ts b/server/server/lib/activitypub/process/process.ts similarity index 69% rename from server/lib/activitypub/process/process.ts rename to server/server/lib/activitypub/process/process.ts index 2bc3dce03..abc1ebf6f 100644 --- a/server/lib/activitypub/process/process.ts +++ b/server/server/lib/activitypub/process/process.ts @@ -1,23 +1,23 @@ -import { StatsManager } from '@server/lib/stat-manager' -import { Activity, ActivityType } from '../../../../shared/models/activitypub' -import { logger } from '../../../helpers/logger' -import { APProcessorOptions } from '../../../types/activitypub-processor.model' -import { MActorDefault, MActorSignature } from '../../../types/models' -import { getAPId } from '../activity' -import { getOrCreateAPActor } from '../actors' -import { checkUrlsSameHost } from '../url' -import { processAcceptActivity } from './process-accept' -import { processAnnounceActivity } from './process-announce' -import { processCreateActivity } from './process-create' -import { processDeleteActivity } from './process-delete' -import { processDislikeActivity } from './process-dislike' -import { processFlagActivity } from './process-flag' -import { processFollowActivity } from './process-follow' -import { processLikeActivity } from './process-like' -import { processRejectActivity } from './process-reject' -import { processUndoActivity } from './process-undo' -import { processUpdateActivity } from './process-update' -import { processViewActivity } from './process-view' +import { StatsManager } from '@server/lib/stat-manager.js' +import { Activity, ActivityType } from '@peertube/peertube-models' +import { logger } from '../../../helpers/logger.js' +import { APProcessorOptions } from '../../../types/activitypub-processor.model.js' +import { MActorDefault, MActorSignature } from '../../../types/models/index.js' +import { getAPId } from '../activity.js' +import { getOrCreateAPActor } from '../actors/index.js' +import { checkUrlsSameHost } from '../url.js' +import { processAcceptActivity } from './process-accept.js' +import { processAnnounceActivity } from './process-announce.js' +import { processCreateActivity } from './process-create.js' +import { processDeleteActivity } from './process-delete.js' +import { processDislikeActivity } from './process-dislike.js' +import { processFlagActivity } from './process-flag.js' +import { processFollowActivity } from './process-follow.js' +import { processLikeActivity } from './process-like.js' +import { processRejectActivity } from './process-reject.js' +import { processUndoActivity } from './process-undo.js' +import { processUpdateActivity } from './process-update.js' +import { processViewActivity } from './process-view.js' const processActivity: { [ P in ActivityType ]: (options: APProcessorOptions) => Promise } = { Create: processCreateActivity, diff --git a/server/lib/activitypub/send/http.ts b/server/server/lib/activitypub/send/http.ts similarity index 54% rename from server/lib/activitypub/send/http.ts rename to server/server/lib/activitypub/send/http.ts index b461aa55d..8d15b970d 100644 --- a/server/lib/activitypub/send/http.ts +++ b/server/server/lib/activitypub/send/http.ts @@ -1,14 +1,14 @@ -import { buildDigest, signJsonLDObject } from '@server/helpers/peertube-crypto' -import { ACTIVITY_PUB, HTTP_SIGNATURE } from '@server/initializers/constants' -import { ActorModel } from '@server/models/actor/actor' -import { getServerActor } from '@server/models/application/application' -import { MActor } from '@server/types/models' -import { ContextType } from '@shared/models/activitypub/context' -import { activityPubContextify } from '../context' +import { ContextType } from '@peertube/peertube-models' +import { signAndContextify } from '@server/helpers/activity-pub-utils.js' +import { HTTP_SIGNATURE } from '@server/initializers/constants.js' +import { ActorModel } from '@server/models/actor/actor.js' +import { getServerActor } from '@server/models/application/application.js' +import { MActor } from '@server/types/models/index.js' +import { getContextFilter } from '../context.js' type Payload = { body: T, contextType: ContextType, signatureActorId?: number } -async function computeBody ( +export async function computeBody ( payload: Payload ): Promise { let body = payload.body @@ -17,13 +17,13 @@ async function computeBody ( const actorSignature = await ActorModel.load(payload.signatureActorId) if (!actorSignature) throw new Error('Unknown signature actor id.') - body = await signAndContextify(actorSignature, payload.body, payload.contextType) + body = await signAndContextify(actorSignature, payload.body, payload.contextType, getContextFilter()) } return body } -async function buildSignedRequestOptions (options: { +export async function buildSignedRequestOptions (options: { signatureActorId?: number hasPayload: boolean }) { @@ -48,26 +48,3 @@ async function buildSignedRequestOptions (options: { : HTTP_SIGNATURE.HEADERS_TO_SIGN_WITHOUT_PAYLOAD } } - -function buildGlobalHeaders (body: any) { - return { - 'digest': buildDigest(body), - 'content-type': 'application/activity+json', - 'accept': ACTIVITY_PUB.ACCEPT_HEADER - } -} - -async function signAndContextify (byActor: MActor, data: T, contextType: ContextType | null) { - const activity = contextType - ? await activityPubContextify(data, contextType) - : data - - return signJsonLDObject(byActor, activity) -} - -export { - buildGlobalHeaders, - computeBody, - buildSignedRequestOptions, - signAndContextify -} diff --git a/server/server/lib/activitypub/send/index.ts b/server/server/lib/activitypub/send/index.ts new file mode 100644 index 000000000..8711cb17b --- /dev/null +++ b/server/server/lib/activitypub/send/index.ts @@ -0,0 +1,10 @@ +export * from './http.js' +export * from './send-accept.js' +export * from './send-announce.js' +export * from './send-create.js' +export * from './send-delete.js' +export * from './send-follow.js' +export * from './send-like.js' +export * from './send-reject.js' +export * from './send-undo.js' +export * from './send-update.js' diff --git a/server/lib/activitypub/send/send-accept.ts b/server/server/lib/activitypub/send/send-accept.ts similarity index 78% rename from server/lib/activitypub/send/send-accept.ts rename to server/server/lib/activitypub/send/send-accept.ts index 4c9bcbb0b..8486564b8 100644 --- a/server/lib/activitypub/send/send-accept.ts +++ b/server/server/lib/activitypub/send/send-accept.ts @@ -1,9 +1,9 @@ -import { ActivityAccept, ActivityFollow } from '@shared/models' -import { logger } from '../../../helpers/logger' -import { MActor, MActorFollowActors } from '../../../types/models' -import { getLocalActorFollowAcceptActivityPubUrl } from '../url' -import { buildFollowActivity } from './send-follow' -import { unicastTo } from './shared/send-utils' +import { ActivityAccept, ActivityFollow } from '@peertube/peertube-models' +import { logger } from '../../../helpers/logger.js' +import { MActor, MActorFollowActors } from '../../../types/models/index.js' +import { getLocalActorFollowAcceptActivityPubUrl } from '../url.js' +import { buildFollowActivity } from './send-follow.js' +import { unicastTo } from './shared/send-utils.js' function sendAccept (actorFollow: MActorFollowActors) { const follower = actorFollow.ActorFollower diff --git a/server/lib/activitypub/send/send-announce.ts b/server/server/lib/activitypub/send/send-announce.ts similarity index 79% rename from server/lib/activitypub/send/send-announce.ts rename to server/server/lib/activitypub/send/send-announce.ts index 6c078b047..ab7da2c86 100644 --- a/server/lib/activitypub/send/send-announce.ts +++ b/server/server/lib/activitypub/send/send-announce.ts @@ -1,11 +1,11 @@ import { Transaction } from 'sequelize' -import { ActivityAnnounce, ActivityAudience } from '@shared/models' -import { logger } from '../../../helpers/logger' -import { MActorLight, MVideo } from '../../../types/models' -import { MVideoShare } from '../../../types/models/video' -import { audiencify, getAudience } from '../audience' -import { getActorsInvolvedInVideo, getAudienceFromFollowersOf } from './shared' -import { broadcastToFollowers } from './shared/send-utils' +import { ActivityAnnounce, ActivityAudience } from '@peertube/peertube-models' +import { logger } from '../../../helpers/logger.js' +import { MActorLight, MVideo } from '../../../types/models/index.js' +import { MVideoShare } from '../../../types/models/video/index.js' +import { audiencify, getAudience } from '../audience.js' +import { getActorsInvolvedInVideo, getAudienceFromFollowersOf } from './shared/index.js' +import { broadcastToFollowers } from './shared/send-utils.js' async function buildAnnounceWithVideoAudience ( byActor: MActorLight, diff --git a/server/lib/activitypub/send/send-create.ts b/server/server/lib/activitypub/send/send-create.ts similarity index 97% rename from server/lib/activitypub/send/send-create.ts rename to server/server/lib/activitypub/send/send-create.ts index 2cd4db14d..7f9721be3 100644 --- a/server/lib/activitypub/send/send-create.ts +++ b/server/server/lib/activitypub/send/send-create.ts @@ -1,5 +1,5 @@ import { Transaction } from 'sequelize' -import { getServerActor } from '@server/models/application/application' +import { getServerActor } from '@server/models/application/application.js' import { ActivityAudience, ActivityCreate, @@ -8,9 +8,9 @@ import { VideoCommentObject, VideoPlaylistPrivacy, VideoPrivacy -} from '@shared/models' -import { logger, loggerTagsFactory } from '../../../helpers/logger' -import { VideoCommentModel } from '../../../models/video/video-comment' +} from '@peertube/peertube-models' +import { logger, loggerTagsFactory } from '../../../helpers/logger.js' +import { VideoCommentModel } from '../../../models/video/video-comment.js' import { MActorLight, MCommentOwnerVideo, @@ -20,8 +20,8 @@ import { MVideoPlaylistFull, MVideoRedundancyFileVideo, MVideoRedundancyStreamingPlaylistVideo -} from '../../../types/models' -import { audiencify, getAudience } from '../audience' +} from '../../../types/models/index.js' +import { audiencify, getAudience } from '../audience.js' import { broadcastToActors, broadcastToFollowers, @@ -31,7 +31,7 @@ import { sendVideoActivityToOrigin, sendVideoRelatedActivity, unicastTo -} from './shared' +} from './shared/index.js' const lTags = loggerTagsFactory('ap', 'create') diff --git a/server/lib/activitypub/send/send-delete.ts b/server/server/lib/activitypub/send/send-delete.ts similarity index 90% rename from server/lib/activitypub/send/send-delete.ts rename to server/server/lib/activitypub/send/send-delete.ts index 0d85d9001..2f83da15d 100644 --- a/server/lib/activitypub/send/send-delete.ts +++ b/server/server/lib/activitypub/send/send-delete.ts @@ -1,16 +1,16 @@ import { Transaction } from 'sequelize' -import { getServerActor } from '@server/models/application/application' -import { ActivityAudience, ActivityDelete } from '@shared/models' -import { logger } from '../../../helpers/logger' -import { ActorModel } from '../../../models/actor/actor' -import { VideoCommentModel } from '../../../models/video/video-comment' -import { VideoShareModel } from '../../../models/video/video-share' -import { MActorUrl } from '../../../types/models' -import { MCommentOwnerVideo, MVideoAccountLight, MVideoPlaylistFullSummary } from '../../../types/models/video' -import { audiencify } from '../audience' -import { getDeleteActivityPubUrl } from '../url' -import { getActorsInvolvedInVideo, getVideoCommentAudience } from './shared' -import { broadcastToActors, broadcastToFollowers, sendVideoRelatedActivity, unicastTo } from './shared/send-utils' +import { getServerActor } from '@server/models/application/application.js' +import { ActivityAudience, ActivityDelete } from '@peertube/peertube-models' +import { logger } from '../../../helpers/logger.js' +import { ActorModel } from '../../../models/actor/actor.js' +import { VideoCommentModel } from '../../../models/video/video-comment.js' +import { VideoShareModel } from '../../../models/video/video-share.js' +import { MActorUrl } from '../../../types/models/index.js' +import { MCommentOwnerVideo, MVideoAccountLight, MVideoPlaylistFullSummary } from '../../../types/models/video/index.js' +import { audiencify } from '../audience.js' +import { getDeleteActivityPubUrl } from '../url.js' +import { getActorsInvolvedInVideo, getVideoCommentAudience } from './shared/index.js' +import { broadcastToActors, broadcastToFollowers, sendVideoRelatedActivity, unicastTo } from './shared/send-utils.js' async function sendDeleteVideo (video: MVideoAccountLight, transaction: Transaction) { logger.info('Creating job to broadcast delete of video %s.', video.url) diff --git a/server/lib/activitypub/send/send-dislike.ts b/server/server/lib/activitypub/send/send-dislike.ts similarity index 78% rename from server/lib/activitypub/send/send-dislike.ts rename to server/server/lib/activitypub/send/send-dislike.ts index 959e74823..0c4dcca5f 100644 --- a/server/lib/activitypub/send/send-dislike.ts +++ b/server/server/lib/activitypub/send/send-dislike.ts @@ -1,10 +1,10 @@ import { Transaction } from 'sequelize' -import { ActivityAudience, ActivityDislike } from '@shared/models' -import { logger } from '../../../helpers/logger' -import { MActor, MActorAudience, MVideoAccountLight, MVideoUrl } from '../../../types/models' -import { audiencify, getAudience } from '../audience' -import { getVideoDislikeActivityPubUrlByLocalActor } from '../url' -import { sendVideoActivityToOrigin } from './shared/send-utils' +import { ActivityAudience, ActivityDislike } from '@peertube/peertube-models' +import { logger } from '../../../helpers/logger.js' +import { MActor, MActorAudience, MVideoAccountLight, MVideoUrl } from '../../../types/models/index.js' +import { audiencify, getAudience } from '../audience.js' +import { getVideoDislikeActivityPubUrlByLocalActor } from '../url.js' +import { sendVideoActivityToOrigin } from './shared/send-utils.js' function sendDislike (byActor: MActor, video: MVideoAccountLight, transaction: Transaction) { logger.info('Creating job to dislike %s.', video.url) diff --git a/server/lib/activitypub/send/send-flag.ts b/server/server/lib/activitypub/send/send-flag.ts similarity index 79% rename from server/lib/activitypub/send/send-flag.ts rename to server/server/lib/activitypub/send/send-flag.ts index 138eb5adc..bc9ba91e0 100644 --- a/server/lib/activitypub/send/send-flag.ts +++ b/server/server/lib/activitypub/send/send-flag.ts @@ -1,10 +1,10 @@ import { Transaction } from 'sequelize' -import { ActivityAudience, ActivityFlag } from '@shared/models' -import { logger } from '../../../helpers/logger' -import { MAbuseAP, MAccountLight, MActor } from '../../../types/models' -import { audiencify, getAudience } from '../audience' -import { getLocalAbuseActivityPubUrl } from '../url' -import { unicastTo } from './shared/send-utils' +import { ActivityAudience, ActivityFlag } from '@peertube/peertube-models' +import { logger } from '../../../helpers/logger.js' +import { MAbuseAP, MAccountLight, MActor } from '../../../types/models/index.js' +import { audiencify, getAudience } from '../audience.js' +import { getLocalAbuseActivityPubUrl } from '../url.js' +import { unicastTo } from './shared/send-utils.js' function sendAbuse (byActor: MActor, abuse: MAbuseAP, flaggedAccount: MAccountLight, t: Transaction) { if (!flaggedAccount.Actor.serverId) return // Local user diff --git a/server/lib/activitypub/send/send-follow.ts b/server/server/lib/activitypub/send/send-follow.ts similarity index 84% rename from server/lib/activitypub/send/send-follow.ts rename to server/server/lib/activitypub/send/send-follow.ts index 57501dadb..26ea030ce 100644 --- a/server/lib/activitypub/send/send-follow.ts +++ b/server/server/lib/activitypub/send/send-follow.ts @@ -1,8 +1,8 @@ import { Transaction } from 'sequelize' -import { ActivityFollow } from '@shared/models' -import { logger } from '../../../helpers/logger' -import { MActor, MActorFollowActors } from '../../../types/models' -import { unicastTo } from './shared/send-utils' +import { ActivityFollow } from '@peertube/peertube-models' +import { logger } from '../../../helpers/logger.js' +import { MActor, MActorFollowActors } from '../../../types/models/index.js' +import { unicastTo } from './shared/send-utils.js' function sendFollow (actorFollow: MActorFollowActors, t: Transaction) { const me = actorFollow.ActorFollower diff --git a/server/lib/activitypub/send/send-like.ts b/server/server/lib/activitypub/send/send-like.ts similarity index 73% rename from server/lib/activitypub/send/send-like.ts rename to server/server/lib/activitypub/send/send-like.ts index 46c9fdec9..701c9325d 100644 --- a/server/lib/activitypub/send/send-like.ts +++ b/server/server/lib/activitypub/send/send-like.ts @@ -1,10 +1,10 @@ import { Transaction } from 'sequelize' -import { ActivityAudience, ActivityLike } from '@shared/models' -import { logger } from '../../../helpers/logger' -import { MActor, MActorAudience, MVideoAccountLight, MVideoUrl } from '../../../types/models' -import { audiencify, getAudience } from '../audience' -import { getVideoLikeActivityPubUrlByLocalActor } from '../url' -import { sendVideoActivityToOrigin } from './shared/send-utils' +import { ActivityAudience, ActivityLike } from '@peertube/peertube-models' +import { logger } from '../../../helpers/logger.js' +import { MActor, MActorAudience, MVideoAccountLight, MVideoUrl } from '../../../types/models/index.js' +import { audiencify, getAudience } from '../audience.js' +import { getVideoLikeActivityPubUrlByLocalActor } from '../url.js' +import { sendVideoActivityToOrigin } from './shared/send-utils.js' function sendLike (byActor: MActor, video: MVideoAccountLight, transaction: Transaction) { logger.info('Creating job to like %s.', video.url) diff --git a/server/lib/activitypub/send/send-reject.ts b/server/server/lib/activitypub/send/send-reject.ts similarity index 73% rename from server/lib/activitypub/send/send-reject.ts rename to server/server/lib/activitypub/send/send-reject.ts index a5f8c2ecf..4076d4d73 100644 --- a/server/lib/activitypub/send/send-reject.ts +++ b/server/server/lib/activitypub/send/send-reject.ts @@ -1,9 +1,9 @@ -import { ActivityFollow, ActivityReject } from '@shared/models' -import { logger } from '../../../helpers/logger' -import { MActor } from '../../../types/models' -import { getLocalActorFollowRejectActivityPubUrl } from '../url' -import { buildFollowActivity } from './send-follow' -import { unicastTo } from './shared/send-utils' +import { ActivityFollow, ActivityReject } from '@peertube/peertube-models' +import { logger } from '../../../helpers/logger.js' +import { MActor } from '../../../types/models/index.js' +import { getLocalActorFollowRejectActivityPubUrl } from '../url.js' +import { buildFollowActivity } from './send-follow.js' +import { unicastTo } from './shared/send-utils.js' function sendReject (followUrl: string, follower: MActor, following: MActor) { if (!follower.serverId) { // This should never happen diff --git a/server/lib/activitypub/send/send-undo.ts b/server/server/lib/activitypub/send/send-undo.ts similarity index 88% rename from server/lib/activitypub/send/send-undo.ts rename to server/server/lib/activitypub/send/send-undo.ts index b0b48c9c4..6db165734 100644 --- a/server/lib/activitypub/send/send-undo.ts +++ b/server/server/lib/activitypub/send/send-undo.ts @@ -1,7 +1,7 @@ import { Transaction } from 'sequelize' -import { ActivityAudience, ActivityDislike, ActivityLike, ActivityUndo, ActivityUndoObject, ContextType } from '@shared/models' -import { logger } from '../../../helpers/logger' -import { VideoModel } from '../../../models/video/video' +import { ActivityAudience, ActivityDislike, ActivityLike, ActivityUndo, ActivityUndoObject, ContextType } from '@peertube/peertube-models' +import { logger } from '../../../helpers/logger.js' +import { VideoModel } from '../../../models/video/video.js' import { MActor, MActorAudience, @@ -11,15 +11,15 @@ import { MVideoAccountLight, MVideoRedundancyVideo, MVideoShare -} from '../../../types/models' -import { audiencify, getAudience } from '../audience' -import { getUndoActivityPubUrl, getVideoDislikeActivityPubUrlByLocalActor, getVideoLikeActivityPubUrlByLocalActor } from '../url' -import { buildAnnounceWithVideoAudience } from './send-announce' -import { buildCreateActivity } from './send-create' -import { buildDislikeActivity } from './send-dislike' -import { buildFollowActivity } from './send-follow' -import { buildLikeActivity } from './send-like' -import { broadcastToFollowers, sendVideoActivityToOrigin, sendVideoRelatedActivity, unicastTo } from './shared/send-utils' +} from '../../../types/models/index.js' +import { audiencify, getAudience } from '../audience.js' +import { getUndoActivityPubUrl, getVideoDislikeActivityPubUrlByLocalActor, getVideoLikeActivityPubUrlByLocalActor } from '../url.js' +import { buildAnnounceWithVideoAudience } from './send-announce.js' +import { buildCreateActivity } from './send-create.js' +import { buildDislikeActivity } from './send-dislike.js' +import { buildFollowActivity } from './send-follow.js' +import { buildLikeActivity } from './send-like.js' +import { broadcastToFollowers, sendVideoActivityToOrigin, sendVideoRelatedActivity, unicastTo } from './shared/send-utils.js' function sendUndoFollow (actorFollow: MActorFollowActors, t: Transaction) { const me = actorFollow.ActorFollower diff --git a/server/lib/activitypub/send/send-update.ts b/server/server/lib/activitypub/send/send-update.ts similarity index 90% rename from server/lib/activitypub/send/send-update.ts rename to server/server/lib/activitypub/send/send-update.ts index f3fb741c6..f6b714c16 100644 --- a/server/lib/activitypub/send/send-update.ts +++ b/server/server/lib/activitypub/send/send-update.ts @@ -1,10 +1,10 @@ import { Transaction } from 'sequelize' -import { getServerActor } from '@server/models/application/application' -import { ActivityAudience, ActivityUpdate, ActivityUpdateObject, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' -import { logger } from '../../../helpers/logger' -import { AccountModel } from '../../../models/account/account' -import { VideoModel } from '../../../models/video/video' -import { VideoShareModel } from '../../../models/video/video-share' +import { getServerActor } from '@server/models/application/application.js' +import { ActivityAudience, ActivityUpdate, ActivityUpdateObject, VideoPlaylistPrivacy, VideoPrivacy } from '@peertube/peertube-models' +import { logger } from '../../../helpers/logger.js' +import { AccountModel } from '../../../models/account/account.js' +import { VideoModel } from '../../../models/video/video.js' +import { VideoShareModel } from '../../../models/video/video-share.js' import { MAccountDefault, MActor, @@ -13,11 +13,11 @@ import { MVideoAPLight, MVideoPlaylistFull, MVideoRedundancyVideo -} from '../../../types/models' -import { audiencify, getAudience } from '../audience' -import { getUpdateActivityPubUrl } from '../url' -import { getActorsInvolvedInVideo } from './shared' -import { broadcastToFollowers, sendVideoRelatedActivity } from './shared/send-utils' +} from '../../../types/models/index.js' +import { audiencify, getAudience } from '../audience.js' +import { getUpdateActivityPubUrl } from '../url.js' +import { getActorsInvolvedInVideo } from './shared/index.js' +import { broadcastToFollowers, sendVideoRelatedActivity } from './shared/send-utils.js' async function sendUpdateVideo (videoArg: MVideoAPLight, transaction: Transaction, overriddenByActor?: MActor) { if (!videoArg.hasPrivacyForFederation()) return undefined diff --git a/server/lib/activitypub/send/send-view.ts b/server/server/lib/activitypub/send/send-view.ts similarity index 81% rename from server/lib/activitypub/send/send-view.ts rename to server/server/lib/activitypub/send/send-view.ts index bf3451603..10cd9508f 100644 --- a/server/lib/activitypub/send/send-view.ts +++ b/server/server/lib/activitypub/send/send-view.ts @@ -1,11 +1,11 @@ import { Transaction } from 'sequelize' -import { VideoViewsManager } from '@server/lib/views/video-views-manager' -import { MActorAudience, MActorLight, MVideoImmutable, MVideoUrl } from '@server/types/models' -import { ActivityAudience, ActivityView } from '@shared/models' -import { logger } from '../../../helpers/logger' -import { audiencify, getAudience } from '../audience' -import { getLocalVideoViewActivityPubUrl } from '../url' -import { sendVideoRelatedActivity } from './shared/send-utils' +import { VideoViewsManager } from '@server/lib/views/video-views-manager.js' +import { MActorAudience, MActorLight, MVideoImmutable, MVideoUrl } from '@server/types/models/index.js' +import { ActivityAudience, ActivityView } from '@peertube/peertube-models' +import { logger } from '../../../helpers/logger.js' +import { audiencify, getAudience } from '../audience.js' +import { getLocalVideoViewActivityPubUrl } from '../url.js' +import { sendVideoRelatedActivity } from './shared/send-utils.js' type ViewType = 'view' | 'viewer' diff --git a/server/lib/activitypub/send/shared/audience-utils.ts b/server/server/lib/activitypub/send/shared/audience-utils.ts similarity index 86% rename from server/lib/activitypub/send/shared/audience-utils.ts rename to server/server/lib/activitypub/send/shared/audience-utils.ts index 2f6b0741d..ac88c4567 100644 --- a/server/lib/activitypub/send/shared/audience-utils.ts +++ b/server/server/lib/activitypub/send/shared/audience-utils.ts @@ -1,10 +1,10 @@ import { Transaction } from 'sequelize' -import { ACTIVITY_PUB } from '@server/initializers/constants' -import { ActorModel } from '@server/models/actor/actor' -import { VideoModel } from '@server/models/video/video' -import { VideoShareModel } from '@server/models/video/video-share' -import { MActorFollowersUrl, MActorUrl, MCommentOwner, MCommentOwnerVideo, MVideoId } from '@server/types/models' -import { ActivityAudience } from '@shared/models' +import { ACTIVITY_PUB } from '@server/initializers/constants.js' +import { ActorModel } from '@server/models/actor/actor.js' +import { VideoModel } from '@server/models/video/video.js' +import { VideoShareModel } from '@server/models/video/video-share.js' +import { MActorFollowersUrl, MActorUrl, MCommentOwner, MCommentOwnerVideo, MVideoId } from '@server/types/models/index.js' +import { ActivityAudience } from '@peertube/peertube-models' function getOriginVideoAudience (accountActor: MActorUrl, actorsInvolvedInVideo: MActorFollowersUrl[] = []): ActivityAudience { return { diff --git a/server/server/lib/activitypub/send/shared/index.ts b/server/server/lib/activitypub/send/shared/index.ts new file mode 100644 index 000000000..25beeafbf --- /dev/null +++ b/server/server/lib/activitypub/send/shared/index.ts @@ -0,0 +1,2 @@ +export * from './audience-utils.js' +export * from './send-utils.js' diff --git a/server/lib/activitypub/send/shared/send-utils.ts b/server/server/lib/activitypub/send/shared/send-utils.ts similarity index 94% rename from server/lib/activitypub/send/shared/send-utils.ts rename to server/server/lib/activitypub/send/shared/send-utils.ts index 2bc1ef8f5..29e22ef58 100644 --- a/server/lib/activitypub/send/shared/send-utils.ts +++ b/server/server/lib/activitypub/send/shared/send-utils.ts @@ -1,15 +1,22 @@ import { Transaction } from 'sequelize' -import { ActorFollowHealthCache } from '@server/lib/actor-follow-health-cache' -import { getServerActor } from '@server/models/application/application' -import { Activity, ActivityAudience, ActivitypubHttpBroadcastPayload } from '@shared/models' -import { ContextType } from '@shared/models/activitypub/context' -import { afterCommitIfTransaction } from '../../../../helpers/database-utils' -import { logger } from '../../../../helpers/logger' -import { ActorModel } from '../../../../models/actor/actor' -import { ActorFollowModel } from '../../../../models/actor/actor-follow' -import { MActor, MActorId, MActorLight, MActorWithInboxes, MVideoAccountLight, MVideoId, MVideoImmutable } from '../../../../types/models' -import { JobQueue } from '../../../job-queue' -import { getActorsInvolvedInVideo, getAudienceFromFollowersOf, getOriginVideoAudience } from './audience-utils' +import { Activity, ActivityAudience, ActivitypubHttpBroadcastPayload, ContextType } from '@peertube/peertube-models' +import { ActorFollowHealthCache } from '@server/lib/actor-follow-health-cache.js' +import { getServerActor } from '@server/models/application/application.js' +import { afterCommitIfTransaction } from '../../../../helpers/database-utils.js' +import { logger } from '../../../../helpers/logger.js' +import { ActorFollowModel } from '../../../../models/actor/actor-follow.js' +import { ActorModel } from '../../../../models/actor/actor.js' +import { + MActor, + MActorId, + MActorLight, + MActorWithInboxes, + MVideoAccountLight, + MVideoId, + MVideoImmutable +} from '../../../../types/models/index.js' +import { JobQueue } from '../../../job-queue/index.js' +import { getActorsInvolvedInVideo, getAudienceFromFollowersOf, getOriginVideoAudience } from './audience-utils.js' async function sendVideoRelatedActivity (activityBuilder: (audience: ActivityAudience) => Activity, options: { byActor: MActorLight diff --git a/server/lib/activitypub/share.ts b/server/server/lib/activitypub/share.ts similarity index 87% rename from server/lib/activitypub/share.ts rename to server/server/lib/activitypub/share.ts index 792a73f2a..b1e49861e 100644 --- a/server/lib/activitypub/share.ts +++ b/server/server/lib/activitypub/share.ts @@ -1,14 +1,14 @@ -import { map } from 'bluebird' +import Bluebird from 'bluebird' import { Transaction } from 'sequelize' -import { getServerActor } from '@server/models/application/application' -import { logger, loggerTagsFactory } from '../../helpers/logger' -import { CRAWL_REQUEST_CONCURRENCY } from '../../initializers/constants' -import { VideoShareModel } from '../../models/video/video-share' -import { MChannelActorLight, MVideo, MVideoAccountLight, MVideoId } from '../../types/models/video' -import { fetchAP, getAPId } from './activity' -import { getOrCreateAPActor } from './actors' -import { sendUndoAnnounce, sendVideoAnnounce } from './send' -import { checkUrlsSameHost, getLocalVideoAnnounceActivityPubUrl } from './url' +import { getServerActor } from '@server/models/application/application.js' +import { logger, loggerTagsFactory } from '../../helpers/logger.js' +import { CRAWL_REQUEST_CONCURRENCY } from '../../initializers/constants.js' +import { VideoShareModel } from '../../models/video/video-share.js' +import { MChannelActorLight, MVideo, MVideoAccountLight, MVideoId } from '../../types/models/video/index.js' +import { fetchAP, getAPId } from './activity.js' +import { getOrCreateAPActor } from './actors/index.js' +import { sendUndoAnnounce, sendVideoAnnounce } from './send/index.js' +import { checkUrlsSameHost, getLocalVideoAnnounceActivityPubUrl } from './url.js' const lTags = loggerTagsFactory('share') @@ -37,7 +37,7 @@ async function changeVideoChannelShare ( } async function addVideoShares (shareUrls: string[], video: MVideoId) { - await map(shareUrls, async shareUrl => { + await Bluebird.map(shareUrls, async shareUrl => { try { await addVideoShare(shareUrl, video) } catch (err) { diff --git a/server/lib/activitypub/url.ts b/server/server/lib/activitypub/url.ts similarity index 97% rename from server/lib/activitypub/url.ts rename to server/server/lib/activitypub/url.ts index 5cdac71bf..73f6f4849 100644 --- a/server/lib/activitypub/url.ts +++ b/server/server/lib/activitypub/url.ts @@ -1,4 +1,4 @@ -import { REMOTE_SCHEME, WEBSERVER } from '../../initializers/constants' +import { REMOTE_SCHEME, WEBSERVER } from '../../initializers/constants.js' import { MAbuseFull, MAbuseId, @@ -13,10 +13,10 @@ import { MVideoUrl, MVideoUUID, MVideoWithHost -} from '../../types/models' -import { MVideoFileVideoUUID } from '../../types/models/video/video-file' -import { MVideoPlaylist, MVideoPlaylistUUID } from '../../types/models/video/video-playlist' -import { MStreamingPlaylist } from '../../types/models/video/video-streaming-playlist' +} from '../../types/models/index.js' +import { MVideoFileVideoUUID } from '../../types/models/video/video-file.js' +import { MVideoPlaylist, MVideoPlaylistUUID } from '../../types/models/video/video-playlist.js' +import { MStreamingPlaylist } from '../../types/models/video/video-streaming-playlist.js' function getLocalVideoActivityPubUrl (video: MVideoUUID) { return WEBSERVER.URL + '/videos/watch/' + video.uuid diff --git a/server/lib/activitypub/video-comments.ts b/server/server/lib/activitypub/video-comments.ts similarity index 91% rename from server/lib/activitypub/video-comments.ts rename to server/server/lib/activitypub/video-comments.ts index b861be5bd..9da89ef0c 100644 --- a/server/lib/activitypub/video-comments.ts +++ b/server/server/lib/activitypub/video-comments.ts @@ -1,16 +1,15 @@ -import { map } from 'bluebird' - -import { sanitizeAndCheckVideoCommentObject } from '../../helpers/custom-validators/activitypub/video-comments' -import { logger } from '../../helpers/logger' -import { ACTIVITY_PUB, CRAWL_REQUEST_CONCURRENCY } from '../../initializers/constants' -import { VideoCommentModel } from '../../models/video/video-comment' -import { MComment, MCommentOwner, MCommentOwnerVideo, MVideoAccountLightBlacklistAllFiles } from '../../types/models/video' -import { isRemoteVideoCommentAccepted } from '../moderation' -import { Hooks } from '../plugins/hooks' -import { fetchAP } from './activity' -import { getOrCreateAPActor } from './actors' -import { checkUrlsSameHost } from './url' -import { getOrCreateAPVideo } from './videos' +import Bluebird from 'bluebird' +import { sanitizeAndCheckVideoCommentObject } from '../../helpers/custom-validators/activitypub/video-comments.js' +import { logger } from '../../helpers/logger.js' +import { ACTIVITY_PUB, CRAWL_REQUEST_CONCURRENCY } from '../../initializers/constants.js' +import { VideoCommentModel } from '../../models/video/video-comment.js' +import { MComment, MCommentOwner, MCommentOwnerVideo, MVideoAccountLightBlacklistAllFiles } from '../../types/models/video/index.js' +import { isRemoteVideoCommentAccepted } from '../moderation.js' +import { Hooks } from '../plugins/hooks.js' +import { fetchAP } from './activity.js' +import { getOrCreateAPActor } from './actors/index.js' +import { checkUrlsSameHost } from './url.js' +import { getOrCreateAPVideo } from './videos/index.js' type ResolveThreadParams = { url: string @@ -21,7 +20,7 @@ type ResolveThreadParams = { type ResolveThreadResult = Promise<{ video: MVideoAccountLightBlacklistAllFiles, comment: MCommentOwnerVideo, commentCreated: boolean }> async function addVideoComments (commentUrls: string[]) { - return map(commentUrls, async commentUrl => { + return Bluebird.map(commentUrls, async commentUrl => { try { await resolveThread({ url: commentUrl, isVideo: false }) } catch (err) { diff --git a/server/lib/activitypub/video-rates.ts b/server/server/lib/activitypub/video-rates.ts similarity index 81% rename from server/lib/activitypub/video-rates.ts rename to server/server/lib/activitypub/video-rates.ts index 2e7920f4e..1c0d5ec14 100644 --- a/server/lib/activitypub/video-rates.ts +++ b/server/server/lib/activitypub/video-rates.ts @@ -1,10 +1,10 @@ import { Transaction } from 'sequelize' -import { VideoRateType } from '../../../shared/models/videos' -import { MAccountActor, MActorUrl, MVideoAccountLight, MVideoFullLight, MVideoId } from '../../types/models' -import { sendLike, sendUndoDislike, sendUndoLike } from './send' -import { sendDislike } from './send/send-dislike' -import { getVideoDislikeActivityPubUrlByLocalActor, getVideoLikeActivityPubUrlByLocalActor } from './url' -import { federateVideoIfNeeded } from './videos' +import { VideoRateType } from '@peertube/peertube-models' +import { MAccountActor, MActorUrl, MVideoAccountLight, MVideoFullLight, MVideoId } from '../../types/models/index.js' +import { sendLike, sendUndoDislike, sendUndoLike } from './send/index.js' +import { sendDislike } from './send/send-dislike.js' +import { getVideoDislikeActivityPubUrlByLocalActor, getVideoLikeActivityPubUrlByLocalActor } from './url.js' +import { federateVideoIfNeeded } from './videos/index.js' async function sendVideoRateChange ( account: MAccountActor, diff --git a/server/lib/activitypub/videos/federate.ts b/server/server/lib/activitypub/videos/federate.ts similarity index 77% rename from server/lib/activitypub/videos/federate.ts rename to server/server/lib/activitypub/videos/federate.ts index d7e251153..76b9030f1 100644 --- a/server/lib/activitypub/videos/federate.ts +++ b/server/server/lib/activitypub/videos/federate.ts @@ -1,7 +1,7 @@ -import { Transaction } from 'sequelize/types' -import { MVideoAP, MVideoAPLight } from '@server/types/models' -import { sendCreateVideo, sendUpdateVideo } from '../send' -import { shareVideoByServerAndChannel } from '../share' +import { Transaction } from 'sequelize' +import { MVideoAP, MVideoAPLight } from '@server/types/models/index.js' +import { sendCreateVideo, sendUpdateVideo } from '../send/index.js' +import { shareVideoByServerAndChannel } from '../share.js' async function federateVideoIfNeeded (videoArg: MVideoAPLight, isNewVideo: boolean, transaction?: Transaction) { const video = videoArg as MVideoAP diff --git a/server/lib/activitypub/videos/get.ts b/server/server/lib/activitypub/videos/get.ts similarity index 90% rename from server/lib/activitypub/videos/get.ts rename to server/server/lib/activitypub/videos/get.ts index 288c506ee..6d70a490f 100644 --- a/server/lib/activitypub/videos/get.ts +++ b/server/server/lib/activitypub/videos/get.ts @@ -1,12 +1,12 @@ -import { retryTransactionWrapper } from '@server/helpers/database-utils' -import { logger } from '@server/helpers/logger' -import { JobQueue } from '@server/lib/job-queue' -import { loadVideoByUrl, VideoLoadByUrlType } from '@server/lib/model-loaders' -import { MVideoAccountLightBlacklistAllFiles, MVideoImmutable, MVideoThumbnail } from '@server/types/models' -import { APObjectId } from '@shared/models' -import { getAPId } from '../activity' -import { refreshVideoIfNeeded } from './refresh' -import { APVideoCreator, fetchRemoteVideo, SyncParam, syncVideoExternalAttributes } from './shared' +import { retryTransactionWrapper } from '@server/helpers/database-utils.js' +import { logger } from '@server/helpers/logger.js' +import { JobQueue } from '@server/lib/job-queue/index.js' +import { loadVideoByUrl, VideoLoadByUrlType } from '@server/lib/model-loaders/index.js' +import { MVideoAccountLightBlacklistAllFiles, MVideoImmutable, MVideoThumbnail } from '@server/types/models/index.js' +import { APObjectId } from '@peertube/peertube-models' +import { getAPId } from '../activity.js' +import { refreshVideoIfNeeded } from './refresh.js' +import { APVideoCreator, fetchRemoteVideo, SyncParam, syncVideoExternalAttributes } from './shared/index.js' type GetVideoResult = Promise<{ video: T diff --git a/server/server/lib/activitypub/videos/index.ts b/server/server/lib/activitypub/videos/index.ts new file mode 100644 index 000000000..05af1431c --- /dev/null +++ b/server/server/lib/activitypub/videos/index.ts @@ -0,0 +1,4 @@ +export * from './federate.js' +export * from './get.js' +export * from './refresh.js' +export * from './updater.js' diff --git a/server/lib/activitypub/videos/refresh.ts b/server/server/lib/activitypub/videos/refresh.ts similarity index 84% rename from server/lib/activitypub/videos/refresh.ts rename to server/server/lib/activitypub/videos/refresh.ts index 9f952a218..961bdf71c 100644 --- a/server/lib/activitypub/videos/refresh.ts +++ b/server/server/lib/activitypub/videos/refresh.ts @@ -1,12 +1,12 @@ -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { PeerTubeRequestError } from '@server/helpers/requests' -import { VideoLoadByUrlType } from '@server/lib/model-loaders' -import { VideoModel } from '@server/models/video/video' -import { MVideoAccountLightBlacklistAllFiles, MVideoThumbnail } from '@server/types/models' -import { HttpStatusCode } from '@shared/models' -import { ActorFollowHealthCache } from '../../actor-follow-health-cache' -import { fetchRemoteVideo, SyncParam, syncVideoExternalAttributes } from './shared' -import { APVideoUpdater } from './updater' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { PeerTubeRequestError } from '@server/helpers/requests.js' +import { VideoLoadByUrlType } from '@server/lib/model-loaders/index.js' +import { VideoModel } from '@server/models/video/video.js' +import { MVideoAccountLightBlacklistAllFiles, MVideoThumbnail } from '@server/types/models/index.js' +import { HttpStatusCode } from '@peertube/peertube-models' +import { ActorFollowHealthCache } from '../../actor-follow-health-cache.js' +import { fetchRemoteVideo, SyncParam, syncVideoExternalAttributes } from './shared/index.js' +import { APVideoUpdater } from './updater.js' async function refreshVideoIfNeeded (options: { video: MVideoThumbnail diff --git a/server/lib/activitypub/videos/shared/abstract-builder.ts b/server/server/lib/activitypub/videos/shared/abstract-builder.ts similarity index 90% rename from server/lib/activitypub/videos/shared/abstract-builder.ts rename to server/server/lib/activitypub/videos/shared/abstract-builder.ts index 98c2f58eb..4397e578f 100644 --- a/server/lib/activitypub/videos/shared/abstract-builder.ts +++ b/server/server/lib/activitypub/videos/shared/abstract-builder.ts @@ -1,13 +1,14 @@ -import { CreationAttributes, Transaction } from 'sequelize/types' -import { deleteAllModels, filterNonExistingModels } from '@server/helpers/database-utils' -import { logger, LoggerTagsFn } from '@server/helpers/logger' -import { updateRemoteVideoThumbnail } from '@server/lib/thumbnail' -import { setVideoTags } from '@server/lib/video' -import { StoryboardModel } from '@server/models/video/storyboard' -import { VideoCaptionModel } from '@server/models/video/video-caption' -import { VideoFileModel } from '@server/models/video/video-file' -import { VideoLiveModel } from '@server/models/video/video-live' -import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' +import { CreationAttributes, Transaction } from 'sequelize' +import { ActivityTagObject, ThumbnailType, VideoObject, VideoStreamingPlaylistType_Type } from '@peertube/peertube-models' +import { deleteAllModels, filterNonExistingModels } from '@server/helpers/database-utils.js' +import { logger, LoggerTagsFn } from '@server/helpers/logger.js' +import { updateRemoteVideoThumbnail } from '@server/lib/thumbnail.js' +import { setVideoTags } from '@server/lib/video.js' +import { StoryboardModel } from '@server/models/video/storyboard.js' +import { VideoCaptionModel } from '@server/models/video/video-caption.js' +import { VideoFileModel } from '@server/models/video/video-file.js' +import { VideoLiveModel } from '@server/models/video/video-live.js' +import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist.js' import { MStreamingPlaylistFiles, MStreamingPlaylistFilesVideo, @@ -15,9 +16,8 @@ import { MVideoFile, MVideoFullLight, MVideoThumbnail -} from '@server/types/models' -import { ActivityTagObject, ThumbnailType, VideoObject, VideoStreamingPlaylistType } from '@shared/models' -import { findOwner, getOrCreateAPActor } from '../../actors' +} from '@server/types/models/index.js' +import { findOwner, getOrCreateAPActor } from '../../actors/index.js' import { getCaptionAttributesFromObject, getFileAttributesFromUrl, @@ -27,8 +27,8 @@ import { getStreamingPlaylistAttributesFromObject, getTagsFromObject, getThumbnailFromIcons -} from './object-to-model-attributes' -import { getTrackerUrls, setVideoTrackers } from './trackers' +} from './object-to-model-attributes.js' +import { getTrackerUrls, setVideoTrackers } from './trackers.js' export abstract class APVideoAbstractBuilder { protected abstract videoObject: VideoObject @@ -164,7 +164,7 @@ export abstract class APVideoAbstractBuilder { return streamingPlaylist as MStreamingPlaylistFilesVideo } - private getStreamingPlaylistFiles (oldPlaylists: MStreamingPlaylistFiles[], type: VideoStreamingPlaylistType) { + private getStreamingPlaylistFiles (oldPlaylists: MStreamingPlaylistFiles[], type: VideoStreamingPlaylistType_Type) { const playlist = oldPlaylists.find(s => s.type === type) if (!playlist) return [] diff --git a/server/lib/activitypub/videos/shared/creator.ts b/server/server/lib/activitypub/videos/shared/creator.ts similarity index 88% rename from server/lib/activitypub/videos/shared/creator.ts rename to server/server/lib/activitypub/videos/shared/creator.ts index e44fd0d52..5a3a46282 100644 --- a/server/lib/activitypub/videos/shared/creator.ts +++ b/server/server/lib/activitypub/videos/shared/creator.ts @@ -1,13 +1,13 @@ -import { logger, loggerTagsFactory, LoggerTagsFn } from '@server/helpers/logger' -import { sequelizeTypescript } from '@server/initializers/database' -import { Hooks } from '@server/lib/plugins/hooks' -import { autoBlacklistVideoIfNeeded } from '@server/lib/video-blacklist' -import { VideoModel } from '@server/models/video/video' -import { MVideoFullLight, MVideoThumbnail } from '@server/types/models' -import { VideoObject } from '@shared/models' -import { APVideoAbstractBuilder } from './abstract-builder' -import { getVideoAttributesFromObject } from './object-to-model-attributes' +import { logger, loggerTagsFactory, LoggerTagsFn } from '@server/helpers/logger.js' +import { sequelizeTypescript } from '@server/initializers/database.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { autoBlacklistVideoIfNeeded } from '@server/lib/video-blacklist.js' +import { VideoModel } from '@server/models/video/video.js' +import { MVideoFullLight, MVideoThumbnail } from '@server/types/models/index.js' +import { VideoObject } from '@peertube/peertube-models' +import { APVideoAbstractBuilder } from './abstract-builder.js' +import { getVideoAttributesFromObject } from './object-to-model-attributes.js' export class APVideoCreator extends APVideoAbstractBuilder { protected lTags: LoggerTagsFn diff --git a/server/server/lib/activitypub/videos/shared/index.ts b/server/server/lib/activitypub/videos/shared/index.ts new file mode 100644 index 000000000..6792af7da --- /dev/null +++ b/server/server/lib/activitypub/videos/shared/index.ts @@ -0,0 +1,6 @@ +export * from './abstract-builder.js' +export * from './creator.js' +export * from './object-to-model-attributes.js' +export * from './trackers.js' +export * from './url-to-object.js' +export * from './video-sync-attributes.js' diff --git a/server/lib/activitypub/videos/shared/object-to-model-attributes.ts b/server/server/lib/activitypub/videos/shared/object-to-model-attributes.ts similarity index 91% rename from server/lib/activitypub/videos/shared/object-to-model-attributes.ts rename to server/server/lib/activitypub/videos/shared/object-to-model-attributes.ts index 6cbe72e27..c0a945331 100644 --- a/server/lib/activitypub/videos/shared/object-to-model-attributes.ts +++ b/server/server/lib/activitypub/videos/shared/object-to-model-attributes.ts @@ -1,17 +1,4 @@ -import { maxBy, minBy } from 'lodash' -import { decode as magnetUriDecode } from 'magnet-uri' -import { basename, extname } from 'path' -import { isAPVideoFileUrlMetadataObject } from '@server/helpers/custom-validators/activitypub/videos' -import { isVideoFileInfoHashValid } from '@server/helpers/custom-validators/videos' -import { logger } from '@server/helpers/logger' -import { getExtFromMimetype } from '@server/helpers/video' -import { ACTIVITY_PUB, MIMETYPES, P2P_MEDIA_LOADER_PEER_VERSION, PREVIEWS_SIZE, THUMBNAILS_SIZE } from '@server/initializers/constants' -import { generateTorrentFileName } from '@server/lib/paths' -import { VideoCaptionModel } from '@server/models/video/video-caption' -import { VideoFileModel } from '@server/models/video/video-file' -import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' -import { FilteredModelAttributes } from '@server/types' -import { isStreamingPlaylist, MChannelId, MStreamingPlaylistVideo, MVideo, MVideoId } from '@server/types/models' +import { arrayify } from '@peertube/peertube-core-utils' import { ActivityHashTagObject, ActivityMagnetUrlObject, @@ -23,11 +10,25 @@ import { VideoObject, VideoPrivacy, VideoStreamingPlaylistType -} from '@shared/models' -import { getDurationFromActivityStream } from '../../activity' -import { isArray } from '@server/helpers/custom-validators/misc' -import { generateImageFilename } from '@server/helpers/image-utils' -import { arrayify } from '@shared/core-utils' +} from '@peertube/peertube-models' +import { isAPVideoFileUrlMetadataObject } from '@server/helpers/custom-validators/activitypub/videos.js' +import { isArray } from '@server/helpers/custom-validators/misc.js' +import { isVideoFileInfoHashValid } from '@server/helpers/custom-validators/videos.js' +import { generateImageFilename } from '@server/helpers/image-utils.js' +import { logger } from '@server/helpers/logger.js' +import { getExtFromMimetype } from '@server/helpers/video.js' +import { ACTIVITY_PUB, MIMETYPES, P2P_MEDIA_LOADER_PEER_VERSION, PREVIEWS_SIZE, THUMBNAILS_SIZE } from '@server/initializers/constants.js' +import { generateTorrentFileName } from '@server/lib/paths.js' +import { VideoCaptionModel } from '@server/models/video/video-caption.js' +import { VideoFileModel } from '@server/models/video/video-file.js' +import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist.js' +import { FilteredModelAttributes } from '@server/types/index.js' +import { MChannelId, MStreamingPlaylistVideo, MVideo, MVideoId, isStreamingPlaylist } from '@server/types/models/index.js' +import maxBy from 'lodash-es/maxBy.js' +import minBy from 'lodash-es/minBy.js' +import { decode as magnetUriDecode } from 'magnet-uri' +import { basename, extname } from 'path' +import { getDurationFromActivityStream } from '../../activity.js' function getThumbnailFromIcons (videoObject: VideoObject) { let validIcons = videoObject.icon.filter(i => i.width > THUMBNAILS_SIZE.minWidth) diff --git a/server/lib/activitypub/videos/shared/trackers.ts b/server/server/lib/activitypub/videos/shared/trackers.ts similarity index 65% rename from server/lib/activitypub/videos/shared/trackers.ts rename to server/server/lib/activitypub/videos/shared/trackers.ts index 2418f45c2..a7ce6f4ad 100644 --- a/server/lib/activitypub/videos/shared/trackers.ts +++ b/server/server/lib/activitypub/videos/shared/trackers.ts @@ -1,11 +1,11 @@ -import { Transaction } from 'sequelize/types' -import { isAPVideoTrackerUrlObject } from '@server/helpers/custom-validators/activitypub/videos' -import { isArray } from '@server/helpers/custom-validators/misc' -import { REMOTE_SCHEME } from '@server/initializers/constants' -import { TrackerModel } from '@server/models/server/tracker' -import { MVideo, MVideoWithHost } from '@server/types/models' -import { ActivityTrackerUrlObject, VideoObject } from '@shared/models' -import { buildRemoteVideoBaseUrl } from '../../url' +import { Transaction } from 'sequelize' +import { isAPVideoTrackerUrlObject } from '@server/helpers/custom-validators/activitypub/videos.js' +import { isArray } from '@server/helpers/custom-validators/misc.js' +import { REMOTE_SCHEME } from '@server/initializers/constants.js' +import { TrackerModel } from '@server/models/server/tracker.js' +import { MVideo, MVideoWithHost } from '@server/types/models/index.js' +import { ActivityTrackerUrlObject, VideoObject } from '@peertube/peertube-models' +import { buildRemoteVideoBaseUrl } from '../../url.js' function getTrackerUrls (object: VideoObject, video: MVideoWithHost) { let wsFound = false diff --git a/server/lib/activitypub/videos/shared/url-to-object.ts b/server/server/lib/activitypub/videos/shared/url-to-object.ts similarity index 78% rename from server/lib/activitypub/videos/shared/url-to-object.ts rename to server/server/lib/activitypub/videos/shared/url-to-object.ts index 7fe008419..f27f24971 100644 --- a/server/lib/activitypub/videos/shared/url-to-object.ts +++ b/server/server/lib/activitypub/videos/shared/url-to-object.ts @@ -1,8 +1,8 @@ -import { sanitizeAndCheckVideoTorrentObject } from '@server/helpers/custom-validators/activitypub/videos' -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { VideoObject } from '@shared/models' -import { fetchAP } from '../../activity' -import { checkUrlsSameHost } from '../../url' +import { sanitizeAndCheckVideoTorrentObject } from '@server/helpers/custom-validators/activitypub/videos.js' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { VideoObject } from '@peertube/peertube-models' +import { fetchAP } from '../../activity.js' +import { checkUrlsSameHost } from '../../url.js' const lTags = loggerTagsFactory('ap', 'video') diff --git a/server/lib/activitypub/videos/shared/video-sync-attributes.ts b/server/server/lib/activitypub/videos/shared/video-sync-attributes.ts similarity index 81% rename from server/lib/activitypub/videos/shared/video-sync-attributes.ts rename to server/server/lib/activitypub/videos/shared/video-sync-attributes.ts index 7fb933559..a07f519fc 100644 --- a/server/lib/activitypub/videos/shared/video-sync-attributes.ts +++ b/server/server/lib/activitypub/videos/shared/video-sync-attributes.ts @@ -1,26 +1,26 @@ -import { runInReadCommittedTransaction } from '@server/helpers/database-utils' -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { JobQueue } from '@server/lib/job-queue' -import { VideoModel } from '@server/models/video/video' -import { VideoCommentModel } from '@server/models/video/video-comment' -import { VideoShareModel } from '@server/models/video/video-share' -import { MVideo } from '@server/types/models' -import { ActivitypubHttpFetcherPayload, ActivityPubOrderedCollection, VideoObject } from '@shared/models' -import { fetchAP } from '../../activity' -import { crawlCollectionPage } from '../../crawl' -import { addVideoShares } from '../../share' -import { addVideoComments } from '../../video-comments' +import { ActivityPubOrderedCollection, ActivitypubHttpFetcherPayload, VideoObject } from '@peertube/peertube-models' +import { runInReadCommittedTransaction } from '@server/helpers/database-utils.js' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { JobQueue } from '@server/lib/job-queue/index.js' +import { VideoCommentModel } from '@server/models/video/video-comment.js' +import { VideoShareModel } from '@server/models/video/video-share.js' +import { VideoModel } from '@server/models/video/video.js' +import { MVideo } from '@server/types/models/index.js' +import { fetchAP } from '../../activity.js' +import { crawlCollectionPage } from '../../crawl.js' +import { addVideoShares } from '../../share.js' +import { addVideoComments } from '../../video-comments.js' const lTags = loggerTagsFactory('ap', 'video') -type SyncParam = { +export type SyncParam = { rates: boolean shares: boolean comments: boolean refreshVideo?: boolean } -async function syncVideoExternalAttributes ( +export async function syncVideoExternalAttributes ( video: MVideo, fetchedVideo: VideoObject, syncParam: Pick @@ -35,7 +35,7 @@ async function syncVideoExternalAttributes ( await syncComments(video, fetchedVideo, syncParam.comments) } -async function updateVideoRates (video: MVideo, fetchedVideo: VideoObject) { +export async function updateVideoRates (video: MVideo, fetchedVideo: VideoObject) { const [ likes, dislikes ] = await Promise.all([ getRatesCount('like', video, fetchedVideo), getRatesCount('dislike', video, fetchedVideo) @@ -48,13 +48,7 @@ async function updateVideoRates (video: MVideo, fetchedVideo: VideoObject) { } // --------------------------------------------------------------------------- - -export { - SyncParam, - syncVideoExternalAttributes, - updateVideoRates -} - +// Private // --------------------------------------------------------------------------- async function getRatesCount (type: 'like' | 'dislike', video: MVideo, fetchedVideo: VideoObject) { diff --git a/server/lib/activitypub/videos/updater.ts b/server/server/lib/activitypub/videos/updater.ts similarity index 91% rename from server/lib/activitypub/videos/updater.ts rename to server/server/lib/activitypub/videos/updater.ts index acb087895..37bf7411a 100644 --- a/server/lib/activitypub/videos/updater.ts +++ b/server/server/lib/activitypub/videos/updater.ts @@ -1,14 +1,20 @@ -import { Transaction } from 'sequelize/types' -import { resetSequelizeInstance, runInReadCommittedTransaction } from '@server/helpers/database-utils' -import { logger, loggerTagsFactory, LoggerTagsFn } from '@server/helpers/logger' -import { Notifier } from '@server/lib/notifier' -import { PeerTubeSocket } from '@server/lib/peertube-socket' -import { Hooks } from '@server/lib/plugins/hooks' -import { autoBlacklistVideoIfNeeded } from '@server/lib/video-blacklist' -import { VideoLiveModel } from '@server/models/video/video-live' -import { MActor, MChannelAccountLight, MChannelId, MVideoAccountLightBlacklistAllFiles, MVideoFullLight } from '@server/types/models' -import { VideoObject, VideoPrivacy } from '@shared/models' -import { APVideoAbstractBuilder, getVideoAttributesFromObject, updateVideoRates } from './shared' +import { Transaction } from 'sequelize' +import { VideoObject, VideoPrivacy } from '@peertube/peertube-models' +import { resetSequelizeInstance, runInReadCommittedTransaction } from '@server/helpers/database-utils.js' +import { logger, loggerTagsFactory, LoggerTagsFn } from '@server/helpers/logger.js' +import { Notifier } from '@server/lib/notifier/index.js' +import { PeerTubeSocket } from '@server/lib/peertube-socket.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { autoBlacklistVideoIfNeeded } from '@server/lib/video-blacklist.js' +import { VideoLiveModel } from '@server/models/video/video-live.js' +import { + MActor, + MChannelAccountLight, + MChannelId, + MVideoAccountLightBlacklistAllFiles, + MVideoFullLight +} from '@server/types/models/index.js' +import { APVideoAbstractBuilder, getVideoAttributesFromObject, updateVideoRates } from './shared/index.js' export class APVideoUpdater extends APVideoAbstractBuilder { private readonly wasPrivateVideo: boolean diff --git a/server/lib/actor-follow-health-cache.ts b/server/server/lib/actor-follow-health-cache.ts similarity index 95% rename from server/lib/actor-follow-health-cache.ts rename to server/server/lib/actor-follow-health-cache.ts index 34357a97a..ec5b03d65 100644 --- a/server/lib/actor-follow-health-cache.ts +++ b/server/server/lib/actor-follow-health-cache.ts @@ -1,5 +1,5 @@ -import { ACTOR_FOLLOW_SCORE } from '../initializers/constants' -import { logger } from '../helpers/logger' +import { ACTOR_FOLLOW_SCORE } from '../initializers/constants.js' +import { logger } from '../helpers/logger.js' // Cache follows scores, instead of writing them too often in database // Keep data in memory, we don't really need Redis here as we don't really care to loose some scores diff --git a/server/lib/actor-image.ts b/server/server/lib/actor-image.ts similarity index 86% rename from server/lib/actor-image.ts rename to server/server/lib/actor-image.ts index e9bd148f6..5b19a740d 100644 --- a/server/lib/actor-image.ts +++ b/server/server/lib/actor-image.ts @@ -1,4 +1,4 @@ -import maxBy from 'lodash/maxBy' +import maxBy from 'lodash-es/maxBy.js' function getBiggestActorImage (images: T[]) { const image = maxBy(images, 'width') diff --git a/server/lib/auth/external-auth.ts b/server/server/lib/auth/external-auth.ts similarity index 94% rename from server/lib/auth/external-auth.ts rename to server/server/lib/auth/external-auth.ts index bc5b74257..e1879aa01 100644 --- a/server/lib/auth/external-auth.ts +++ b/server/server/lib/auth/external-auth.ts @@ -1,4 +1,3 @@ - import { isUserAdminFlagsValid, isUserDisplayNameValid, @@ -6,20 +5,20 @@ import { isUserUsernameValid, isUserVideoQuotaDailyValid, isUserVideoQuotaValid -} from '@server/helpers/custom-validators/users' -import { logger } from '@server/helpers/logger' -import { generateRandomString } from '@server/helpers/utils' -import { PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME } from '@server/initializers/constants' -import { PluginManager } from '@server/lib/plugins/plugin-manager' -import { OAuthTokenModel } from '@server/models/oauth/oauth-token' -import { MUser } from '@server/types/models' +} from '@server/helpers/custom-validators/users.js' +import { logger } from '@server/helpers/logger.js' +import { generateRandomString } from '@server/helpers/utils.js' +import { PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME } from '@server/initializers/constants.js' +import { PluginManager } from '@server/lib/plugins/plugin-manager.js' +import { OAuthTokenModel } from '@server/models/oauth/oauth-token.js' +import { MUser } from '@server/types/models/index.js' import { RegisterServerAuthenticatedResult, RegisterServerAuthPassOptions, RegisterServerExternalAuthenticatedResult -} from '@server/types/plugins/register-server-auth.model' -import { UserAdminFlag, UserRole } from '@shared/models' -import { BypassLogin } from './oauth-model' +} from '@server/types/plugins/register-server-auth.model.js' +import { UserAdminFlag, UserRole } from '@peertube/peertube-models' +import { BypassLogin } from './oauth-model.js' export type ExternalUser = Pick & diff --git a/server/lib/auth/oauth-model.ts b/server/server/lib/auth/oauth-model.ts similarity index 92% rename from server/lib/auth/oauth-model.ts rename to server/server/lib/auth/oauth-model.ts index d3a5eccd5..26a9f8996 100644 --- a/server/lib/auth/oauth-model.ts +++ b/server/server/lib/auth/oauth-model.ts @@ -1,22 +1,22 @@ import express from 'express' import { AccessDeniedError } from '@node-oauth/oauth2-server' -import { PluginManager } from '@server/lib/plugins/plugin-manager' -import { AccountModel } from '@server/models/account/account' -import { AuthenticatedResultUpdaterFieldName, RegisterServerAuthenticatedResult } from '@server/types' -import { MOAuthClient } from '@server/types/models' -import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token' -import { MUser, MUserDefault } from '@server/types/models/user/user' -import { pick } from '@shared/core-utils' -import { AttributesOnly } from '@shared/typescript-utils' -import { logger } from '../../helpers/logger' -import { CONFIG } from '../../initializers/config' -import { OAuthClientModel } from '../../models/oauth/oauth-client' -import { OAuthTokenModel } from '../../models/oauth/oauth-token' -import { UserModel } from '../../models/user/user' -import { findAvailableLocalActorName } from '../local-actor' -import { buildUser, createUserAccountAndChannelAndPlaylist } from '../user' -import { ExternalUser } from './external-auth' -import { TokensCache } from './tokens-cache' +import { PluginManager } from '@server/lib/plugins/plugin-manager.js' +import { AccountModel } from '@server/models/account/account.js' +import { AuthenticatedResultUpdaterFieldName, RegisterServerAuthenticatedResult } from '@server/types/index.js' +import { MOAuthClient } from '@server/types/models/index.js' +import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token.js' +import { MUser, MUserDefault } from '@server/types/models/user/user.js' +import { pick } from '@peertube/peertube-core-utils' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { logger } from '../../helpers/logger.js' +import { CONFIG } from '../../initializers/config.js' +import { OAuthClientModel } from '../../models/oauth/oauth-client.js' +import { OAuthTokenModel } from '../../models/oauth/oauth-token.js' +import { UserModel } from '../../models/user/user.js' +import { findAvailableLocalActorName } from '../local-actor.js' +import { buildUser, createUserAccountAndChannelAndPlaylist } from '../user.js' +import { ExternalUser } from './external-auth.js' +import { TokensCache } from './tokens-cache.js' type TokenInfo = { accessToken: string diff --git a/server/lib/auth/oauth.ts b/server/server/lib/auth/oauth.ts similarity index 90% rename from server/lib/auth/oauth.ts rename to server/server/lib/auth/oauth.ts index 887c4f7c9..d91bfc37a 100644 --- a/server/lib/auth/oauth.ts +++ b/server/server/lib/auth/oauth.ts @@ -8,15 +8,15 @@ import OAuth2Server, { UnauthorizedClientError, UnsupportedGrantTypeError } from '@node-oauth/oauth2-server' -import { randomBytesPromise } from '@server/helpers/core-utils' -import { isOTPValid } from '@server/helpers/otp' -import { CONFIG } from '@server/initializers/config' -import { UserRegistrationModel } from '@server/models/user/user-registration' -import { MOAuthClient } from '@server/types/models' -import { sha1 } from '@shared/extra-utils' -import { HttpStatusCode, ServerErrorCode, UserRegistrationState } from '@shared/models' -import { OTP } from '../../initializers/constants' -import { BypassLogin, getClient, getRefreshToken, getUser, revokeToken, saveToken } from './oauth-model' +import { randomBytesPromise } from '@server/helpers/core-utils.js' +import { isOTPValid } from '@server/helpers/otp.js' +import { CONFIG } from '@server/initializers/config.js' +import { UserRegistrationModel } from '@server/models/user/user-registration.js' +import { MOAuthClient } from '@server/types/models/index.js' +import { sha1 } from '@peertube/peertube-node-utils' +import { HttpStatusCode, ServerErrorCode, UserRegistrationState } from '@peertube/peertube-models' +import { OTP } from '../../initializers/constants.js' +import { BypassLogin, getAccessToken, getClient, getRefreshToken, getUser, revokeToken, saveToken } from './oauth-model.js' class MissingTwoFactorError extends Error { code = HttpStatusCode.UNAUTHORIZED_401 @@ -49,7 +49,14 @@ const oAuthServer = new OAuth2Server({ refreshTokenLifetime: CONFIG.OAUTH2.TOKEN_LIFETIME.REFRESH_TOKEN / 1000, // See https://github.com/oauthjs/node-oauth2-server/wiki/Model-specification for the model specifications - model: require('./oauth-model') + model: { + getAccessToken, + getClient, + getRefreshToken, + getUser, + revokeToken, + saveToken + } as any // FIXME: typings }) // --------------------------------------------------------------------------- diff --git a/server/lib/auth/tokens-cache.ts b/server/server/lib/auth/tokens-cache.ts similarity index 91% rename from server/lib/auth/tokens-cache.ts rename to server/server/lib/auth/tokens-cache.ts index e7b12159b..45d62bcaf 100644 --- a/server/lib/auth/tokens-cache.ts +++ b/server/server/lib/auth/tokens-cache.ts @@ -1,6 +1,6 @@ import { LRUCache } from 'lru-cache' -import { MOAuthTokenUser } from '@server/types/models' -import { LRU_CACHE } from '../../initializers/constants' +import { MOAuthTokenUser } from '@server/types/models/index.js' +import { LRU_CACHE } from '../../initializers/constants.js' export class TokensCache { diff --git a/server/lib/blocklist.ts b/server/server/lib/blocklist.ts similarity index 95% rename from server/lib/blocklist.ts rename to server/server/lib/blocklist.ts index 009e229ce..7491d92d7 100644 --- a/server/lib/blocklist.ts +++ b/server/server/lib/blocklist.ts @@ -1,8 +1,8 @@ -import { sequelizeTypescript } from '@server/initializers/database' -import { getServerActor } from '@server/models/application/application' -import { MAccountBlocklist, MAccountId, MAccountHost, MServerBlocklist } from '@server/types/models' -import { AccountBlocklistModel } from '../models/account/account-blocklist' -import { ServerBlocklistModel } from '../models/server/server-blocklist' +import { sequelizeTypescript } from '@server/initializers/database.js' +import { getServerActor } from '@server/models/application/application.js' +import { MAccountBlocklist, MAccountId, MAccountHost, MServerBlocklist } from '@server/types/models/index.js' +import { AccountBlocklistModel } from '../models/account/account-blocklist.js' +import { ServerBlocklistModel } from '../models/server/server-blocklist.js' function addAccountInBlocklist (byAccountId: number, targetAccountId: number) { return sequelizeTypescript.transaction(async t => { diff --git a/server/lib/client-html.ts b/server/server/lib/client-html.ts similarity index 93% rename from server/lib/client-html.ts rename to server/server/lib/client-html.ts index 8e0c9e328..f00b05fab 100644 --- a/server/lib/client-html.ts +++ b/server/server/lib/client-html.ts @@ -1,21 +1,17 @@ +import { buildFileLocale, escapeHTML, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '@peertube/peertube-core-utils' +import { HTMLServerConfig, HttpStatusCode, VideoPlaylistPrivacy, VideoPrivacy } from '@peertube/peertube-models' +import { isTestOrDevInstance, root, sha256 } from '@peertube/peertube-node-utils' +import { toCompleteUUID } from '@server/helpers/custom-validators/misc.js' +import { mdToOneLinePlainText } from '@server/helpers/markdown.js' +import { ActorImageModel } from '@server/models/actor/actor-image.js' import express from 'express' -import { pathExists, readFile } from 'fs-extra' -import { truncate } from 'lodash' +import { pathExists } from 'fs-extra/esm' +import { readFile } from 'fs/promises' +import truncate from 'lodash-es/truncate.js' import { join } from 'path' import validator from 'validator' -import { isTestOrDevInstance } from '@server/helpers/core-utils' -import { toCompleteUUID } from '@server/helpers/custom-validators/misc' -import { mdToOneLinePlainText } from '@server/helpers/markdown' -import { ActorImageModel } from '@server/models/actor/actor-image' -import { root } from '@shared/core-utils' -import { escapeHTML } from '@shared/core-utils/renderer' -import { sha256 } from '@shared/extra-utils' -import { HTMLServerConfig } from '@shared/models' -import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/core-utils/i18n/i18n' -import { HttpStatusCode } from '../../shared/models/http/http-error-codes' -import { VideoPlaylistPrivacy, VideoPrivacy } from '../../shared/models/videos' -import { logger } from '../helpers/logger' -import { CONFIG } from '../initializers/config' +import { logger } from '../helpers/logger.js' +import { CONFIG } from '../initializers/config.js' import { ACCEPT_HEADERS, CUSTOM_HTML_TAG_COMMENTS, @@ -23,17 +19,17 @@ import { FILES_CONTENT_HASH, PLUGIN_GLOBAL_CSS_PATH, WEBSERVER -} from '../initializers/constants' -import { AccountModel } from '../models/account/account' -import { VideoModel } from '../models/video/video' -import { VideoChannelModel } from '../models/video/video-channel' -import { VideoPlaylistModel } from '../models/video/video-playlist' -import { MAccountHost, MChannelHost, MVideo, MVideoPlaylist } from '../types/models' -import { getActivityStreamDuration } from './activitypub/activity' -import { getBiggestActorImage } from './actor-image' -import { Hooks } from './plugins/hooks' -import { ServerConfigManager } from './server-config-manager' -import { isVideoInPrivateDirectory } from './video-privacy' +} from '../initializers/constants.js' +import { AccountModel } from '../models/account/account.js' +import { VideoChannelModel } from '../models/video/video-channel.js' +import { VideoPlaylistModel } from '../models/video/video-playlist.js' +import { VideoModel } from '../models/video/video.js' +import { MAccountHost, MChannelHost, MVideo, MVideoPlaylist } from '../types/models/index.js' +import { getActivityStreamDuration } from './activitypub/activity.js' +import { getBiggestActorImage } from './actor-image.js' +import { Hooks } from './plugins/hooks.js' +import { ServerConfigManager } from './server-config-manager.js' +import { isVideoInPrivateDirectory } from './video-privacy.js' type Tags = { ogType: string @@ -97,7 +93,7 @@ class ClientHtml { const videoId = toCompleteUUID(videoIdArg) // Let Angular application handle errors - if (!validator.isInt(videoId) && !validator.isUUID(videoId, 4)) { + if (!validator.default.isInt(videoId) && !validator.default.isUUID(videoId, 4)) { res.status(HttpStatusCode.NOT_FOUND_404) return ClientHtml.getIndexHTML(req, res) } @@ -158,7 +154,7 @@ class ClientHtml { const videoPlaylistId = toCompleteUUID(videoPlaylistIdArg) // Let Angular application handle errors - if (!validator.isInt(videoPlaylistId) && !validator.isUUID(videoPlaylistId, 4)) { + if (!validator.default.isInt(videoPlaylistId) && !validator.default.isUUID(videoPlaylistId, 4)) { res.status(HttpStatusCode.NOT_FOUND_404) return ClientHtml.getIndexHTML(req, res) } diff --git a/server/lib/emailer.ts b/server/server/lib/emailer.ts similarity index 90% rename from server/lib/emailer.ts rename to server/server/lib/emailer.ts index f5c3e4745..eea722d9d 100644 --- a/server/lib/emailer.ts +++ b/server/server/lib/emailer.ts @@ -1,18 +1,15 @@ -import { readFileSync } from 'fs-extra' -import { merge } from 'lodash' -import { createTransport, Transporter } from 'nodemailer' +import { arrayify } from '@peertube/peertube-core-utils' +import { EmailPayload, SendEmailDefaultOptions, UserRegistrationState } from '@peertube/peertube-models' +import { isTestOrDevInstance, root } from '@peertube/peertube-node-utils' +import { readFileSync } from 'fs' +import merge from 'lodash-es/merge.js' +import { Transporter, createTransport } from 'nodemailer' import { join } from 'path' -import { arrayify, root } from '@shared/core-utils' -import { EmailPayload, UserRegistrationState } from '@shared/models' -import { SendEmailDefaultOptions } from '../../shared/models/server/emailer.model' -import { isTestOrDevInstance } from '../helpers/core-utils' -import { bunyanLogger, logger } from '../helpers/logger' -import { CONFIG, isEmailEnabled } from '../initializers/config' -import { WEBSERVER } from '../initializers/constants' -import { MRegistration, MUser } from '../types/models' -import { JobQueue } from './job-queue' - -const Email = require('email-templates') +import { bunyanLogger, logger } from '../helpers/logger.js' +import { CONFIG, isEmailEnabled } from '../initializers/config.js' +import { WEBSERVER } from '../initializers/constants.js' +import { MRegistration, MUser } from '../types/models/index.js' +import { JobQueue } from './job-queue/index.js' class Emailer { @@ -180,7 +177,9 @@ class Emailer { ? options.from : CONFIG.INSTANCE.NAME - const email = new Email({ + const EmailTemplates = (await import('email-templates')).default + + const email = new EmailTemplates({ send: true, htmlToText: { selectors: [ diff --git a/server/lib/emails/abuse-new-message/html.pug b/server/server/lib/emails/abuse-new-message/html.pug similarity index 100% rename from server/lib/emails/abuse-new-message/html.pug rename to server/server/lib/emails/abuse-new-message/html.pug diff --git a/server/lib/emails/abuse-state-change/html.pug b/server/server/lib/emails/abuse-state-change/html.pug similarity index 100% rename from server/lib/emails/abuse-state-change/html.pug rename to server/server/lib/emails/abuse-state-change/html.pug diff --git a/server/lib/emails/account-abuse-new/html.pug b/server/server/lib/emails/account-abuse-new/html.pug similarity index 100% rename from server/lib/emails/account-abuse-new/html.pug rename to server/server/lib/emails/account-abuse-new/html.pug diff --git a/server/lib/emails/common/base.pug b/server/server/lib/emails/common/base.pug similarity index 100% rename from server/lib/emails/common/base.pug rename to server/server/lib/emails/common/base.pug diff --git a/server/lib/emails/common/greetings.pug b/server/server/lib/emails/common/greetings.pug similarity index 100% rename from server/lib/emails/common/greetings.pug rename to server/server/lib/emails/common/greetings.pug diff --git a/server/lib/emails/common/html.pug b/server/server/lib/emails/common/html.pug similarity index 100% rename from server/lib/emails/common/html.pug rename to server/server/lib/emails/common/html.pug diff --git a/server/lib/emails/common/mixins.pug b/server/server/lib/emails/common/mixins.pug similarity index 100% rename from server/lib/emails/common/mixins.pug rename to server/server/lib/emails/common/mixins.pug diff --git a/server/lib/emails/contact-form/html.pug b/server/server/lib/emails/contact-form/html.pug similarity index 100% rename from server/lib/emails/contact-form/html.pug rename to server/server/lib/emails/contact-form/html.pug diff --git a/server/lib/emails/follower-on-channel/html.pug b/server/server/lib/emails/follower-on-channel/html.pug similarity index 100% rename from server/lib/emails/follower-on-channel/html.pug rename to server/server/lib/emails/follower-on-channel/html.pug diff --git a/server/lib/emails/password-create/html.pug b/server/server/lib/emails/password-create/html.pug similarity index 100% rename from server/lib/emails/password-create/html.pug rename to server/server/lib/emails/password-create/html.pug diff --git a/server/lib/emails/password-reset/html.pug b/server/server/lib/emails/password-reset/html.pug similarity index 100% rename from server/lib/emails/password-reset/html.pug rename to server/server/lib/emails/password-reset/html.pug diff --git a/server/lib/emails/peertube-version-new/html.pug b/server/server/lib/emails/peertube-version-new/html.pug similarity index 100% rename from server/lib/emails/peertube-version-new/html.pug rename to server/server/lib/emails/peertube-version-new/html.pug diff --git a/server/lib/emails/plugin-version-new/html.pug b/server/server/lib/emails/plugin-version-new/html.pug similarity index 100% rename from server/lib/emails/plugin-version-new/html.pug rename to server/server/lib/emails/plugin-version-new/html.pug diff --git a/server/lib/emails/user-registered/html.pug b/server/server/lib/emails/user-registered/html.pug similarity index 100% rename from server/lib/emails/user-registered/html.pug rename to server/server/lib/emails/user-registered/html.pug diff --git a/server/lib/emails/user-registration-request-accepted/html.pug b/server/server/lib/emails/user-registration-request-accepted/html.pug similarity index 100% rename from server/lib/emails/user-registration-request-accepted/html.pug rename to server/server/lib/emails/user-registration-request-accepted/html.pug diff --git a/server/lib/emails/user-registration-request-rejected/html.pug b/server/server/lib/emails/user-registration-request-rejected/html.pug similarity index 100% rename from server/lib/emails/user-registration-request-rejected/html.pug rename to server/server/lib/emails/user-registration-request-rejected/html.pug diff --git a/server/lib/emails/user-registration-request/html.pug b/server/server/lib/emails/user-registration-request/html.pug similarity index 100% rename from server/lib/emails/user-registration-request/html.pug rename to server/server/lib/emails/user-registration-request/html.pug diff --git a/server/lib/emails/verify-email/html.pug b/server/server/lib/emails/verify-email/html.pug similarity index 100% rename from server/lib/emails/verify-email/html.pug rename to server/server/lib/emails/verify-email/html.pug diff --git a/server/lib/emails/video-abuse-new/html.pug b/server/server/lib/emails/video-abuse-new/html.pug similarity index 100% rename from server/lib/emails/video-abuse-new/html.pug rename to server/server/lib/emails/video-abuse-new/html.pug diff --git a/server/lib/emails/video-auto-blacklist-new/html.pug b/server/server/lib/emails/video-auto-blacklist-new/html.pug similarity index 100% rename from server/lib/emails/video-auto-blacklist-new/html.pug rename to server/server/lib/emails/video-auto-blacklist-new/html.pug diff --git a/server/lib/emails/video-comment-abuse-new/html.pug b/server/server/lib/emails/video-comment-abuse-new/html.pug similarity index 100% rename from server/lib/emails/video-comment-abuse-new/html.pug rename to server/server/lib/emails/video-comment-abuse-new/html.pug diff --git a/server/lib/emails/video-comment-mention/html.pug b/server/server/lib/emails/video-comment-mention/html.pug similarity index 100% rename from server/lib/emails/video-comment-mention/html.pug rename to server/server/lib/emails/video-comment-mention/html.pug diff --git a/server/lib/emails/video-comment-new/html.pug b/server/server/lib/emails/video-comment-new/html.pug similarity index 100% rename from server/lib/emails/video-comment-new/html.pug rename to server/server/lib/emails/video-comment-new/html.pug diff --git a/server/lib/files-cache/avatar-permanent-file-cache.ts b/server/server/lib/files-cache/avatar-permanent-file-cache.ts similarity index 77% rename from server/lib/files-cache/avatar-permanent-file-cache.ts rename to server/server/lib/files-cache/avatar-permanent-file-cache.ts index 0c508b063..7103e0c7f 100644 --- a/server/lib/files-cache/avatar-permanent-file-cache.ts +++ b/server/server/lib/files-cache/avatar-permanent-file-cache.ts @@ -1,8 +1,8 @@ -import { CONFIG } from '@server/initializers/config' -import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants' -import { ActorImageModel } from '@server/models/actor/actor-image' -import { MActorImage } from '@server/types/models' -import { AbstractPermanentFileCache } from './shared' +import { CONFIG } from '@server/initializers/config.js' +import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants.js' +import { ActorImageModel } from '@server/models/actor/actor-image.js' +import { MActorImage } from '@server/types/models/index.js' +import { AbstractPermanentFileCache } from './shared/index.js' export class AvatarPermanentFileCache extends AbstractPermanentFileCache { diff --git a/server/server/lib/files-cache/index.ts b/server/server/lib/files-cache/index.ts new file mode 100644 index 000000000..219baed52 --- /dev/null +++ b/server/server/lib/files-cache/index.ts @@ -0,0 +1,6 @@ +export * from './avatar-permanent-file-cache.js' +export * from './video-miniature-permanent-file-cache.js' +export * from './video-captions-simple-file-cache.js' +export * from './video-previews-simple-file-cache.js' +export * from './video-storyboards-simple-file-cache.js' +export * from './video-torrents-simple-file-cache.js' diff --git a/server/lib/files-cache/shared/abstract-permanent-file-cache.ts b/server/server/lib/files-cache/shared/abstract-permanent-file-cache.ts similarity index 94% rename from server/lib/files-cache/shared/abstract-permanent-file-cache.ts rename to server/server/lib/files-cache/shared/abstract-permanent-file-cache.ts index f990e9872..f9e9878a8 100644 --- a/server/lib/files-cache/shared/abstract-permanent-file-cache.ts +++ b/server/server/lib/files-cache/shared/abstract-permanent-file-cache.ts @@ -1,11 +1,11 @@ import express from 'express' import { LRUCache } from 'lru-cache' import { Model } from 'sequelize' -import { logger } from '@server/helpers/logger' -import { CachePromise } from '@server/helpers/promise-cache' -import { LRU_CACHE, STATIC_MAX_AGE } from '@server/initializers/constants' -import { downloadImageFromWorker } from '@server/lib/worker/parent-process' -import { HttpStatusCode } from '@shared/models' +import { logger } from '@server/helpers/logger.js' +import { CachePromise } from '@server/helpers/promise-cache.js' +import { LRU_CACHE, STATIC_MAX_AGE } from '@server/initializers/constants.js' +import { downloadImageFromWorker } from '@server/lib/worker/parent-process.js' +import { HttpStatusCode } from '@peertube/peertube-models' type ImageModel = { fileUrl: string diff --git a/server/lib/files-cache/shared/abstract-simple-file-cache.ts b/server/server/lib/files-cache/shared/abstract-simple-file-cache.ts similarity index 91% rename from server/lib/files-cache/shared/abstract-simple-file-cache.ts rename to server/server/lib/files-cache/shared/abstract-simple-file-cache.ts index 6fab322cd..1dd45d221 100644 --- a/server/lib/files-cache/shared/abstract-simple-file-cache.ts +++ b/server/server/lib/files-cache/shared/abstract-simple-file-cache.ts @@ -1,5 +1,5 @@ -import { remove } from 'fs-extra' -import { logger } from '../../../helpers/logger' +import { remove } from 'fs-extra/esm' +import { logger } from '../../../helpers/logger.js' import memoizee from 'memoizee' type GetFilePathResult = { isOwned: boolean, path: string, downloadName?: string } | undefined diff --git a/server/server/lib/files-cache/shared/index.ts b/server/server/lib/files-cache/shared/index.ts new file mode 100644 index 000000000..4dc4d8c4d --- /dev/null +++ b/server/server/lib/files-cache/shared/index.ts @@ -0,0 +1,2 @@ +export * from './abstract-permanent-file-cache.js' +export * from './abstract-simple-file-cache.js' diff --git a/server/lib/files-cache/video-captions-simple-file-cache.ts b/server/server/lib/files-cache/video-captions-simple-file-cache.ts similarity index 87% rename from server/lib/files-cache/video-captions-simple-file-cache.ts rename to server/server/lib/files-cache/video-captions-simple-file-cache.ts index cbeeff732..26853706e 100644 --- a/server/lib/files-cache/video-captions-simple-file-cache.ts +++ b/server/server/lib/files-cache/video-captions-simple-file-cache.ts @@ -1,11 +1,11 @@ import { join } from 'path' -import { logger } from '@server/helpers/logger' -import { doRequestAndSaveToFile } from '@server/helpers/requests' -import { CONFIG } from '../../initializers/config' -import { FILES_CACHE } from '../../initializers/constants' -import { VideoModel } from '../../models/video/video' -import { VideoCaptionModel } from '../../models/video/video-caption' -import { AbstractSimpleFileCache } from './shared/abstract-simple-file-cache' +import { logger } from '@server/helpers/logger.js' +import { doRequestAndSaveToFile } from '@server/helpers/requests.js' +import { CONFIG } from '../../initializers/config.js' +import { FILES_CACHE } from '../../initializers/constants.js' +import { VideoModel } from '../../models/video/video.js' +import { VideoCaptionModel } from '../../models/video/video-caption.js' +import { AbstractSimpleFileCache } from './shared/abstract-simple-file-cache.js' class VideoCaptionsSimpleFileCache extends AbstractSimpleFileCache { diff --git a/server/lib/files-cache/video-miniature-permanent-file-cache.ts b/server/server/lib/files-cache/video-miniature-permanent-file-cache.ts similarity index 58% rename from server/lib/files-cache/video-miniature-permanent-file-cache.ts rename to server/server/lib/files-cache/video-miniature-permanent-file-cache.ts index 35d9466f7..d3366ba43 100644 --- a/server/lib/files-cache/video-miniature-permanent-file-cache.ts +++ b/server/server/lib/files-cache/video-miniature-permanent-file-cache.ts @@ -1,9 +1,9 @@ -import { CONFIG } from '@server/initializers/config' -import { THUMBNAILS_SIZE } from '@server/initializers/constants' -import { ThumbnailModel } from '@server/models/video/thumbnail' -import { MThumbnail } from '@server/types/models' -import { ThumbnailType } from '@shared/models' -import { AbstractPermanentFileCache } from './shared' +import { CONFIG } from '@server/initializers/config.js' +import { THUMBNAILS_SIZE } from '@server/initializers/constants.js' +import { ThumbnailModel } from '@server/models/video/thumbnail.js' +import { MThumbnail } from '@server/types/models/index.js' +import { ThumbnailType } from '@peertube/peertube-models' +import { AbstractPermanentFileCache } from './shared/index.js' export class VideoMiniaturePermanentFileCache extends AbstractPermanentFileCache { diff --git a/server/lib/files-cache/video-previews-simple-file-cache.ts b/server/server/lib/files-cache/video-previews-simple-file-cache.ts similarity index 82% rename from server/lib/files-cache/video-previews-simple-file-cache.ts rename to server/server/lib/files-cache/video-previews-simple-file-cache.ts index a05e80e16..4dd0fd148 100644 --- a/server/lib/files-cache/video-previews-simple-file-cache.ts +++ b/server/server/lib/files-cache/video-previews-simple-file-cache.ts @@ -1,11 +1,11 @@ import { join } from 'path' -import { FILES_CACHE } from '../../initializers/constants' -import { VideoModel } from '../../models/video/video' -import { AbstractSimpleFileCache } from './shared/abstract-simple-file-cache' -import { doRequestAndSaveToFile } from '@server/helpers/requests' -import { ThumbnailModel } from '@server/models/video/thumbnail' -import { ThumbnailType } from '@shared/models' -import { logger } from '@server/helpers/logger' +import { FILES_CACHE } from '../../initializers/constants.js' +import { VideoModel } from '../../models/video/video.js' +import { AbstractSimpleFileCache } from './shared/abstract-simple-file-cache.js' +import { doRequestAndSaveToFile } from '@server/helpers/requests.js' +import { ThumbnailModel } from '@server/models/video/thumbnail.js' +import { ThumbnailType } from '@peertube/peertube-models' +import { logger } from '@server/helpers/logger.js' class VideoPreviewsSimpleFileCache extends AbstractSimpleFileCache { diff --git a/server/lib/files-cache/video-storyboards-simple-file-cache.ts b/server/server/lib/files-cache/video-storyboards-simple-file-cache.ts similarity index 91% rename from server/lib/files-cache/video-storyboards-simple-file-cache.ts rename to server/server/lib/files-cache/video-storyboards-simple-file-cache.ts index 4cd96e70c..7991b8d59 100644 --- a/server/lib/files-cache/video-storyboards-simple-file-cache.ts +++ b/server/server/lib/files-cache/video-storyboards-simple-file-cache.ts @@ -1,9 +1,9 @@ import { join } from 'path' -import { logger } from '@server/helpers/logger' -import { doRequestAndSaveToFile } from '@server/helpers/requests' -import { StoryboardModel } from '@server/models/video/storyboard' -import { FILES_CACHE } from '../../initializers/constants' -import { AbstractSimpleFileCache } from './shared/abstract-simple-file-cache' +import { logger } from '@server/helpers/logger.js' +import { doRequestAndSaveToFile } from '@server/helpers/requests.js' +import { StoryboardModel } from '@server/models/video/storyboard.js' +import { FILES_CACHE } from '../../initializers/constants.js' +import { AbstractSimpleFileCache } from './shared/abstract-simple-file-cache.js' class VideoStoryboardsSimpleFileCache extends AbstractSimpleFileCache { diff --git a/server/lib/files-cache/video-torrents-simple-file-cache.ts b/server/server/lib/files-cache/video-torrents-simple-file-cache.ts similarity index 83% rename from server/lib/files-cache/video-torrents-simple-file-cache.ts rename to server/server/lib/files-cache/video-torrents-simple-file-cache.ts index 8bcd0b9bf..5a1ef3467 100644 --- a/server/lib/files-cache/video-torrents-simple-file-cache.ts +++ b/server/server/lib/files-cache/video-torrents-simple-file-cache.ts @@ -1,12 +1,12 @@ import { join } from 'path' -import { logger } from '@server/helpers/logger' -import { doRequestAndSaveToFile } from '@server/helpers/requests' -import { VideoFileModel } from '@server/models/video/video-file' -import { MVideo, MVideoFile } from '@server/types/models' -import { CONFIG } from '../../initializers/config' -import { FILES_CACHE } from '../../initializers/constants' -import { VideoModel } from '../../models/video/video' -import { AbstractSimpleFileCache } from './shared/abstract-simple-file-cache' +import { logger } from '@server/helpers/logger.js' +import { doRequestAndSaveToFile } from '@server/helpers/requests.js' +import { VideoFileModel } from '@server/models/video/video-file.js' +import { MVideo, MVideoFile } from '@server/types/models/index.js' +import { CONFIG } from '../../initializers/config.js' +import { FILES_CACHE } from '../../initializers/constants.js' +import { VideoModel } from '../../models/video/video.js' +import { AbstractSimpleFileCache } from './shared/abstract-simple-file-cache.js' class VideoTorrentsSimpleFileCache extends AbstractSimpleFileCache { diff --git a/server/lib/hls.ts b/server/server/lib/hls.ts similarity index 89% rename from server/lib/hls.ts rename to server/server/lib/hls.ts index 19044d7c2..9a53593fb 100644 --- a/server/lib/hls.ts +++ b/server/server/lib/hls.ts @@ -1,24 +1,25 @@ -import { close, ensureDir, move, open, outputJSON, read, readFile, remove, stat, writeFile } from 'fs-extra' -import { flatten } from 'lodash' +import { uniqify, uuidRegex } from '@peertube/peertube-core-utils' +import { getVideoStreamDimensionsInfo } from '@peertube/peertube-ffmpeg' +import { VideoStorage } from '@peertube/peertube-models' +import { sha256 } from '@peertube/peertube-node-utils' +import { MStreamingPlaylist, MStreamingPlaylistFilesVideo, MVideo } from '@server/types/models/index.js' +import { ensureDir, move, outputJSON, remove } from 'fs-extra/esm' +import { open, readFile, stat, writeFile } from 'fs/promises' +import flatten from 'lodash-es/flatten.js' import PQueue from 'p-queue' import { basename, dirname, join } from 'path' -import { MStreamingPlaylist, MStreamingPlaylistFilesVideo, MVideo } from '@server/types/models' -import { uniqify, uuidRegex } from '@shared/core-utils' -import { sha256 } from '@shared/extra-utils' -import { getVideoStreamDimensionsInfo } from '@shared/ffmpeg' -import { VideoStorage } from '@shared/models' -import { getAudioStreamCodec, getVideoStreamCodec } from '../helpers/ffmpeg' -import { logger, loggerTagsFactory } from '../helpers/logger' -import { doRequest, doRequestAndSaveToFile } from '../helpers/requests' -import { generateRandomString } from '../helpers/utils' -import { CONFIG } from '../initializers/config' -import { P2P_MEDIA_LOADER_PEER_VERSION, REQUEST_TIMEOUTS } from '../initializers/constants' -import { sequelizeTypescript } from '../initializers/database' -import { VideoFileModel } from '../models/video/video-file' -import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' -import { storeHLSFileFromFilename } from './object-storage' -import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename, getHlsResolutionPlaylistFilename } from './paths' -import { VideoPathManager } from './video-path-manager' +import { getAudioStreamCodec, getVideoStreamCodec } from '../helpers/ffmpeg/index.js' +import { logger, loggerTagsFactory } from '../helpers/logger.js' +import { doRequest, doRequestAndSaveToFile } from '../helpers/requests.js' +import { generateRandomString } from '../helpers/utils.js' +import { CONFIG } from '../initializers/config.js' +import { P2P_MEDIA_LOADER_PEER_VERSION, REQUEST_TIMEOUTS } from '../initializers/constants.js' +import { sequelizeTypescript } from '../initializers/database.js' +import { VideoFileModel } from '../models/video/video-file.js' +import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist.js' +import { storeHLSFileFromFilename } from './object-storage/index.js' +import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename, getHlsResolutionPlaylistFilename } from './paths.js' +import { VideoPathManager } from './video-path-manager.js' const lTags = loggerTagsFactory('hls') @@ -105,7 +106,7 @@ function updateMasterHLSPlaylist (video: MVideo, playlistArg: MStreamingPlaylist } return playlist.save() - }) + }, { throwOnTimeout: true }) } // --------------------------------------------------------------------------- @@ -130,11 +131,11 @@ function updateSha256VODSegments (video: MVideo, playlistArg: MStreamingPlaylist const fd = await open(videoPath, 'r') for (const range of ranges) { const buf = Buffer.alloc(range.length) - await read(fd, buf, 0, range.length, range.offset) + await fd.read(buf, 0, range.length, range.offset) rangeHashes[`${range.offset}-${range.offset + range.length - 1}`] = sha256(buf) } - await close(fd) + await fd.close() const videoFilename = file.filename json[videoFilename] = rangeHashes @@ -156,7 +157,7 @@ function updateSha256VODSegments (video: MVideo, playlistArg: MStreamingPlaylist } return playlist.save() - }) + }, { throwOnTimeout: true }) } // --------------------------------------------------------------------------- diff --git a/server/lib/internal-event-emitter.ts b/server/server/lib/internal-event-emitter.ts similarity index 93% rename from server/lib/internal-event-emitter.ts rename to server/server/lib/internal-event-emitter.ts index 08b46a5c3..54f192982 100644 --- a/server/lib/internal-event-emitter.ts +++ b/server/server/lib/internal-event-emitter.ts @@ -1,4 +1,4 @@ -import { MChannel, MVideo } from '@server/types/models' +import { MChannel, MVideo } from '@server/types/models/index.js' import { EventEmitter } from 'events' export interface PeerTubeInternalEvents { diff --git a/server/lib/job-queue/handlers/activitypub-cleaner.ts b/server/server/lib/job-queue/handlers/activitypub-cleaner.ts similarity index 87% rename from server/lib/job-queue/handlers/activitypub-cleaner.ts rename to server/server/lib/job-queue/handlers/activitypub-cleaner.ts index 6ee9e2429..7c8c68fdf 100644 --- a/server/lib/job-queue/handlers/activitypub-cleaner.ts +++ b/server/server/lib/job-queue/handlers/activitypub-cleaner.ts @@ -1,22 +1,22 @@ -import { map } from 'bluebird' +import Bluebird from 'bluebird' import { Job } from 'bullmq' import { isAnnounceActivityValid, isDislikeActivityValid, isLikeActivityValid -} from '@server/helpers/custom-validators/activitypub/activity' -import { sanitizeAndCheckVideoCommentObject } from '@server/helpers/custom-validators/activitypub/video-comments' -import { PeerTubeRequestError } from '@server/helpers/requests' -import { AP_CLEANER } from '@server/initializers/constants' -import { fetchAP } from '@server/lib/activitypub/activity' -import { checkUrlsSameHost } from '@server/lib/activitypub/url' -import { Redis } from '@server/lib/redis' -import { VideoModel } from '@server/models/video/video' -import { VideoCommentModel } from '@server/models/video/video-comment' -import { VideoShareModel } from '@server/models/video/video-share' -import { HttpStatusCode } from '@shared/models' -import { logger, loggerTagsFactory } from '../../../helpers/logger' -import { AccountVideoRateModel } from '../../../models/account/account-video-rate' +} from '@server/helpers/custom-validators/activitypub/activity.js' +import { sanitizeAndCheckVideoCommentObject } from '@server/helpers/custom-validators/activitypub/video-comments.js' +import { PeerTubeRequestError } from '@server/helpers/requests.js' +import { AP_CLEANER } from '@server/initializers/constants.js' +import { fetchAP } from '@server/lib/activitypub/activity.js' +import { checkUrlsSameHost } from '@server/lib/activitypub/url.js' +import { Redis } from '@server/lib/redis.js' +import { VideoCommentModel } from '@server/models/video/video-comment.js' +import { VideoShareModel } from '@server/models/video/video-share.js' +import { VideoModel } from '@server/models/video/video.js' +import { HttpStatusCode } from '@peertube/peertube-models' +import { logger, loggerTagsFactory } from '../../../helpers/logger.js' +import { AccountVideoRateModel } from '../../../models/account/account-video-rate.js' const lTags = loggerTagsFactory('ap-cleaner') @@ -29,7 +29,7 @@ async function processActivityPubCleaner (_job: Job) { const rateUrls = await AccountVideoRateModel.listRemoteRateUrlsOfLocalVideos() const { bodyValidator, deleter, updater } = rateOptionsFactory() - await map(rateUrls, async rateUrl => { + await Bluebird.map(rateUrls, async rateUrl => { // TODO: remove when https://github.com/mastodon/mastodon/issues/13571 is fixed if (rateUrl.includes('#')) return @@ -47,7 +47,7 @@ async function processActivityPubCleaner (_job: Job) { const shareUrls = await VideoShareModel.listRemoteShareUrlsOfLocalVideos() const { bodyValidator, deleter, updater } = shareOptionsFactory() - await map(shareUrls, async shareUrl => { + await Bluebird.map(shareUrls, async shareUrl => { await updateObjectIfNeeded({ url: shareUrl, bodyValidator, updater, deleter }) }, { concurrency: AP_CLEANER.CONCURRENCY }) } @@ -56,7 +56,7 @@ async function processActivityPubCleaner (_job: Job) { const commentUrls = await VideoCommentModel.listRemoteCommentUrlsOfLocalVideos() const { bodyValidator, deleter, updater } = commentOptionsFactory() - await map(commentUrls, async commentUrl => { + await Bluebird.map(commentUrls, async commentUrl => { await updateObjectIfNeeded({ url: commentUrl, bodyValidator, updater, deleter }) }, { concurrency: AP_CLEANER.CONCURRENCY }) } diff --git a/server/lib/job-queue/handlers/activitypub-follow.ts b/server/server/lib/job-queue/handlers/activitypub-follow.ts similarity index 83% rename from server/lib/job-queue/handlers/activitypub-follow.ts rename to server/server/lib/job-queue/handlers/activitypub-follow.ts index a68c32ba0..a5b3a4fd4 100644 --- a/server/lib/job-queue/handlers/activitypub-follow.ts +++ b/server/server/lib/job-queue/handlers/activitypub-follow.ts @@ -1,17 +1,17 @@ import { Job } from 'bullmq' -import { getLocalActorFollowActivityPubUrl } from '@server/lib/activitypub/url' -import { ActivitypubFollowPayload } from '@shared/models' -import { sanitizeHost } from '../../../helpers/core-utils' -import { retryTransactionWrapper } from '../../../helpers/database-utils' -import { logger } from '../../../helpers/logger' -import { REMOTE_SCHEME, WEBSERVER } from '../../../initializers/constants' -import { sequelizeTypescript } from '../../../initializers/database' -import { ActorModel } from '../../../models/actor/actor' -import { ActorFollowModel } from '../../../models/actor/actor-follow' -import { MActor, MActorFull } from '../../../types/models' -import { getOrCreateAPActor, loadActorUrlOrGetFromWebfinger } from '../../activitypub/actors' -import { sendFollow } from '../../activitypub/send' -import { Notifier } from '../../notifier' +import { getLocalActorFollowActivityPubUrl } from '@server/lib/activitypub/url.js' +import { ActivitypubFollowPayload } from '@peertube/peertube-models' +import { sanitizeHost } from '../../../helpers/core-utils.js' +import { retryTransactionWrapper } from '../../../helpers/database-utils.js' +import { logger } from '../../../helpers/logger.js' +import { REMOTE_SCHEME, WEBSERVER } from '../../../initializers/constants.js' +import { sequelizeTypescript } from '../../../initializers/database.js' +import { ActorModel } from '../../../models/actor/actor.js' +import { ActorFollowModel } from '../../../models/actor/actor-follow.js' +import { MActor, MActorFull } from '../../../types/models/index.js' +import { getOrCreateAPActor, loadActorUrlOrGetFromWebfinger } from '../../activitypub/actors/index.js' +import { sendFollow } from '../../activitypub/send/index.js' +import { Notifier } from '../../notifier/index.js' async function processActivityPubFollow (job: Job) { const payload = job.data as ActivitypubFollowPayload diff --git a/server/lib/job-queue/handlers/activitypub-http-broadcast.ts b/server/server/lib/job-queue/handlers/activitypub-http-broadcast.ts similarity index 80% rename from server/lib/job-queue/handlers/activitypub-http-broadcast.ts rename to server/server/lib/job-queue/handlers/activitypub-http-broadcast.ts index 8904d086f..f7307c97d 100644 --- a/server/lib/job-queue/handlers/activitypub-http-broadcast.ts +++ b/server/server/lib/job-queue/handlers/activitypub-http-broadcast.ts @@ -1,9 +1,10 @@ import { Job } from 'bullmq' -import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from '@server/lib/activitypub/send' -import { ActorFollowHealthCache } from '@server/lib/actor-follow-health-cache' -import { parallelHTTPBroadcastFromWorker, sequentialHTTPBroadcastFromWorker } from '@server/lib/worker/parent-process' -import { ActivitypubHttpBroadcastPayload } from '@shared/models' -import { logger } from '../../../helpers/logger' +import { ActivitypubHttpBroadcastPayload } from '@peertube/peertube-models' +import { buildGlobalHTTPHeaders } from '@server/helpers/activity-pub-utils.js' +import { buildSignedRequestOptions, computeBody } from '@server/lib/activitypub/send/index.js' +import { ActorFollowHealthCache } from '@server/lib/actor-follow-health-cache.js' +import { parallelHTTPBroadcastFromWorker, sequentialHTTPBroadcastFromWorker } from '@server/lib/worker/parent-process.js' +import { logger } from '../../../helpers/logger.js' // Prefer using a worker thread for HTTP requests because on high load we may have to sign many requests, which can be CPU intensive @@ -44,6 +45,6 @@ async function buildRequestOptions (payload: ActivitypubHttpBroadcastPayload) { method: 'POST' as 'POST', json: body, httpSignature: httpSignatureOptions, - headers: buildGlobalHeaders(body) + headers: buildGlobalHTTPHeaders(body) } } diff --git a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts b/server/server/lib/job-queue/handlers/activitypub-http-fetcher.ts similarity index 74% rename from server/lib/job-queue/handlers/activitypub-http-fetcher.ts rename to server/server/lib/job-queue/handlers/activitypub-http-fetcher.ts index b6cb3c4a6..649d23650 100644 --- a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts +++ b/server/server/lib/job-queue/handlers/activitypub-http-fetcher.ts @@ -1,15 +1,15 @@ import { Job } from 'bullmq' -import { ActivitypubHttpFetcherPayload, FetchType } from '@shared/models' -import { logger } from '../../../helpers/logger' -import { VideoModel } from '../../../models/video/video' -import { VideoCommentModel } from '../../../models/video/video-comment' -import { VideoShareModel } from '../../../models/video/video-share' -import { MVideoFullLight } from '../../../types/models' -import { crawlCollectionPage } from '../../activitypub/crawl' -import { createAccountPlaylists } from '../../activitypub/playlists' -import { processActivities } from '../../activitypub/process' -import { addVideoShares } from '../../activitypub/share' -import { addVideoComments } from '../../activitypub/video-comments' +import { ActivitypubHttpFetcherPayload, FetchType } from '@peertube/peertube-models' +import { logger } from '../../../helpers/logger.js' +import { VideoModel } from '../../../models/video/video.js' +import { VideoCommentModel } from '../../../models/video/video-comment.js' +import { VideoShareModel } from '../../../models/video/video-share.js' +import { MVideoFullLight } from '../../../types/models/index.js' +import { crawlCollectionPage } from '../../activitypub/crawl.js' +import { createAccountPlaylists } from '../../activitypub/playlists/index.js' +import { processActivities } from '../../activitypub/process/index.js' +import { addVideoShares } from '../../activitypub/share.js' +import { addVideoComments } from '../../activitypub/video-comments.js' async function processActivityPubHttpFetcher (job: Job) { logger.info('Processing ActivityPub fetcher in job %s.', job.id) diff --git a/server/lib/job-queue/handlers/activitypub-http-unicast.ts b/server/server/lib/job-queue/handlers/activitypub-http-unicast.ts similarity index 69% rename from server/lib/job-queue/handlers/activitypub-http-unicast.ts rename to server/server/lib/job-queue/handlers/activitypub-http-unicast.ts index 50fca3f94..9b2f542f0 100644 --- a/server/lib/job-queue/handlers/activitypub-http-unicast.ts +++ b/server/server/lib/job-queue/handlers/activitypub-http-unicast.ts @@ -1,9 +1,10 @@ import { Job } from 'bullmq' -import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from '@server/lib/activitypub/send' -import { ActivitypubHttpUnicastPayload } from '@shared/models' -import { logger } from '../../../helpers/logger' -import { doRequest } from '../../../helpers/requests' -import { ActorFollowHealthCache } from '../../actor-follow-health-cache' +import { ActivitypubHttpUnicastPayload } from '@peertube/peertube-models' +import { buildGlobalHTTPHeaders } from '@server/helpers/activity-pub-utils.js' +import { buildSignedRequestOptions, computeBody } from '@server/lib/activitypub/send/index.js' +import { logger } from '../../../helpers/logger.js' +import { doRequest } from '../../../helpers/requests.js' +import { ActorFollowHealthCache } from '../../actor-follow-health-cache.js' async function processActivityPubHttpUnicast (job: Job) { logger.info('Processing ActivityPub unicast in job %s.', job.id) @@ -18,7 +19,7 @@ async function processActivityPubHttpUnicast (job: Job) { method: 'POST' as 'POST', json: body, httpSignature: httpSignatureOptions, - headers: buildGlobalHeaders(body) + headers: buildGlobalHTTPHeaders(body) } try { diff --git a/server/lib/job-queue/handlers/activitypub-refresher.ts b/server/server/lib/job-queue/handlers/activitypub-refresher.ts similarity index 82% rename from server/lib/job-queue/handlers/activitypub-refresher.ts rename to server/server/lib/job-queue/handlers/activitypub-refresher.ts index 706bf17fa..ae238396e 100644 --- a/server/lib/job-queue/handlers/activitypub-refresher.ts +++ b/server/server/lib/job-queue/handlers/activitypub-refresher.ts @@ -1,12 +1,12 @@ import { Job } from 'bullmq' -import { refreshVideoPlaylistIfNeeded } from '@server/lib/activitypub/playlists' -import { refreshVideoIfNeeded } from '@server/lib/activitypub/videos' -import { loadVideoByUrl } from '@server/lib/model-loaders' -import { RefreshPayload } from '@shared/models' -import { logger } from '../../../helpers/logger' -import { ActorModel } from '../../../models/actor/actor' -import { VideoPlaylistModel } from '../../../models/video/video-playlist' -import { refreshActorIfNeeded } from '../../activitypub/actors' +import { refreshVideoPlaylistIfNeeded } from '@server/lib/activitypub/playlists/index.js' +import { refreshVideoIfNeeded } from '@server/lib/activitypub/videos/index.js' +import { loadVideoByUrl } from '@server/lib/model-loaders/index.js' +import { RefreshPayload } from '@peertube/peertube-models' +import { logger } from '../../../helpers/logger.js' +import { ActorModel } from '../../../models/actor/actor.js' +import { VideoPlaylistModel } from '../../../models/video/video-playlist.js' +import { refreshActorIfNeeded } from '../../activitypub/actors/index.js' async function refreshAPObject (job: Job) { const payload = job.data as RefreshPayload diff --git a/server/lib/job-queue/handlers/actor-keys.ts b/server/server/lib/job-queue/handlers/actor-keys.ts similarity index 70% rename from server/lib/job-queue/handlers/actor-keys.ts rename to server/server/lib/job-queue/handlers/actor-keys.ts index 27a2d431b..40dfc6d49 100644 --- a/server/lib/job-queue/handlers/actor-keys.ts +++ b/server/server/lib/job-queue/handlers/actor-keys.ts @@ -1,8 +1,8 @@ import { Job } from 'bullmq' -import { generateAndSaveActorKeys } from '@server/lib/activitypub/actors' -import { ActorModel } from '@server/models/actor/actor' -import { ActorKeysPayload } from '@shared/models' -import { logger } from '../../../helpers/logger' +import { generateAndSaveActorKeys } from '@server/lib/activitypub/actors/index.js' +import { ActorModel } from '@server/models/actor/actor.js' +import { ActorKeysPayload } from '@peertube/peertube-models' +import { logger } from '../../../helpers/logger.js' async function processActorKeys (job: Job) { const payload = job.data as ActorKeysPayload diff --git a/server/lib/job-queue/handlers/after-video-channel-import.ts b/server/server/lib/job-queue/handlers/after-video-channel-import.ts similarity index 90% rename from server/lib/job-queue/handlers/after-video-channel-import.ts rename to server/server/lib/job-queue/handlers/after-video-channel-import.ts index ffdd8c5b5..91d889dcb 100644 --- a/server/lib/job-queue/handlers/after-video-channel-import.ts +++ b/server/server/lib/job-queue/handlers/after-video-channel-import.ts @@ -1,7 +1,7 @@ import { Job } from 'bullmq' -import { logger } from '@server/helpers/logger' -import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync' -import { AfterVideoChannelImportPayload, VideoChannelSyncState, VideoImportPreventExceptionResult } from '@shared/models' +import { logger } from '@server/helpers/logger.js' +import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync.js' +import { AfterVideoChannelImportPayload, VideoChannelSyncState, VideoImportPreventExceptionResult } from '@peertube/peertube-models' export async function processAfterVideoChannelImport (job: Job) { const payload = job.data as AfterVideoChannelImportPayload diff --git a/server/lib/job-queue/handlers/email.ts b/server/server/lib/job-queue/handlers/email.ts similarity index 67% rename from server/lib/job-queue/handlers/email.ts rename to server/server/lib/job-queue/handlers/email.ts index 567bcc076..26b084e03 100644 --- a/server/lib/job-queue/handlers/email.ts +++ b/server/server/lib/job-queue/handlers/email.ts @@ -1,7 +1,7 @@ import { Job } from 'bullmq' -import { EmailPayload } from '@shared/models' -import { logger } from '../../../helpers/logger' -import { Emailer } from '../../emailer' +import { EmailPayload } from '@peertube/peertube-models' +import { logger } from '../../../helpers/logger.js' +import { Emailer } from '../../emailer.js' async function processEmail (job: Job) { const payload = job.data as EmailPayload diff --git a/server/lib/job-queue/handlers/federate-video.ts b/server/server/lib/job-queue/handlers/federate-video.ts similarity index 78% rename from server/lib/job-queue/handlers/federate-video.ts rename to server/server/lib/job-queue/handlers/federate-video.ts index 6aac36741..270ce6cc5 100644 --- a/server/lib/job-queue/handlers/federate-video.ts +++ b/server/server/lib/job-queue/handlers/federate-video.ts @@ -1,10 +1,10 @@ import { Job } from 'bullmq' -import { retryTransactionWrapper } from '@server/helpers/database-utils' -import { sequelizeTypescript } from '@server/initializers/database' -import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' -import { VideoModel } from '@server/models/video/video' -import { FederateVideoPayload } from '@shared/models' -import { logger } from '../../../helpers/logger' +import { retryTransactionWrapper } from '@server/helpers/database-utils.js' +import { sequelizeTypescript } from '@server/initializers/database.js' +import { federateVideoIfNeeded } from '@server/lib/activitypub/videos/index.js' +import { VideoModel } from '@server/models/video/video.js' +import { FederateVideoPayload } from '@peertube/peertube-models' +import { logger } from '../../../helpers/logger.js' function processFederateVideo (job: Job) { const payload = job.data as FederateVideoPayload diff --git a/server/lib/job-queue/handlers/generate-storyboard.ts b/server/server/lib/job-queue/handlers/generate-storyboard.ts similarity index 91% rename from server/lib/job-queue/handlers/generate-storyboard.ts rename to server/server/lib/job-queue/handlers/generate-storyboard.ts index eea20274a..6f4d00dc5 100644 --- a/server/lib/job-queue/handlers/generate-storyboard.ts +++ b/server/server/lib/job-queue/handlers/generate-storyboard.ts @@ -1,20 +1,20 @@ import { Job } from 'bullmq' import { join } from 'path' -import { retryTransactionWrapper } from '@server/helpers/database-utils' -import { getFFmpegCommandWrapperOptions } from '@server/helpers/ffmpeg' -import { generateImageFilename, getImageSize } from '@server/helpers/image-utils' -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { deleteFileAndCatch } from '@server/helpers/utils' -import { CONFIG } from '@server/initializers/config' -import { STORYBOARD } from '@server/initializers/constants' -import { sequelizeTypescript } from '@server/initializers/database' -import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' -import { VideoPathManager } from '@server/lib/video-path-manager' -import { StoryboardModel } from '@server/models/video/storyboard' -import { VideoModel } from '@server/models/video/video' -import { MVideo } from '@server/types/models' -import { FFmpegImage, isAudioFile } from '@shared/ffmpeg' -import { GenerateStoryboardPayload } from '@shared/models' +import { retryTransactionWrapper } from '@server/helpers/database-utils.js' +import { getFFmpegCommandWrapperOptions } from '@server/helpers/ffmpeg/index.js' +import { generateImageFilename, getImageSize } from '@server/helpers/image-utils.js' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { deleteFileAndCatch } from '@server/helpers/utils.js' +import { CONFIG } from '@server/initializers/config.js' +import { STORYBOARD } from '@server/initializers/constants.js' +import { sequelizeTypescript } from '@server/initializers/database.js' +import { federateVideoIfNeeded } from '@server/lib/activitypub/videos/index.js' +import { VideoPathManager } from '@server/lib/video-path-manager.js' +import { StoryboardModel } from '@server/models/video/storyboard.js' +import { VideoModel } from '@server/models/video/video.js' +import { MVideo } from '@server/types/models/index.js' +import { FFmpegImage, isAudioFile } from '@peertube/peertube-ffmpeg' +import { GenerateStoryboardPayload } from '@peertube/peertube-models' const lTagsBase = loggerTagsFactory('storyboard') diff --git a/server/lib/job-queue/handlers/manage-video-torrent.ts b/server/server/lib/job-queue/handlers/manage-video-torrent.ts similarity index 89% rename from server/lib/job-queue/handlers/manage-video-torrent.ts rename to server/server/lib/job-queue/handlers/manage-video-torrent.ts index edf52de0c..24bfc5acb 100644 --- a/server/lib/job-queue/handlers/manage-video-torrent.ts +++ b/server/server/lib/job-queue/handlers/manage-video-torrent.ts @@ -1,12 +1,12 @@ import { Job } from 'bullmq' -import { extractVideo } from '@server/helpers/video' -import { createTorrentAndSetInfoHash, updateTorrentMetadata } from '@server/helpers/webtorrent' -import { VideoPathManager } from '@server/lib/video-path-manager' -import { VideoModel } from '@server/models/video/video' -import { VideoFileModel } from '@server/models/video/video-file' -import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' -import { ManageVideoTorrentPayload } from '@shared/models' -import { logger } from '../../../helpers/logger' +import { extractVideo } from '@server/helpers/video.js' +import { createTorrentAndSetInfoHash, updateTorrentMetadata } from '@server/helpers/webtorrent.js' +import { VideoPathManager } from '@server/lib/video-path-manager.js' +import { VideoModel } from '@server/models/video/video.js' +import { VideoFileModel } from '@server/models/video/video-file.js' +import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist.js' +import { ManageVideoTorrentPayload } from '@peertube/peertube-models' +import { logger } from '../../../helpers/logger.js' async function processManageVideoTorrent (job: Job) { const payload = job.data as ManageVideoTorrentPayload diff --git a/server/lib/job-queue/handlers/move-to-object-storage.ts b/server/server/lib/job-queue/handlers/move-to-object-storage.ts similarity index 92% rename from server/lib/job-queue/handlers/move-to-object-storage.ts rename to server/server/lib/job-queue/handlers/move-to-object-storage.ts index 9a99b6722..be3021247 100644 --- a/server/lib/job-queue/handlers/move-to-object-storage.ts +++ b/server/server/lib/job-queue/handlers/move-to-object-storage.ts @@ -1,17 +1,17 @@ import { Job } from 'bullmq' -import { remove } from 'fs-extra' +import { remove } from 'fs-extra/esm' import { join } from 'path' -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { updateTorrentMetadata } from '@server/helpers/webtorrent' -import { P2P_MEDIA_LOADER_PEER_VERSION } from '@server/initializers/constants' -import { storeHLSFileFromFilename, storeWebVideoFile } from '@server/lib/object-storage' -import { getHLSDirectory, getHlsResolutionPlaylistFilename } from '@server/lib/paths' -import { VideoPathManager } from '@server/lib/video-path-manager' -import { moveToFailedMoveToObjectStorageState, moveToNextState } from '@server/lib/video-state' -import { VideoModel } from '@server/models/video/video' -import { VideoJobInfoModel } from '@server/models/video/video-job-info' -import { MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoWithAllFiles } from '@server/types/models' -import { MoveObjectStoragePayload, VideoState, VideoStorage } from '@shared/models' +import { MoveObjectStoragePayload, VideoStateType, VideoStorage } from '@peertube/peertube-models' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { updateTorrentMetadata } from '@server/helpers/webtorrent.js' +import { P2P_MEDIA_LOADER_PEER_VERSION } from '@server/initializers/constants.js' +import { storeHLSFileFromFilename, storeWebVideoFile } from '@server/lib/object-storage/index.js' +import { getHLSDirectory, getHlsResolutionPlaylistFilename } from '@server/lib/paths.js' +import { VideoPathManager } from '@server/lib/video-path-manager.js' +import { moveToFailedMoveToObjectStorageState, moveToNextState } from '@server/lib/video-state.js' +import { VideoJobInfoModel } from '@server/models/video/video-job-info.js' +import { VideoModel } from '@server/models/video/video.js' +import { MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoWithAllFiles } from '@server/types/models/index.js' const lTagsBase = loggerTagsFactory('move-object-storage') @@ -109,7 +109,7 @@ async function moveHLSFiles (video: MVideoWithAllFiles) { async function doAfterLastJob (options: { video: MVideoWithAllFiles - previousVideoState: VideoState + previousVideoState: VideoStateType isNewVideo: boolean }) { const { video, previousVideoState, isNewVideo } = options diff --git a/server/lib/job-queue/handlers/notify.ts b/server/server/lib/job-queue/handlers/notify.ts similarity index 75% rename from server/lib/job-queue/handlers/notify.ts rename to server/server/lib/job-queue/handlers/notify.ts index 83605396c..a09f43bf8 100644 --- a/server/lib/job-queue/handlers/notify.ts +++ b/server/server/lib/job-queue/handlers/notify.ts @@ -1,8 +1,8 @@ import { Job } from 'bullmq' -import { Notifier } from '@server/lib/notifier' -import { VideoModel } from '@server/models/video/video' -import { NotifyPayload } from '@shared/models' -import { logger } from '../../../helpers/logger' +import { Notifier } from '@server/lib/notifier/index.js' +import { VideoModel } from '@server/models/video/video.js' +import { NotifyPayload } from '@peertube/peertube-models' +import { logger } from '../../../helpers/logger.js' async function processNotify (job: Job) { const payload = job.data as NotifyPayload diff --git a/server/lib/job-queue/handlers/transcoding-job-builder.ts b/server/server/lib/job-queue/handlers/transcoding-job-builder.ts similarity index 77% rename from server/lib/job-queue/handlers/transcoding-job-builder.ts rename to server/server/lib/job-queue/handlers/transcoding-job-builder.ts index 8621b109f..9e29b86da 100644 --- a/server/lib/job-queue/handlers/transcoding-job-builder.ts +++ b/server/server/lib/job-queue/handlers/transcoding-job-builder.ts @@ -1,12 +1,12 @@ import { Job } from 'bullmq' -import { createOptimizeOrMergeAudioJobs } from '@server/lib/transcoding/create-transcoding-job' -import { UserModel } from '@server/models/user/user' -import { VideoModel } from '@server/models/video/video' -import { VideoJobInfoModel } from '@server/models/video/video-job-info' -import { pick } from '@shared/core-utils' -import { TranscodingJobBuilderPayload } from '@shared/models' -import { logger } from '../../../helpers/logger' -import { JobQueue } from '../job-queue' +import { createOptimizeOrMergeAudioJobs } from '@server/lib/transcoding/create-transcoding-job.js' +import { UserModel } from '@server/models/user/user.js' +import { VideoJobInfoModel } from '@server/models/video/video-job-info.js' +import { VideoModel } from '@server/models/video/video.js' +import { pick } from '@peertube/peertube-core-utils' +import { TranscodingJobBuilderPayload } from '@peertube/peertube-models' +import { logger } from '../../../helpers/logger.js' +import { JobQueue } from '../job-queue.js' async function processTranscodingJobBuilder (job: Job) { const payload = job.data as TranscodingJobBuilderPayload diff --git a/server/lib/job-queue/handlers/video-channel-import.ts b/server/server/lib/job-queue/handlers/video-channel-import.ts similarity index 80% rename from server/lib/job-queue/handlers/video-channel-import.ts rename to server/server/lib/job-queue/handlers/video-channel-import.ts index 035f88e96..b5f87e11f 100644 --- a/server/lib/job-queue/handlers/video-channel-import.ts +++ b/server/server/lib/job-queue/handlers/video-channel-import.ts @@ -1,11 +1,11 @@ import { Job } from 'bullmq' -import { logger } from '@server/helpers/logger' -import { CONFIG } from '@server/initializers/config' -import { synchronizeChannel } from '@server/lib/sync-channel' -import { VideoChannelModel } from '@server/models/video/video-channel' -import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync' -import { MChannelSync } from '@server/types/models' -import { VideoChannelImportPayload } from '@shared/models' +import { logger } from '@server/helpers/logger.js' +import { CONFIG } from '@server/initializers/config.js' +import { synchronizeChannel } from '@server/lib/sync-channel.js' +import { VideoChannelModel } from '@server/models/video/video-channel.js' +import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync.js' +import { MChannelSync } from '@server/types/models/index.js' +import { VideoChannelImportPayload } from '@peertube/peertube-models' export async function processVideoChannelImport (job: Job) { const payload = job.data as VideoChannelImportPayload diff --git a/server/lib/job-queue/handlers/video-file-import.ts b/server/server/lib/job-queue/handlers/video-file-import.ts similarity index 75% rename from server/lib/job-queue/handlers/video-file-import.ts rename to server/server/lib/job-queue/handlers/video-file-import.ts index d221e8968..899b5dac2 100644 --- a/server/lib/job-queue/handlers/video-file-import.ts +++ b/server/server/lib/job-queue/handlers/video-file-import.ts @@ -1,19 +1,20 @@ import { Job } from 'bullmq' -import { copy, stat } from 'fs-extra' -import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' -import { CONFIG } from '@server/initializers/config' -import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' -import { generateWebVideoFilename } from '@server/lib/paths' -import { buildMoveToObjectStorageJob } from '@server/lib/video' -import { VideoPathManager } from '@server/lib/video-path-manager' -import { VideoModel } from '@server/models/video/video' -import { VideoFileModel } from '@server/models/video/video-file' -import { MVideoFullLight } from '@server/types/models' -import { getLowercaseExtension } from '@shared/core-utils' -import { getVideoStreamDimensionsInfo, getVideoStreamFPS } from '@shared/ffmpeg' -import { VideoFileImportPayload, VideoStorage } from '@shared/models' -import { logger } from '../../../helpers/logger' -import { JobQueue } from '../job-queue' +import { copy } from 'fs-extra/esm' +import { stat } from 'fs/promises' +import { VideoFileImportPayload, VideoStorage } from '@peertube/peertube-models' +import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent.js' +import { CONFIG } from '@server/initializers/config.js' +import { federateVideoIfNeeded } from '@server/lib/activitypub/videos/index.js' +import { generateWebVideoFilename } from '@server/lib/paths.js' +import { VideoPathManager } from '@server/lib/video-path-manager.js' +import { buildMoveToObjectStorageJob } from '@server/lib/video.js' +import { VideoFileModel } from '@server/models/video/video-file.js' +import { VideoModel } from '@server/models/video/video.js' +import { MVideoFullLight } from '@server/types/models/index.js' +import { getLowercaseExtension } from '@peertube/peertube-node-utils' +import { getVideoStreamDimensionsInfo, getVideoStreamFPS } from '@peertube/peertube-ffmpeg' +import { logger } from '../../../helpers/logger.js' +import { JobQueue } from '../job-queue.js' async function processVideoFileImport (job: Job) { const payload = job.data as VideoFileImportPayload diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/server/lib/job-queue/handlers/video-import.ts similarity index 87% rename from server/lib/job-queue/handlers/video-import.ts rename to server/server/lib/job-queue/handlers/video-import.ts index e5cd258d6..7d5435a3b 100644 --- a/server/lib/job-queue/handlers/video-import.ts +++ b/server/server/lib/job-queue/handlers/video-import.ts @@ -1,24 +1,9 @@ import { Job } from 'bullmq' -import { move, remove, stat } from 'fs-extra' -import { retryTransactionWrapper } from '@server/helpers/database-utils' -import { YoutubeDLWrapper } from '@server/helpers/youtube-dl' -import { CONFIG } from '@server/initializers/config' -import { isPostImportVideoAccepted } from '@server/lib/moderation' -import { generateWebVideoFilename } from '@server/lib/paths' -import { Hooks } from '@server/lib/plugins/hooks' -import { ServerConfigManager } from '@server/lib/server-config-manager' -import { createOptimizeOrMergeAudioJobs } from '@server/lib/transcoding/create-transcoding-job' -import { isAbleToUploadVideo } from '@server/lib/user' -import { buildMoveToObjectStorageJob } from '@server/lib/video' -import { VideoPathManager } from '@server/lib/video-path-manager' -import { buildNextVideoState } from '@server/lib/video-state' -import { ThumbnailModel } from '@server/models/video/thumbnail' -import { MUserId, MVideoFile, MVideoFullLight } from '@server/types/models' -import { MVideoImport, MVideoImportDefault, MVideoImportDefaultFiles, MVideoImportVideo } from '@server/types/models/video/video-import' -import { getLowercaseExtension } from '@shared/core-utils' -import { ffprobePromise, getVideoStreamDimensionsInfo, getVideoStreamDuration, getVideoStreamFPS, isAudioFile } from '@shared/ffmpeg' +import { move, remove } from 'fs-extra/esm' +import { stat } from 'fs/promises' import { ThumbnailType, + ThumbnailType_Type, VideoImportPayload, VideoImportPreventExceptionResult, VideoImportState, @@ -28,19 +13,42 @@ import { VideoImportYoutubeDLPayloadType, VideoResolution, VideoState -} from '@shared/models' -import { logger } from '../../../helpers/logger' -import { getSecureTorrentName } from '../../../helpers/utils' -import { createTorrentAndSetInfoHash, downloadWebTorrentVideo } from '../../../helpers/webtorrent' -import { JOB_TTL } from '../../../initializers/constants' -import { sequelizeTypescript } from '../../../initializers/database' -import { VideoModel } from '../../../models/video/video' -import { VideoFileModel } from '../../../models/video/video-file' -import { VideoImportModel } from '../../../models/video/video-import' -import { federateVideoIfNeeded } from '../../activitypub/videos' -import { Notifier } from '../../notifier' -import { generateLocalVideoMiniature } from '../../thumbnail' -import { JobQueue } from '../job-queue' +} from '@peertube/peertube-models' +import { retryTransactionWrapper } from '@server/helpers/database-utils.js' +import { YoutubeDLWrapper } from '@server/helpers/youtube-dl/index.js' +import { CONFIG } from '@server/initializers/config.js' +import { isPostImportVideoAccepted } from '@server/lib/moderation.js' +import { generateWebVideoFilename } from '@server/lib/paths.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { ServerConfigManager } from '@server/lib/server-config-manager.js' +import { createOptimizeOrMergeAudioJobs } from '@server/lib/transcoding/create-transcoding-job.js' +import { isAbleToUploadVideo } from '@server/lib/user.js' +import { VideoPathManager } from '@server/lib/video-path-manager.js' +import { buildNextVideoState } from '@server/lib/video-state.js' +import { buildMoveToObjectStorageJob } from '@server/lib/video.js' +import { ThumbnailModel } from '@server/models/video/thumbnail.js' +import { MUserId, MVideoFile, MVideoFullLight } from '@server/types/models/index.js' +import { MVideoImport, MVideoImportDefault, MVideoImportDefaultFiles, MVideoImportVideo } from '@server/types/models/video/video-import.js' +import { getLowercaseExtension } from '@peertube/peertube-node-utils' +import { + ffprobePromise, + getVideoStreamDimensionsInfo, + getVideoStreamDuration, + getVideoStreamFPS, + isAudioFile +} from '@peertube/peertube-ffmpeg' +import { logger } from '../../../helpers/logger.js' +import { getSecureTorrentName } from '../../../helpers/utils.js' +import { createTorrentAndSetInfoHash, downloadWebTorrentVideo } from '../../../helpers/webtorrent.js' +import { JOB_TTL } from '../../../initializers/constants.js' +import { sequelizeTypescript } from '../../../initializers/database.js' +import { VideoFileModel } from '../../../models/video/video-file.js' +import { VideoImportModel } from '../../../models/video/video-import.js' +import { VideoModel } from '../../../models/video/video.js' +import { federateVideoIfNeeded } from '../../activitypub/videos/index.js' +import { Notifier } from '../../notifier/index.js' +import { generateLocalVideoMiniature } from '../../thumbnail.js' +import { JobQueue } from '../job-queue.js' async function processVideoImport (job: Job): Promise { const payload = job.data as VideoImportPayload @@ -261,7 +269,11 @@ async function refreshVideoImportFromDB (videoImport: MVideoImportDefault, video return Object.assign(videoImport, { Video: videoWithFiles }) } -async function generateMiniature (videoImportWithFiles: MVideoImportDefaultFiles, videoFile: MVideoFile, thumbnailType: ThumbnailType) { +async function generateMiniature ( + videoImportWithFiles: MVideoImportDefaultFiles, + videoFile: MVideoFile, + thumbnailType: ThumbnailType_Type +) { // Generate miniature if the import did not created it const needsMiniature = thumbnailType === ThumbnailType.MINIATURE ? !videoImportWithFiles.Video.getMiniature() diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/server/lib/job-queue/handlers/video-live-ending.ts similarity index 91% rename from server/lib/job-queue/handlers/video-live-ending.ts rename to server/server/lib/job-queue/handlers/video-live-ending.ts index 070d1d7a2..0b4a4fd8b 100644 --- a/server/lib/job-queue/handlers/video-live-ending.ts +++ b/server/server/lib/job-queue/handlers/video-live-ending.ts @@ -1,28 +1,29 @@ import { Job } from 'bullmq' -import { readdir, remove } from 'fs-extra' +import { remove } from 'fs-extra/esm' +import { readdir } from 'fs/promises' import { join } from 'path' -import { peertubeTruncate } from '@server/helpers/core-utils' -import { CONSTRAINTS_FIELDS } from '@server/initializers/constants' -import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url' -import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' -import { cleanupAndDestroyPermanentLive, cleanupTMPLiveFiles, cleanupUnsavedNormalLive } from '@server/lib/live' -import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename, getLiveReplayBaseDirectory } from '@server/lib/paths' -import { generateLocalVideoMiniature, regenerateMiniaturesIfNeeded } from '@server/lib/thumbnail' -import { generateHlsPlaylistResolutionFromTS } from '@server/lib/transcoding/hls-transcoding' -import { VideoPathManager } from '@server/lib/video-path-manager' -import { moveToNextState } from '@server/lib/video-state' -import { VideoModel } from '@server/models/video/video' -import { VideoBlacklistModel } from '@server/models/video/video-blacklist' -import { VideoFileModel } from '@server/models/video/video-file' -import { VideoLiveModel } from '@server/models/video/video-live' -import { VideoLiveReplaySettingModel } from '@server/models/video/video-live-replay-setting' -import { VideoLiveSessionModel } from '@server/models/video/video-live-session' -import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' -import { MVideo, MVideoLive, MVideoLiveSession, MVideoWithAllFiles } from '@server/types/models' -import { ffprobePromise, getAudioStream, getVideoStreamDimensionsInfo, getVideoStreamFPS } from '@shared/ffmpeg' -import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models' -import { logger, loggerTagsFactory } from '../../../helpers/logger' -import { JobQueue } from '../job-queue' +import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@peertube/peertube-models' +import { peertubeTruncate } from '@server/helpers/core-utils.js' +import { CONSTRAINTS_FIELDS } from '@server/initializers/constants.js' +import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url.js' +import { federateVideoIfNeeded } from '@server/lib/activitypub/videos/index.js' +import { cleanupAndDestroyPermanentLive, cleanupTMPLiveFiles, cleanupUnsavedNormalLive } from '@server/lib/live/index.js' +import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename, getLiveReplayBaseDirectory } from '@server/lib/paths.js' +import { generateLocalVideoMiniature, regenerateMiniaturesIfNeeded } from '@server/lib/thumbnail.js' +import { generateHlsPlaylistResolutionFromTS } from '@server/lib/transcoding/hls-transcoding.js' +import { VideoPathManager } from '@server/lib/video-path-manager.js' +import { moveToNextState } from '@server/lib/video-state.js' +import { VideoBlacklistModel } from '@server/models/video/video-blacklist.js' +import { VideoFileModel } from '@server/models/video/video-file.js' +import { VideoLiveReplaySettingModel } from '@server/models/video/video-live-replay-setting.js' +import { VideoLiveSessionModel } from '@server/models/video/video-live-session.js' +import { VideoLiveModel } from '@server/models/video/video-live.js' +import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist.js' +import { VideoModel } from '@server/models/video/video.js' +import { MVideo, MVideoLive, MVideoLiveSession, MVideoWithAllFiles } from '@server/types/models/index.js' +import { ffprobePromise, getAudioStream, getVideoStreamDimensionsInfo, getVideoStreamFPS } from '@peertube/peertube-ffmpeg' +import { logger, loggerTagsFactory } from '../../../helpers/logger.js' +import { JobQueue } from '../job-queue.js' const lTags = loggerTagsFactory('live', 'job') diff --git a/server/lib/job-queue/handlers/video-redundancy.ts b/server/server/lib/job-queue/handlers/video-redundancy.ts similarity index 75% rename from server/lib/job-queue/handlers/video-redundancy.ts rename to server/server/lib/job-queue/handlers/video-redundancy.ts index bac99fdb7..b4c96219c 100644 --- a/server/lib/job-queue/handlers/video-redundancy.ts +++ b/server/server/lib/job-queue/handlers/video-redundancy.ts @@ -1,7 +1,7 @@ import { Job } from 'bullmq' -import { VideosRedundancyScheduler } from '@server/lib/schedulers/videos-redundancy-scheduler' -import { VideoRedundancyPayload } from '@shared/models' -import { logger } from '../../../helpers/logger' +import { VideosRedundancyScheduler } from '@server/lib/schedulers/videos-redundancy-scheduler.js' +import { VideoRedundancyPayload } from '@peertube/peertube-models' +import { logger } from '../../../helpers/logger.js' async function processVideoRedundancy (job: Job) { const payload = job.data as VideoRedundancyPayload diff --git a/server/lib/job-queue/handlers/video-studio-edition.ts b/server/server/lib/job-queue/handlers/video-studio-edition.ts similarity index 88% rename from server/lib/job-queue/handlers/video-studio-edition.ts rename to server/server/lib/job-queue/handlers/video-studio-edition.ts index caf051bfa..3ddf0fa82 100644 --- a/server/lib/job-queue/handlers/video-studio-edition.ts +++ b/server/server/lib/job-queue/handlers/video-studio-edition.ts @@ -1,18 +1,18 @@ import { Job } from 'bullmq' -import { remove } from 'fs-extra' +import { remove } from 'fs-extra/esm' import { join } from 'path' -import { getFFmpegCommandWrapperOptions } from '@server/helpers/ffmpeg' -import { CONFIG } from '@server/initializers/config' -import { VideoTranscodingProfilesManager } from '@server/lib/transcoding/default-transcoding-profiles' -import { isAbleToUploadVideo } from '@server/lib/user' -import { VideoPathManager } from '@server/lib/video-path-manager' -import { approximateIntroOutroAdditionalSize, onVideoStudioEnded, safeCleanupStudioTMPFiles } from '@server/lib/video-studio' -import { UserModel } from '@server/models/user/user' -import { VideoModel } from '@server/models/video/video' -import { MVideo, MVideoFullLight } from '@server/types/models' -import { pick } from '@shared/core-utils' -import { buildUUID } from '@shared/extra-utils' -import { FFmpegEdition } from '@shared/ffmpeg' +import { getFFmpegCommandWrapperOptions } from '@server/helpers/ffmpeg/index.js' +import { CONFIG } from '@server/initializers/config.js' +import { VideoTranscodingProfilesManager } from '@server/lib/transcoding/default-transcoding-profiles.js' +import { isAbleToUploadVideo } from '@server/lib/user.js' +import { VideoPathManager } from '@server/lib/video-path-manager.js' +import { approximateIntroOutroAdditionalSize, onVideoStudioEnded, safeCleanupStudioTMPFiles } from '@server/lib/video-studio.js' +import { UserModel } from '@server/models/user/user.js' +import { VideoModel } from '@server/models/video/video.js' +import { MVideo, MVideoFullLight } from '@server/types/models/index.js' +import { pick } from '@peertube/peertube-core-utils' +import { buildUUID } from '@peertube/peertube-node-utils' +import { FFmpegEdition } from '@peertube/peertube-ffmpeg' import { VideoStudioEditionPayload, VideoStudioTask, @@ -21,8 +21,8 @@ import { VideoStudioTaskOutroPayload, VideoStudioTaskPayload, VideoStudioTaskWatermarkPayload -} from '@shared/models' -import { logger, loggerTagsFactory } from '../../../helpers/logger' +} from '@peertube/peertube-models' +import { logger, loggerTagsFactory } from '../../../helpers/logger.js' const lTagsBase = loggerTagsFactory('video-studio') diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/server/lib/job-queue/handlers/video-transcoding.ts similarity index 94% rename from server/lib/job-queue/handlers/video-transcoding.ts rename to server/server/lib/job-queue/handlers/video-transcoding.ts index 1c8f4fd9f..f46cf9a80 100644 --- a/server/lib/job-queue/handlers/video-transcoding.ts +++ b/server/server/lib/job-queue/handlers/video-transcoding.ts @@ -1,22 +1,22 @@ import { Job } from 'bullmq' -import { onTranscodingEnded } from '@server/lib/transcoding/ended-transcoding' -import { generateHlsPlaylistResolution } from '@server/lib/transcoding/hls-transcoding' -import { mergeAudioVideofile, optimizeOriginalVideofile, transcodeNewWebVideoResolution } from '@server/lib/transcoding/web-transcoding' -import { removeAllWebVideoFiles } from '@server/lib/video-file' -import { VideoPathManager } from '@server/lib/video-path-manager' -import { moveToFailedTranscodingState } from '@server/lib/video-state' -import { UserModel } from '@server/models/user/user' -import { VideoJobInfoModel } from '@server/models/video/video-job-info' -import { MUser, MUserId, MVideoFullLight } from '@server/types/models' +import { onTranscodingEnded } from '@server/lib/transcoding/ended-transcoding.js' +import { generateHlsPlaylistResolution } from '@server/lib/transcoding/hls-transcoding.js' +import { mergeAudioVideofile, optimizeOriginalVideofile, transcodeNewWebVideoResolution } from '@server/lib/transcoding/web-transcoding.js' +import { removeAllWebVideoFiles } from '@server/lib/video-file.js' +import { VideoPathManager } from '@server/lib/video-path-manager.js' +import { moveToFailedTranscodingState } from '@server/lib/video-state.js' +import { UserModel } from '@server/models/user/user.js' +import { VideoJobInfoModel } from '@server/models/video/video-job-info.js' +import { MUser, MUserId, MVideoFullLight } from '@server/types/models/index.js' import { HLSTranscodingPayload, MergeAudioTranscodingPayload, NewWebVideoResolutionTranscodingPayload, OptimizeTranscodingPayload, VideoTranscodingPayload -} from '@shared/models' -import { logger, loggerTagsFactory } from '../../../helpers/logger' -import { VideoModel } from '../../../models/video/video' +} from '@peertube/peertube-models' +import { logger, loggerTagsFactory } from '../../../helpers/logger.js' +import { VideoModel } from '../../../models/video/video.js' type HandlerFunction = (job: Job, payload: VideoTranscodingPayload, video: MVideoFullLight, user: MUser) => Promise diff --git a/server/lib/job-queue/handlers/video-views-stats.ts b/server/server/lib/job-queue/handlers/video-views-stats.ts similarity index 85% rename from server/lib/job-queue/handlers/video-views-stats.ts rename to server/server/lib/job-queue/handlers/video-views-stats.ts index c9aa218e5..479b47ed0 100644 --- a/server/lib/job-queue/handlers/video-views-stats.ts +++ b/server/server/lib/job-queue/handlers/video-views-stats.ts @@ -1,8 +1,8 @@ -import { VideoViewModel } from '@server/models/view/video-view' -import { isTestOrDevInstance } from '../../../helpers/core-utils' -import { logger } from '../../../helpers/logger' -import { VideoModel } from '../../../models/video/video' -import { Redis } from '../../redis' +import { isTestOrDevInstance } from '@peertube/peertube-node-utils' +import { VideoViewModel } from '@server/models/view/video-view.js' +import { logger } from '../../../helpers/logger.js' +import { VideoModel } from '../../../models/video/video.js' +import { Redis } from '../../redis.js' async function processVideosViewsStats () { const lastHour = new Date() diff --git a/server/server/lib/job-queue/index.ts b/server/server/lib/job-queue/index.ts new file mode 100644 index 000000000..098d4e7a3 --- /dev/null +++ b/server/server/lib/job-queue/index.ts @@ -0,0 +1 @@ +export * from './job-queue.js' diff --git a/server/lib/job-queue/job-queue.ts b/server/server/lib/job-queue/job-queue.ts similarity index 93% rename from server/lib/job-queue/job-queue.ts rename to server/server/lib/job-queue/job-queue.ts index 177bca285..390da209e 100644 --- a/server/lib/job-queue/job-queue.ts +++ b/server/server/lib/job-queue/job-queue.ts @@ -10,11 +10,7 @@ import { Worker, WorkerOptions } from 'bullmq' -import { parseDurationToMs } from '@server/helpers/core-utils' -import { jobStates } from '@server/helpers/custom-validators/jobs' -import { CONFIG } from '@server/initializers/config' -import { processVideoRedundancy } from '@server/lib/job-queue/handlers/video-redundancy' -import { pick, timeoutPromise } from '@shared/core-utils' +import { pick, timeoutPromise } from '@peertube/peertube-core-utils' import { ActivitypubFollowPayload, ActivitypubHttpBroadcastPayload, @@ -40,33 +36,40 @@ import { VideoRedundancyPayload, VideoStudioEditionPayload, VideoTranscodingPayload -} from '../../../shared/models' -import { logger } from '../../helpers/logger' -import { JOB_ATTEMPTS, JOB_CONCURRENCY, JOB_REMOVAL_OPTIONS, JOB_TTL, REPEAT_JOBS, WEBSERVER } from '../../initializers/constants' -import { Hooks } from '../plugins/hooks' -import { Redis } from '../redis' -import { processActivityPubCleaner } from './handlers/activitypub-cleaner' -import { processActivityPubFollow } from './handlers/activitypub-follow' -import { processActivityPubHttpSequentialBroadcast, processActivityPubParallelHttpBroadcast } from './handlers/activitypub-http-broadcast' -import { processActivityPubHttpFetcher } from './handlers/activitypub-http-fetcher' -import { processActivityPubHttpUnicast } from './handlers/activitypub-http-unicast' -import { refreshAPObject } from './handlers/activitypub-refresher' -import { processActorKeys } from './handlers/actor-keys' -import { processAfterVideoChannelImport } from './handlers/after-video-channel-import' -import { processEmail } from './handlers/email' -import { processFederateVideo } from './handlers/federate-video' -import { processManageVideoTorrent } from './handlers/manage-video-torrent' -import { onMoveToObjectStorageFailure, processMoveToObjectStorage } from './handlers/move-to-object-storage' -import { processNotify } from './handlers/notify' -import { processTranscodingJobBuilder } from './handlers/transcoding-job-builder' -import { processVideoChannelImport } from './handlers/video-channel-import' -import { processVideoFileImport } from './handlers/video-file-import' -import { processVideoImport } from './handlers/video-import' -import { processVideoLiveEnding } from './handlers/video-live-ending' -import { processVideoStudioEdition } from './handlers/video-studio-edition' -import { processVideoTranscoding } from './handlers/video-transcoding' -import { processVideosViewsStats } from './handlers/video-views-stats' -import { processGenerateStoryboard } from './handlers/generate-storyboard' +} from '@peertube/peertube-models' +import { parseDurationToMs } from '@server/helpers/core-utils.js' +import { jobStates } from '@server/helpers/custom-validators/jobs.js' +import { CONFIG } from '@server/initializers/config.js' +import { processVideoRedundancy } from '@server/lib/job-queue/handlers/video-redundancy.js' +import { logger } from '../../helpers/logger.js' +import { JOB_ATTEMPTS, JOB_CONCURRENCY, JOB_REMOVAL_OPTIONS, JOB_TTL, REPEAT_JOBS, WEBSERVER } from '../../initializers/constants.js' +import { Hooks } from '../plugins/hooks.js' +import { Redis } from '../redis.js' +import { processActivityPubCleaner } from './handlers/activitypub-cleaner.js' +import { processActivityPubFollow } from './handlers/activitypub-follow.js' +import { + processActivityPubHttpSequentialBroadcast, + processActivityPubParallelHttpBroadcast +} from './handlers/activitypub-http-broadcast.js' +import { processActivityPubHttpFetcher } from './handlers/activitypub-http-fetcher.js' +import { processActivityPubHttpUnicast } from './handlers/activitypub-http-unicast.js' +import { refreshAPObject } from './handlers/activitypub-refresher.js' +import { processActorKeys } from './handlers/actor-keys.js' +import { processAfterVideoChannelImport } from './handlers/after-video-channel-import.js' +import { processEmail } from './handlers/email.js' +import { processFederateVideo } from './handlers/federate-video.js' +import { processGenerateStoryboard } from './handlers/generate-storyboard.js' +import { processManageVideoTorrent } from './handlers/manage-video-torrent.js' +import { onMoveToObjectStorageFailure, processMoveToObjectStorage } from './handlers/move-to-object-storage.js' +import { processNotify } from './handlers/notify.js' +import { processTranscodingJobBuilder } from './handlers/transcoding-job-builder.js' +import { processVideoChannelImport } from './handlers/video-channel-import.js' +import { processVideoFileImport } from './handlers/video-file-import.js' +import { processVideoImport } from './handlers/video-import.js' +import { processVideoLiveEnding } from './handlers/video-live-ending.js' +import { processVideoStudioEdition } from './handlers/video-studio-edition.js' +import { processVideoTranscoding } from './handlers/video-transcoding.js' +import { processVideosViewsStats } from './handlers/video-views-stats.js' export type CreateJobArgument = { type: 'activitypub-http-broadcast', payload: ActivitypubHttpBroadcastPayload } | diff --git a/server/server/lib/live/index.ts b/server/server/lib/live/index.ts new file mode 100644 index 000000000..d770aeb4b --- /dev/null +++ b/server/server/lib/live/index.ts @@ -0,0 +1,4 @@ +export * from './live-manager.js' +export * from './live-quota-store.js' +export * from './live-segment-sha-store.js' +export * from './live-utils.js' diff --git a/server/lib/live/live-manager.ts b/server/server/lib/live/live-manager.ts similarity index 91% rename from server/lib/live/live-manager.ts rename to server/server/lib/live/live-manager.ts index acb7af274..d003379c9 100644 --- a/server/lib/live/live-manager.ts +++ b/server/server/lib/live/live-manager.ts @@ -1,35 +1,40 @@ -import { readdir, readFile } from 'fs-extra' +import { readdir, readFile } from 'fs/promises' import { createServer, Server } from 'net' +import context from 'node-media-server/src/node_core_ctx.js' +import nodeMediaServerLogger from 'node-media-server/src/node_core_logger.js' +import NodeRtmpSession from 'node-media-server/src/node_rtmp_session.js' import { join } from 'path' import { createServer as createServerTLS, Server as ServerTLS } from 'tls' -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { CONFIG, registerConfigChangedHandler } from '@server/initializers/config' -import { VIDEO_LIVE, WEBSERVER } from '@server/initializers/constants' -import { sequelizeTypescript } from '@server/initializers/database' -import { RunnerJobModel } from '@server/models/runner/runner-job' -import { UserModel } from '@server/models/user/user' -import { VideoModel } from '@server/models/video/video' -import { VideoLiveModel } from '@server/models/video/video-live' -import { VideoLiveReplaySettingModel } from '@server/models/video/video-live-replay-setting' -import { VideoLiveSessionModel } from '@server/models/video/video-live-session' -import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' -import { MVideo, MVideoLiveSession, MVideoLiveVideo, MVideoLiveVideoWithSetting } from '@server/types/models' -import { pick, wait } from '@shared/core-utils' -import { ffprobePromise, getVideoStreamBitrate, getVideoStreamDimensionsInfo, getVideoStreamFPS, hasAudioStream } from '@shared/ffmpeg' -import { LiveVideoError, VideoState } from '@shared/models' -import { federateVideoIfNeeded } from '../activitypub/videos' -import { JobQueue } from '../job-queue' -import { getLiveReplayBaseDirectory } from '../paths' -import { PeerTubeSocket } from '../peertube-socket' -import { Hooks } from '../plugins/hooks' -import { computeResolutionsToTranscode } from '../transcoding/transcoding-resolutions' -import { LiveQuotaStore } from './live-quota-store' -import { cleanupAndDestroyPermanentLive, getLiveSegmentTime } from './live-utils' -import { MuxingSession } from './shared' - -const NodeRtmpSession = require('node-media-server/src/node_rtmp_session') -const context = require('node-media-server/src/node_core_ctx') -const nodeMediaServerLogger = require('node-media-server/src/node_core_logger') +import { pick, wait } from '@peertube/peertube-core-utils' +import { LiveVideoError, LiveVideoErrorType, VideoState } from '@peertube/peertube-models' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { CONFIG, registerConfigChangedHandler } from '@server/initializers/config.js' +import { VIDEO_LIVE, WEBSERVER } from '@server/initializers/constants.js' +import { sequelizeTypescript } from '@server/initializers/database.js' +import { RunnerJobModel } from '@server/models/runner/runner-job.js' +import { UserModel } from '@server/models/user/user.js' +import { VideoLiveReplaySettingModel } from '@server/models/video/video-live-replay-setting.js' +import { VideoLiveSessionModel } from '@server/models/video/video-live-session.js' +import { VideoLiveModel } from '@server/models/video/video-live.js' +import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist.js' +import { VideoModel } from '@server/models/video/video.js' +import { MVideo, MVideoLiveSession, MVideoLiveVideo, MVideoLiveVideoWithSetting } from '@server/types/models/index.js' +import { + ffprobePromise, + getVideoStreamBitrate, + getVideoStreamDimensionsInfo, + getVideoStreamFPS, + hasAudioStream +} from '@peertube/peertube-ffmpeg' +import { federateVideoIfNeeded } from '../activitypub/videos/index.js' +import { JobQueue } from '../job-queue/index.js' +import { getLiveReplayBaseDirectory } from '../paths.js' +import { PeerTubeSocket } from '../peertube-socket.js' +import { Hooks } from '../plugins/hooks.js' +import { computeResolutionsToTranscode } from '../transcoding/transcoding-resolutions.js' +import { LiveQuotaStore } from './live-quota-store.js' +import { cleanupAndDestroyPermanentLive, getLiveSegmentTime } from './live-utils.js' +import { MuxingSession } from './shared/index.js' // Disable node media server logs nodeMediaServerLogger.setLogType(0) @@ -182,7 +187,7 @@ class LiveManager { return this.getContext().sessions.has(sessionId) } - stopSessionOf (videoUUID: string, error: LiveVideoError | null) { + stopSessionOf (videoUUID: string, error: LiveVideoErrorType | null) { const sessionId = this.videoSessions.get(videoUUID) if (!sessionId) { logger.debug('No live session to stop for video %s', videoUUID, lTags(sessionId, videoUUID)) @@ -530,7 +535,7 @@ class LiveManager { }) } - private async saveEndingSession (videoUUID: string, error: LiveVideoError | null) { + private async saveEndingSession (videoUUID: string, error: LiveVideoErrorType | null) { const liveSession = await VideoLiveSessionModel.findCurrentSessionOf(videoUUID) if (!liveSession) return diff --git a/server/lib/live/live-quota-store.ts b/server/server/lib/live/live-quota-store.ts similarity index 100% rename from server/lib/live/live-quota-store.ts rename to server/server/lib/live/live-quota-store.ts diff --git a/server/lib/live/live-segment-sha-store.ts b/server/server/lib/live/live-segment-sha-store.ts similarity index 88% rename from server/lib/live/live-segment-sha-store.ts rename to server/server/lib/live/live-segment-sha-store.ts index 8253c0274..fbe1b5e29 100644 --- a/server/lib/live/live-segment-sha-store.ts +++ b/server/server/lib/live/live-segment-sha-store.ts @@ -1,11 +1,12 @@ -import { rename, writeJson } from 'fs-extra' +import { writeJson } from 'fs-extra/esm' +import { rename } from 'fs/promises' import PQueue from 'p-queue' import { basename } from 'path' -import { mapToJSON } from '@server/helpers/core-utils' -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { MStreamingPlaylistVideo } from '@server/types/models' -import { buildSha256Segment } from '../hls' -import { storeHLSFileFromPath } from '../object-storage' +import { mapToJSON } from '@server/helpers/core-utils.js' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { MStreamingPlaylistVideo } from '@server/types/models/index.js' +import { buildSha256Segment } from '../hls.js' +import { storeHLSFileFromPath } from '../object-storage/index.js' const lTags = loggerTagsFactory('live') diff --git a/server/lib/live/live-utils.ts b/server/server/lib/live/live-utils.ts similarity index 84% rename from server/lib/live/live-utils.ts rename to server/server/lib/live/live-utils.ts index 3fb3ce1ce..55b7984bf 100644 --- a/server/lib/live/live-utils.ts +++ b/server/server/lib/live/live-utils.ts @@ -1,11 +1,12 @@ -import { pathExists, readdir, remove } from 'fs-extra' +import { pathExists, remove } from 'fs-extra/esm' +import { readdir } from 'fs/promises' import { basename, join } from 'path' -import { logger } from '@server/helpers/logger' -import { VIDEO_LIVE } from '@server/initializers/constants' -import { MStreamingPlaylist, MStreamingPlaylistVideo, MVideo } from '@server/types/models' -import { LiveVideoLatencyMode, VideoStorage } from '@shared/models' -import { listHLSFileKeysOf, removeHLSFileObjectStorageByFullKey, removeHLSObjectStorage } from '../object-storage' -import { getLiveDirectory } from '../paths' +import { LiveVideoLatencyMode, LiveVideoLatencyModeType, VideoStorage } from '@peertube/peertube-models' +import { logger } from '@server/helpers/logger.js' +import { VIDEO_LIVE } from '@server/initializers/constants.js' +import { MStreamingPlaylist, MStreamingPlaylistVideo, MVideo } from '@server/types/models/index.js' +import { listHLSFileKeysOf, removeHLSFileObjectStorageByFullKey, removeHLSObjectStorage } from '../object-storage/index.js' +import { getLiveDirectory } from '../paths.js' function buildConcatenatedName (segmentOrPlaylistPath: string) { const num = basename(segmentOrPlaylistPath).match(/^(\d+)(-|\.)/) @@ -38,7 +39,7 @@ async function cleanupTMPLiveFiles (video: MVideo, streamingPlaylist: MStreaming await cleanupTMPLiveFilesFromFilesystem(video) } -function getLiveSegmentTime (latencyMode: LiveVideoLatencyMode) { +function getLiveSegmentTime (latencyMode: LiveVideoLatencyModeType) { if (latencyMode === LiveVideoLatencyMode.SMALL_LATENCY) { return VIDEO_LIVE.SEGMENT_TIME_SECONDS.SMALL_LATENCY } diff --git a/server/server/lib/live/shared/index.ts b/server/server/lib/live/shared/index.ts new file mode 100644 index 000000000..218eab284 --- /dev/null +++ b/server/server/lib/live/shared/index.ts @@ -0,0 +1 @@ +export * from './muxing-session.js' diff --git a/server/lib/live/shared/muxing-session.ts b/server/server/lib/live/shared/muxing-session.ts similarity index 94% rename from server/lib/live/shared/muxing-session.ts rename to server/server/lib/live/shared/muxing-session.ts index 02691b651..1a71a04d7 100644 --- a/server/lib/live/shared/muxing-session.ts +++ b/server/server/lib/live/shared/muxing-session.ts @@ -1,31 +1,32 @@ -import { mapSeries } from 'bluebird' +import Bluebird from 'bluebird' import { FSWatcher, watch } from 'chokidar' import { EventEmitter } from 'events' -import { appendFile, ensureDir, readFile, stat } from 'fs-extra' +import { ensureDir } from 'fs-extra/esm' +import { appendFile, readFile, stat } from 'fs/promises' +import memoizee from 'memoizee' import PQueue from 'p-queue' import { basename, join } from 'path' -import { computeOutputFPS } from '@server/helpers/ffmpeg' -import { logger, loggerTagsFactory, LoggerTagsFn } from '@server/helpers/logger' -import { CONFIG } from '@server/initializers/config' -import { MEMOIZE_TTL, P2P_MEDIA_LOADER_PEER_VERSION, VIDEO_LIVE } from '@server/initializers/constants' -import { removeHLSFileObjectStorageByPath, storeHLSFileFromContent, storeHLSFileFromPath } from '@server/lib/object-storage' -import { VideoFileModel } from '@server/models/video/video-file' -import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' -import { MStreamingPlaylistVideo, MUserId, MVideoLiveVideo } from '@server/types/models' -import { VideoStorage, VideoStreamingPlaylistType } from '@shared/models' +import { computeOutputFPS } from '@server/helpers/ffmpeg/index.js' +import { logger, loggerTagsFactory, LoggerTagsFn } from '@server/helpers/logger.js' +import { CONFIG } from '@server/initializers/config.js' +import { MEMOIZE_TTL, P2P_MEDIA_LOADER_PEER_VERSION, VIDEO_LIVE } from '@server/initializers/constants.js' +import { removeHLSFileObjectStorageByPath, storeHLSFileFromContent, storeHLSFileFromPath } from '@server/lib/object-storage/index.js' +import { VideoFileModel } from '@server/models/video/video-file.js' +import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist.js' +import { MStreamingPlaylistVideo, MUserId, MVideoLiveVideo } from '@server/types/models/index.js' +import { VideoStorage, VideoStreamingPlaylistType } from '@peertube/peertube-models' import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename, getLiveDirectory, getLiveReplayBaseDirectory -} from '../../paths' -import { isAbleToUploadVideo } from '../../user' -import { LiveQuotaStore } from '../live-quota-store' -import { LiveSegmentShaStore } from '../live-segment-sha-store' -import { buildConcatenatedName, getLiveSegmentTime } from '../live-utils' -import { AbstractTranscodingWrapper, FFmpegTranscodingWrapper, RemoteTranscodingWrapper } from './transcoding-wrapper' +} from '../../paths.js' +import { isAbleToUploadVideo } from '../../user.js' +import { LiveQuotaStore } from '../live-quota-store.js' +import { LiveSegmentShaStore } from '../live-segment-sha-store.js' +import { buildConcatenatedName, getLiveSegmentTime } from '../live-utils.js' +import { AbstractTranscodingWrapper, FFmpegTranscodingWrapper, RemoteTranscodingWrapper } from './transcoding-wrapper/index.js' -import memoizee = require('memoizee') interface MuxingSessionEvents { 'live-ready': (options: { videoUUID: string }) => void @@ -318,7 +319,7 @@ class MuxingSession extends EventEmitter { } private processSegments (segmentPaths: string[]) { - mapSeries(segmentPaths, previousSegment => this.processSegment(previousSegment)) + Bluebird.mapSeries(segmentPaths, previousSegment => this.processSegment(previousSegment)) .catch(err => { if (this.aborted) return diff --git a/server/lib/live/shared/transcoding-wrapper/abstract-transcoding-wrapper.ts b/server/server/lib/live/shared/transcoding-wrapper/abstract-transcoding-wrapper.ts similarity index 90% rename from server/lib/live/shared/transcoding-wrapper/abstract-transcoding-wrapper.ts rename to server/server/lib/live/shared/transcoding-wrapper/abstract-transcoding-wrapper.ts index 95168745d..8cae0c45b 100644 --- a/server/lib/live/shared/transcoding-wrapper/abstract-transcoding-wrapper.ts +++ b/server/server/lib/live/shared/transcoding-wrapper/abstract-transcoding-wrapper.ts @@ -1,7 +1,7 @@ +import { LiveVideoErrorType } from '@peertube/peertube-models' +import { LoggerTagsFn } from '@server/helpers/logger.js' +import { MStreamingPlaylistVideo, MVideoLiveVideo } from '@server/types/models/index.js' import EventEmitter from 'events' -import { LoggerTagsFn } from '@server/helpers/logger' -import { MStreamingPlaylistVideo, MVideoLiveVideo } from '@server/types/models' -import { LiveVideoError } from '@shared/models' interface TranscodingWrapperEvents { 'end': () => void @@ -101,10 +101,11 @@ abstract class AbstractTranscodingWrapper extends EventEmitter { abstract run (): Promise - abstract abort (error?: LiveVideoError): void + abstract abort (error?: LiveVideoErrorType): void } export { - AbstractTranscodingWrapper, - AbstractTranscodingWrapperOptions + type AbstractTranscodingWrapperOptions, + + AbstractTranscodingWrapper } diff --git a/server/lib/live/shared/transcoding-wrapper/ffmpeg-transcoding-wrapper.ts b/server/server/lib/live/shared/transcoding-wrapper/ffmpeg-transcoding-wrapper.ts similarity index 89% rename from server/lib/live/shared/transcoding-wrapper/ffmpeg-transcoding-wrapper.ts rename to server/server/lib/live/shared/transcoding-wrapper/ffmpeg-transcoding-wrapper.ts index c6ee8ebf1..464686470 100644 --- a/server/lib/live/shared/transcoding-wrapper/ffmpeg-transcoding-wrapper.ts +++ b/server/server/lib/live/shared/transcoding-wrapper/ffmpeg-transcoding-wrapper.ts @@ -1,12 +1,12 @@ import { FfmpegCommand } from 'fluent-ffmpeg' -import { getFFmpegCommandWrapperOptions } from '@server/helpers/ffmpeg' -import { logger } from '@server/helpers/logger' -import { CONFIG } from '@server/initializers/config' -import { VIDEO_LIVE } from '@server/initializers/constants' -import { VideoTranscodingProfilesManager } from '@server/lib/transcoding/default-transcoding-profiles' -import { FFmpegLive } from '@shared/ffmpeg' -import { getLiveSegmentTime } from '../../live-utils' -import { AbstractTranscodingWrapper } from './abstract-transcoding-wrapper' +import { getFFmpegCommandWrapperOptions } from '@server/helpers/ffmpeg/index.js' +import { logger } from '@server/helpers/logger.js' +import { CONFIG } from '@server/initializers/config.js' +import { VIDEO_LIVE } from '@server/initializers/constants.js' +import { VideoTranscodingProfilesManager } from '@server/lib/transcoding/default-transcoding-profiles.js' +import { FFmpegLive } from '@peertube/peertube-ffmpeg' +import { getLiveSegmentTime } from '../../live-utils.js' +import { AbstractTranscodingWrapper } from './abstract-transcoding-wrapper.js' export class FFmpegTranscodingWrapper extends AbstractTranscodingWrapper { private ffmpegCommand: FfmpegCommand diff --git a/server/server/lib/live/shared/transcoding-wrapper/index.ts b/server/server/lib/live/shared/transcoding-wrapper/index.ts new file mode 100644 index 000000000..3ab9f9417 --- /dev/null +++ b/server/server/lib/live/shared/transcoding-wrapper/index.ts @@ -0,0 +1,3 @@ +export * from './abstract-transcoding-wrapper.js' +export * from './ffmpeg-transcoding-wrapper.js' +export * from './remote-transcoding-wrapper.js' diff --git a/server/lib/live/shared/transcoding-wrapper/remote-transcoding-wrapper.ts b/server/server/lib/live/shared/transcoding-wrapper/remote-transcoding-wrapper.ts similarity index 95% rename from server/lib/live/shared/transcoding-wrapper/remote-transcoding-wrapper.ts rename to server/server/lib/live/shared/transcoding-wrapper/remote-transcoding-wrapper.ts index 2aeeb31fb..4e375a749 100644 --- a/server/lib/live/shared/transcoding-wrapper/remote-transcoding-wrapper.ts +++ b/server/server/lib/live/shared/transcoding-wrapper/remote-transcoding-wrapper.ts @@ -1,5 +1,5 @@ -import { LiveRTMPHLSTranscodingJobHandler } from '@server/lib/runners' -import { AbstractTranscodingWrapper } from './abstract-transcoding-wrapper' +import { LiveRTMPHLSTranscodingJobHandler } from '@server/lib/runners/index.js' +import { AbstractTranscodingWrapper } from './abstract-transcoding-wrapper.js' export class RemoteTranscodingWrapper extends AbstractTranscodingWrapper { async run () { diff --git a/server/lib/local-actor.ts b/server/server/lib/local-actor.ts similarity index 80% rename from server/lib/local-actor.ts rename to server/server/lib/local-actor.ts index 611e6d0af..5ee9df875 100644 --- a/server/lib/local-actor.ts +++ b/server/server/lib/local-actor.ts @@ -1,18 +1,17 @@ -import { remove } from 'fs-extra' +import { remove } from 'fs-extra/esm' import { join } from 'path' -import { Transaction } from 'sequelize/types' -import { ActorModel } from '@server/models/actor/actor' -import { getLowercaseExtension } from '@shared/core-utils' -import { buildUUID } from '@shared/extra-utils' -import { ActivityPubActorType, ActorImageType } from '@shared/models' -import { retryTransactionWrapper } from '../helpers/database-utils' -import { CONFIG } from '../initializers/config' -import { ACTOR_IMAGES_SIZE, WEBSERVER } from '../initializers/constants' -import { sequelizeTypescript } from '../initializers/database' -import { MAccountDefault, MActor, MChannelDefault } from '../types/models' -import { deleteActorImages, updateActorImages } from './activitypub/actors' -import { sendUpdateActor } from './activitypub/send' -import { processImageFromWorker } from './worker/parent-process' +import { Transaction } from 'sequelize' +import { ActivityPubActorType, ActorImageType, ActorImageType_Type } from '@peertube/peertube-models' +import { ActorModel } from '@server/models/actor/actor.js' +import { buildUUID, getLowercaseExtension } from '@peertube/peertube-node-utils' +import { retryTransactionWrapper } from '../helpers/database-utils.js' +import { CONFIG } from '../initializers/config.js' +import { ACTOR_IMAGES_SIZE, WEBSERVER } from '../initializers/constants.js' +import { sequelizeTypescript } from '../initializers/database.js' +import { MAccountDefault, MActor, MChannelDefault } from '../types/models/index.js' +import { deleteActorImages, updateActorImages } from './activitypub/actors/index.js' +import { sendUpdateActor } from './activitypub/send/index.js' +import { processImageFromWorker } from './worker/parent-process.js' export function buildActorInstance (type: ActivityPubActorType, url: string, preferredUsername: string) { return new ActorModel({ @@ -34,7 +33,7 @@ export function buildActorInstance (type: ActivityPubActorType, url: string, pre export async function updateLocalActorImageFiles ( accountOrChannel: MAccountDefault | MChannelDefault, imagePhysicalFile: Express.Multer.File, - type: ActorImageType + type: ActorImageType_Type ) { const processImageSize = async (imageSize: { width: number, height: number }) => { const extension = getLowercaseExtension(imagePhysicalFile.filename) @@ -72,7 +71,7 @@ export async function updateLocalActorImageFiles ( })) } -export async function deleteLocalActorImageFile (accountOrChannel: MAccountDefault | MChannelDefault, type: ActorImageType) { +export async function deleteLocalActorImageFile (accountOrChannel: MAccountDefault | MChannelDefault, type: ActorImageType_Type) { return retryTransactionWrapper(() => { return sequelizeTypescript.transaction(async t => { const updatedActor = await deleteActorImages(accountOrChannel.Actor, type, t) diff --git a/server/lib/model-loaders/actor.ts b/server/server/lib/model-loaders/actor.ts similarity index 80% rename from server/lib/model-loaders/actor.ts rename to server/server/lib/model-loaders/actor.ts index 1355d8ee2..3c1179391 100644 --- a/server/lib/model-loaders/actor.ts +++ b/server/server/lib/model-loaders/actor.ts @@ -1,6 +1,5 @@ - -import { ActorModel } from '../../models/actor/actor' -import { MActorAccountChannelId, MActorFull } from '../../types/models' +import { ActorModel } from '../../models/actor/actor.js' +import { MActorAccountChannelId, MActorFull } from '../../types/models/index.js' type ActorLoadByUrlType = 'all' | 'association-ids' @@ -11,7 +10,7 @@ function loadActorByUrl (url: string, fetchType: ActorLoadByUrlType): Promise { diff --git a/server/server/lib/notifier/shared/abuse/index.ts b/server/server/lib/notifier/shared/abuse/index.ts new file mode 100644 index 000000000..4f4b30503 --- /dev/null +++ b/server/server/lib/notifier/shared/abuse/index.ts @@ -0,0 +1,4 @@ +export * from './abuse-state-change-for-reporter.js' +export * from './new-abuse-for-moderators.js' +export * from './new-abuse-message-for-reporter.js' +export * from './new-abuse-message-for-moderators.js' diff --git a/server/lib/notifier/shared/abuse/new-abuse-for-moderators.ts b/server/server/lib/notifier/shared/abuse/new-abuse-for-moderators.ts similarity index 90% rename from server/lib/notifier/shared/abuse/new-abuse-for-moderators.ts rename to server/server/lib/notifier/shared/abuse/new-abuse-for-moderators.ts index 7d86fb55f..2bd93133d 100644 --- a/server/lib/notifier/shared/abuse/new-abuse-for-moderators.ts +++ b/server/server/lib/notifier/shared/abuse/new-abuse-for-moderators.ts @@ -1,11 +1,11 @@ -import { logger } from '@server/helpers/logger' -import { WEBSERVER } from '@server/initializers/constants' -import { getAbuseTargetUrl } from '@server/lib/activitypub/url' -import { UserModel } from '@server/models/user/user' -import { UserNotificationModel } from '@server/models/user/user-notification' -import { MAbuseFull, MUserDefault, MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/types/models' -import { UserAbuse, UserNotificationType, UserRight } from '@shared/models' -import { AbstractNotification } from '../common/abstract-notification' +import { logger } from '@server/helpers/logger.js' +import { WEBSERVER } from '@server/initializers/constants.js' +import { getAbuseTargetUrl } from '@server/lib/activitypub/url.js' +import { UserModel } from '@server/models/user/user.js' +import { UserNotificationModel } from '@server/models/user/user-notification.js' +import { MAbuseFull, MUserDefault, MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/types/models/index.js' +import { UserAbuse, UserNotificationType, UserRight } from '@peertube/peertube-models' +import { AbstractNotification } from '../common/abstract-notification.js' export type NewAbusePayload = { abuse: UserAbuse, abuseInstance: MAbuseFull, reporter: string } diff --git a/server/lib/notifier/shared/abuse/new-abuse-message-for-moderators.ts b/server/server/lib/notifier/shared/abuse/new-abuse-message-for-moderators.ts similarity index 71% rename from server/lib/notifier/shared/abuse/new-abuse-message-for-moderators.ts rename to server/server/lib/notifier/shared/abuse/new-abuse-message-for-moderators.ts index 9d0629690..d3f590e46 100644 --- a/server/lib/notifier/shared/abuse/new-abuse-message-for-moderators.ts +++ b/server/server/lib/notifier/shared/abuse/new-abuse-message-for-moderators.ts @@ -1,9 +1,9 @@ -import { logger } from '@server/helpers/logger' -import { getAbuseTargetUrl } from '@server/lib/activitypub/url' -import { UserModel } from '@server/models/user/user' -import { MUserDefault } from '@server/types/models' -import { UserRight } from '@shared/models' -import { AbstractNewAbuseMessage } from './abstract-new-abuse-message' +import { logger } from '@server/helpers/logger.js' +import { getAbuseTargetUrl } from '@server/lib/activitypub/url.js' +import { UserModel } from '@server/models/user/user.js' +import { MUserDefault } from '@server/types/models/index.js' +import { UserRight } from '@peertube/peertube-models' +import { AbstractNewAbuseMessage } from './abstract-new-abuse-message.js' export class NewAbuseMessageForModerators extends AbstractNewAbuseMessage { private moderators: MUserDefault[] diff --git a/server/lib/notifier/shared/abuse/new-abuse-message-for-reporter.ts b/server/server/lib/notifier/shared/abuse/new-abuse-message-for-reporter.ts similarity index 77% rename from server/lib/notifier/shared/abuse/new-abuse-message-for-reporter.ts rename to server/server/lib/notifier/shared/abuse/new-abuse-message-for-reporter.ts index c5bbb5447..d0ec709fe 100644 --- a/server/lib/notifier/shared/abuse/new-abuse-message-for-reporter.ts +++ b/server/server/lib/notifier/shared/abuse/new-abuse-message-for-reporter.ts @@ -1,8 +1,8 @@ -import { logger } from '@server/helpers/logger' -import { getAbuseTargetUrl } from '@server/lib/activitypub/url' -import { UserModel } from '@server/models/user/user' -import { MUserDefault } from '@server/types/models' -import { AbstractNewAbuseMessage } from './abstract-new-abuse-message' +import { logger } from '@server/helpers/logger.js' +import { getAbuseTargetUrl } from '@server/lib/activitypub/url.js' +import { UserModel } from '@server/models/user/user.js' +import { MUserDefault } from '@server/types/models/index.js' +import { AbstractNewAbuseMessage } from './abstract-new-abuse-message.js' export class NewAbuseMessageForReporter extends AbstractNewAbuseMessage { private reporter: MUserDefault diff --git a/server/server/lib/notifier/shared/blacklist/index.ts b/server/server/lib/notifier/shared/blacklist/index.ts new file mode 100644 index 000000000..9af153b5a --- /dev/null +++ b/server/server/lib/notifier/shared/blacklist/index.ts @@ -0,0 +1,3 @@ +export * from './new-auto-blacklist-for-moderators.js' +export * from './new-blacklist-for-owner.js' +export * from './unblacklist-for-owner.js' diff --git a/server/lib/notifier/shared/blacklist/new-auto-blacklist-for-moderators.ts b/server/server/lib/notifier/shared/blacklist/new-auto-blacklist-for-moderators.ts similarity index 80% rename from server/lib/notifier/shared/blacklist/new-auto-blacklist-for-moderators.ts rename to server/server/lib/notifier/shared/blacklist/new-auto-blacklist-for-moderators.ts index ad2cc00ea..3389bcd67 100644 --- a/server/lib/notifier/shared/blacklist/new-auto-blacklist-for-moderators.ts +++ b/server/server/lib/notifier/shared/blacklist/new-auto-blacklist-for-moderators.ts @@ -1,11 +1,16 @@ -import { logger } from '@server/helpers/logger' -import { WEBSERVER } from '@server/initializers/constants' -import { UserModel } from '@server/models/user/user' -import { UserNotificationModel } from '@server/models/user/user-notification' -import { VideoChannelModel } from '@server/models/video/video-channel' -import { MUserDefault, MUserWithNotificationSetting, MVideoBlacklistLightVideo, UserNotificationModelForApi } from '@server/types/models' -import { UserNotificationType, UserRight } from '@shared/models' -import { AbstractNotification } from '../common/abstract-notification' +import { UserNotificationType, UserRight } from '@peertube/peertube-models' +import { logger } from '@server/helpers/logger.js' +import { WEBSERVER } from '@server/initializers/constants.js' +import { UserNotificationModel } from '@server/models/user/user-notification.js' +import { UserModel } from '@server/models/user/user.js' +import { VideoChannelModel } from '@server/models/video/video-channel.js' +import { + MUserDefault, + MUserWithNotificationSetting, + MVideoBlacklistLightVideo, + UserNotificationModelForApi +} from '@server/types/models/index.js' +import { AbstractNotification } from '../common/abstract-notification.js' export class NewAutoBlacklistForModerators extends AbstractNotification { private moderators: MUserDefault[] diff --git a/server/lib/notifier/shared/blacklist/new-blacklist-for-owner.ts b/server/server/lib/notifier/shared/blacklist/new-blacklist-for-owner.ts similarity index 77% rename from server/lib/notifier/shared/blacklist/new-blacklist-for-owner.ts rename to server/server/lib/notifier/shared/blacklist/new-blacklist-for-owner.ts index 342b69ec7..2ce8b1327 100644 --- a/server/lib/notifier/shared/blacklist/new-blacklist-for-owner.ts +++ b/server/server/lib/notifier/shared/blacklist/new-blacklist-for-owner.ts @@ -1,11 +1,16 @@ -import { logger } from '@server/helpers/logger' -import { CONFIG } from '@server/initializers/config' -import { WEBSERVER } from '@server/initializers/constants' -import { UserModel } from '@server/models/user/user' -import { UserNotificationModel } from '@server/models/user/user-notification' -import { MUserDefault, MUserWithNotificationSetting, MVideoBlacklistVideo, UserNotificationModelForApi } from '@server/types/models' -import { UserNotificationType } from '@shared/models' -import { AbstractNotification } from '../common/abstract-notification' +import { UserNotificationType } from '@peertube/peertube-models' +import { logger } from '@server/helpers/logger.js' +import { CONFIG } from '@server/initializers/config.js' +import { WEBSERVER } from '@server/initializers/constants.js' +import { UserNotificationModel } from '@server/models/user/user-notification.js' +import { UserModel } from '@server/models/user/user.js' +import { + MUserDefault, + MUserWithNotificationSetting, + MVideoBlacklistVideo, + UserNotificationModelForApi +} from '@server/types/models/index.js' +import { AbstractNotification } from '../common/abstract-notification.js' export class NewBlacklistForOwner extends AbstractNotification { private user: MUserDefault diff --git a/server/lib/notifier/shared/blacklist/unblacklist-for-owner.ts b/server/server/lib/notifier/shared/blacklist/unblacklist-for-owner.ts similarity index 78% rename from server/lib/notifier/shared/blacklist/unblacklist-for-owner.ts rename to server/server/lib/notifier/shared/blacklist/unblacklist-for-owner.ts index e6f90e23c..66a6d1263 100644 --- a/server/lib/notifier/shared/blacklist/unblacklist-for-owner.ts +++ b/server/server/lib/notifier/shared/blacklist/unblacklist-for-owner.ts @@ -1,11 +1,11 @@ -import { logger } from '@server/helpers/logger' -import { CONFIG } from '@server/initializers/config' -import { WEBSERVER } from '@server/initializers/constants' -import { UserModel } from '@server/models/user/user' -import { UserNotificationModel } from '@server/models/user/user-notification' -import { MUserDefault, MUserWithNotificationSetting, MVideoFullLight, UserNotificationModelForApi } from '@server/types/models' -import { UserNotificationType } from '@shared/models' -import { AbstractNotification } from '../common/abstract-notification' +import { logger } from '@server/helpers/logger.js' +import { CONFIG } from '@server/initializers/config.js' +import { WEBSERVER } from '@server/initializers/constants.js' +import { UserModel } from '@server/models/user/user.js' +import { UserNotificationModel } from '@server/models/user/user-notification.js' +import { MUserDefault, MUserWithNotificationSetting, MVideoFullLight, UserNotificationModelForApi } from '@server/types/models/index.js' +import { UserNotificationType } from '@peertube/peertube-models' +import { AbstractNotification } from '../common/abstract-notification.js' export class UnblacklistForOwner extends AbstractNotification { private user: MUserDefault diff --git a/server/lib/notifier/shared/comment/comment-mention.ts b/server/server/lib/notifier/shared/comment/comment-mention.ts similarity index 89% rename from server/lib/notifier/shared/comment/comment-mention.ts rename to server/server/lib/notifier/shared/comment/comment-mention.ts index 3074e97db..e6bba1eee 100644 --- a/server/lib/notifier/shared/comment/comment-mention.ts +++ b/server/server/lib/notifier/shared/comment/comment-mention.ts @@ -1,20 +1,20 @@ -import { logger } from '@server/helpers/logger' -import { toSafeHtml } from '@server/helpers/markdown' -import { WEBSERVER } from '@server/initializers/constants' -import { AccountBlocklistModel } from '@server/models/account/account-blocklist' -import { getServerActor } from '@server/models/application/application' -import { ServerBlocklistModel } from '@server/models/server/server-blocklist' -import { UserModel } from '@server/models/user/user' -import { UserNotificationModel } from '@server/models/user/user-notification' +import { logger } from '@server/helpers/logger.js' +import { toSafeHtml } from '@server/helpers/markdown.js' +import { WEBSERVER } from '@server/initializers/constants.js' +import { AccountBlocklistModel } from '@server/models/account/account-blocklist.js' +import { getServerActor } from '@server/models/application/application.js' +import { ServerBlocklistModel } from '@server/models/server/server-blocklist.js' +import { UserNotificationModel } from '@server/models/user/user-notification.js' +import { UserModel } from '@server/models/user/user.js' import { MCommentOwnerVideo, MUserDefault, MUserNotifSettingAccount, MUserWithNotificationSetting, UserNotificationModelForApi -} from '@server/types/models' -import { UserNotificationSettingValue, UserNotificationType } from '@shared/models' -import { AbstractNotification } from '../common' +} from '@server/types/models/index.js' +import { UserNotificationSettingValue, UserNotificationType } from '@peertube/peertube-models' +import { AbstractNotification } from '../common/index.js' export class CommentMention extends AbstractNotification { private users: MUserDefault[] diff --git a/server/server/lib/notifier/shared/comment/index.ts b/server/server/lib/notifier/shared/comment/index.ts new file mode 100644 index 000000000..cbb93ebd3 --- /dev/null +++ b/server/server/lib/notifier/shared/comment/index.ts @@ -0,0 +1,2 @@ +export * from './comment-mention.js' +export * from './new-comment-for-video-owner.js' diff --git a/server/lib/notifier/shared/comment/new-comment-for-video-owner.ts b/server/server/lib/notifier/shared/comment/new-comment-for-video-owner.ts similarity index 86% rename from server/lib/notifier/shared/comment/new-comment-for-video-owner.ts rename to server/server/lib/notifier/shared/comment/new-comment-for-video-owner.ts index 4f96439a3..eddb162f3 100644 --- a/server/lib/notifier/shared/comment/new-comment-for-video-owner.ts +++ b/server/server/lib/notifier/shared/comment/new-comment-for-video-owner.ts @@ -1,12 +1,12 @@ -import { logger } from '@server/helpers/logger' -import { toSafeHtml } from '@server/helpers/markdown' -import { WEBSERVER } from '@server/initializers/constants' -import { isBlockedByServerOrAccount } from '@server/lib/blocklist' -import { UserModel } from '@server/models/user/user' -import { UserNotificationModel } from '@server/models/user/user-notification' -import { MCommentOwnerVideo, MUserDefault, MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/types/models' -import { UserNotificationType } from '@shared/models' -import { AbstractNotification } from '../common/abstract-notification' +import { logger } from '@server/helpers/logger.js' +import { toSafeHtml } from '@server/helpers/markdown.js' +import { WEBSERVER } from '@server/initializers/constants.js' +import { isBlockedByServerOrAccount } from '@server/lib/blocklist.js' +import { UserModel } from '@server/models/user/user.js' +import { UserNotificationModel } from '@server/models/user/user-notification.js' +import { MCommentOwnerVideo, MUserDefault, MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/types/models/index.js' +import { UserNotificationType } from '@peertube/peertube-models' +import { AbstractNotification } from '../common/abstract-notification.js' export class NewCommentForVideoOwner extends AbstractNotification { private user: MUserDefault diff --git a/server/lib/notifier/shared/common/abstract-notification.ts b/server/server/lib/notifier/shared/common/abstract-notification.ts similarity index 72% rename from server/lib/notifier/shared/common/abstract-notification.ts rename to server/server/lib/notifier/shared/common/abstract-notification.ts index 79403611e..c8b385c6d 100644 --- a/server/lib/notifier/shared/common/abstract-notification.ts +++ b/server/server/lib/notifier/shared/common/abstract-notification.ts @@ -1,5 +1,5 @@ -import { MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/types/models' -import { EmailPayload, UserNotificationSettingValue } from '@shared/models' +import { EmailPayload, UserNotificationSettingValueType } from '@peertube/peertube-models' +import { MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/types/models/index.js' export abstract class AbstractNotification { @@ -10,7 +10,7 @@ export abstract class AbstractNotification abstract prepare (): Promise abstract log (): void - abstract getSetting (user: U): UserNotificationSettingValue + abstract getSetting (user: U): UserNotificationSettingValueType abstract getTargetUsers (): U[] abstract createNotification (user: U): UserNotificationModelForApi diff --git a/server/server/lib/notifier/shared/common/index.ts b/server/server/lib/notifier/shared/common/index.ts new file mode 100644 index 000000000..322a35120 --- /dev/null +++ b/server/server/lib/notifier/shared/common/index.ts @@ -0,0 +1 @@ +export * from './abstract-notification.js' diff --git a/server/lib/notifier/shared/follow/auto-follow-for-instance.ts b/server/server/lib/notifier/shared/follow/auto-follow-for-instance.ts similarity index 83% rename from server/lib/notifier/shared/follow/auto-follow-for-instance.ts rename to server/server/lib/notifier/shared/follow/auto-follow-for-instance.ts index ab9747ba8..027bf8eef 100644 --- a/server/lib/notifier/shared/follow/auto-follow-for-instance.ts +++ b/server/server/lib/notifier/shared/follow/auto-follow-for-instance.ts @@ -1,9 +1,9 @@ -import { logger } from '@server/helpers/logger' -import { UserModel } from '@server/models/user/user' -import { UserNotificationModel } from '@server/models/user/user-notification' -import { MActorFollowFull, MUserDefault, MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/types/models' -import { UserNotificationType, UserRight } from '@shared/models' -import { AbstractNotification } from '../common/abstract-notification' +import { logger } from '@server/helpers/logger.js' +import { UserModel } from '@server/models/user/user.js' +import { UserNotificationModel } from '@server/models/user/user-notification.js' +import { MActorFollowFull, MUserDefault, MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/types/models/index.js' +import { UserNotificationType, UserRight } from '@peertube/peertube-models' +import { AbstractNotification } from '../common/abstract-notification.js' export class AutoFollowForInstance extends AbstractNotification { private admins: MUserDefault[] diff --git a/server/lib/notifier/shared/follow/follow-for-instance.ts b/server/server/lib/notifier/shared/follow/follow-for-instance.ts similarity index 84% rename from server/lib/notifier/shared/follow/follow-for-instance.ts rename to server/server/lib/notifier/shared/follow/follow-for-instance.ts index 777a12ef4..76fa0332a 100644 --- a/server/lib/notifier/shared/follow/follow-for-instance.ts +++ b/server/server/lib/notifier/shared/follow/follow-for-instance.ts @@ -1,11 +1,11 @@ -import { logger } from '@server/helpers/logger' -import { WEBSERVER } from '@server/initializers/constants' -import { isBlockedByServerOrAccount } from '@server/lib/blocklist' -import { UserModel } from '@server/models/user/user' -import { UserNotificationModel } from '@server/models/user/user-notification' -import { MActorFollowFull, MUserDefault, MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/types/models' -import { UserNotificationType, UserRight } from '@shared/models' -import { AbstractNotification } from '../common/abstract-notification' +import { logger } from '@server/helpers/logger.js' +import { WEBSERVER } from '@server/initializers/constants.js' +import { isBlockedByServerOrAccount } from '@server/lib/blocklist.js' +import { UserModel } from '@server/models/user/user.js' +import { UserNotificationModel } from '@server/models/user/user-notification.js' +import { MActorFollowFull, MUserDefault, MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/types/models/index.js' +import { UserNotificationType, UserRight } from '@peertube/peertube-models' +import { AbstractNotification } from '../common/abstract-notification.js' export class FollowForInstance extends AbstractNotification { private admins: MUserDefault[] diff --git a/server/lib/notifier/shared/follow/follow-for-user.ts b/server/server/lib/notifier/shared/follow/follow-for-user.ts similarity index 89% rename from server/lib/notifier/shared/follow/follow-for-user.ts rename to server/server/lib/notifier/shared/follow/follow-for-user.ts index 697c82cdd..bf915dfeb 100644 --- a/server/lib/notifier/shared/follow/follow-for-user.ts +++ b/server/server/lib/notifier/shared/follow/follow-for-user.ts @@ -1,10 +1,10 @@ -import { logger } from '@server/helpers/logger' -import { isBlockedByServerOrAccount } from '@server/lib/blocklist' -import { UserModel } from '@server/models/user/user' -import { UserNotificationModel } from '@server/models/user/user-notification' -import { MActorFollowFull, MUserDefault, MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/types/models' -import { UserNotificationType } from '@shared/models' -import { AbstractNotification } from '../common/abstract-notification' +import { logger } from '@server/helpers/logger.js' +import { isBlockedByServerOrAccount } from '@server/lib/blocklist.js' +import { UserModel } from '@server/models/user/user.js' +import { UserNotificationModel } from '@server/models/user/user-notification.js' +import { MActorFollowFull, MUserDefault, MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/types/models/index.js' +import { UserNotificationType } from '@peertube/peertube-models' +import { AbstractNotification } from '../common/abstract-notification.js' export class FollowForUser extends AbstractNotification { private followType: 'account' | 'channel' diff --git a/server/server/lib/notifier/shared/follow/index.ts b/server/server/lib/notifier/shared/follow/index.ts new file mode 100644 index 000000000..5fe27e4c9 --- /dev/null +++ b/server/server/lib/notifier/shared/follow/index.ts @@ -0,0 +1,3 @@ +export * from './auto-follow-for-instance.js' +export * from './follow-for-instance.js' +export * from './follow-for-user.js' diff --git a/server/server/lib/notifier/shared/index.ts b/server/server/lib/notifier/shared/index.ts new file mode 100644 index 000000000..f4f165c40 --- /dev/null +++ b/server/server/lib/notifier/shared/index.ts @@ -0,0 +1,7 @@ +export * from './abuse/index.js' +export * from './blacklist/index.js' +export * from './comment/index.js' +export * from './common/index.js' +export * from './follow/index.js' +export * from './instance/index.js' +export * from './video-publication/index.js' diff --git a/server/lib/notifier/shared/instance/direct-registration-for-moderators.ts b/server/server/lib/notifier/shared/instance/direct-registration-for-moderators.ts similarity index 80% rename from server/lib/notifier/shared/instance/direct-registration-for-moderators.ts rename to server/server/lib/notifier/shared/instance/direct-registration-for-moderators.ts index 5044f2068..42078ba24 100644 --- a/server/lib/notifier/shared/instance/direct-registration-for-moderators.ts +++ b/server/server/lib/notifier/shared/instance/direct-registration-for-moderators.ts @@ -1,10 +1,10 @@ -import { logger } from '@server/helpers/logger' -import { CONFIG } from '@server/initializers/config' -import { UserModel } from '@server/models/user/user' -import { UserNotificationModel } from '@server/models/user/user-notification' -import { MUserDefault, MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/types/models' -import { UserNotificationType, UserRight } from '@shared/models' -import { AbstractNotification } from '../common/abstract-notification' +import { logger } from '@server/helpers/logger.js' +import { CONFIG } from '@server/initializers/config.js' +import { UserModel } from '@server/models/user/user.js' +import { UserNotificationModel } from '@server/models/user/user-notification.js' +import { MUserDefault, MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/types/models/index.js' +import { UserNotificationType, UserRight } from '@peertube/peertube-models' +import { AbstractNotification } from '../common/abstract-notification.js' export class DirectRegistrationForModerators extends AbstractNotification { private moderators: MUserDefault[] diff --git a/server/server/lib/notifier/shared/instance/index.ts b/server/server/lib/notifier/shared/instance/index.ts new file mode 100644 index 000000000..c922fcbe9 --- /dev/null +++ b/server/server/lib/notifier/shared/instance/index.ts @@ -0,0 +1,4 @@ +export * from './new-peertube-version-for-admins.js' +export * from './new-plugin-version-for-admins.js' +export * from './direct-registration-for-moderators.js' +export * from './registration-request-for-moderators.js' diff --git a/server/lib/notifier/shared/instance/new-peertube-version-for-admins.ts b/server/server/lib/notifier/shared/instance/new-peertube-version-for-admins.ts similarity index 84% rename from server/lib/notifier/shared/instance/new-peertube-version-for-admins.ts rename to server/server/lib/notifier/shared/instance/new-peertube-version-for-admins.ts index f5646c666..ff9b248e5 100644 --- a/server/lib/notifier/shared/instance/new-peertube-version-for-admins.ts +++ b/server/server/lib/notifier/shared/instance/new-peertube-version-for-admins.ts @@ -1,9 +1,9 @@ -import { logger } from '@server/helpers/logger' -import { UserModel } from '@server/models/user/user' -import { UserNotificationModel } from '@server/models/user/user-notification' -import { MApplication, MUserDefault, MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/types/models' -import { UserNotificationType, UserRight } from '@shared/models' -import { AbstractNotification } from '../common/abstract-notification' +import { logger } from '@server/helpers/logger.js' +import { UserModel } from '@server/models/user/user.js' +import { UserNotificationModel } from '@server/models/user/user-notification.js' +import { MApplication, MUserDefault, MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/types/models/index.js' +import { UserNotificationType, UserRight } from '@peertube/peertube-models' +import { AbstractNotification } from '../common/abstract-notification.js' export type NewPeerTubeVersionForAdminsPayload = { application: MApplication diff --git a/server/lib/notifier/shared/instance/new-plugin-version-for-admins.ts b/server/server/lib/notifier/shared/instance/new-plugin-version-for-admins.ts similarity index 82% rename from server/lib/notifier/shared/instance/new-plugin-version-for-admins.ts rename to server/server/lib/notifier/shared/instance/new-plugin-version-for-admins.ts index 547c6726c..4a9de9a0b 100644 --- a/server/lib/notifier/shared/instance/new-plugin-version-for-admins.ts +++ b/server/server/lib/notifier/shared/instance/new-plugin-version-for-admins.ts @@ -1,10 +1,10 @@ -import { logger } from '@server/helpers/logger' -import { WEBSERVER } from '@server/initializers/constants' -import { UserModel } from '@server/models/user/user' -import { UserNotificationModel } from '@server/models/user/user-notification' -import { MPlugin, MUserDefault, MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/types/models' -import { UserNotificationType, UserRight } from '@shared/models' -import { AbstractNotification } from '../common/abstract-notification' +import { logger } from '@server/helpers/logger.js' +import { WEBSERVER } from '@server/initializers/constants.js' +import { UserModel } from '@server/models/user/user.js' +import { UserNotificationModel } from '@server/models/user/user-notification.js' +import { MPlugin, MUserDefault, MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/types/models/index.js' +import { UserNotificationType, UserRight } from '@peertube/peertube-models' +import { AbstractNotification } from '../common/abstract-notification.js' export class NewPluginVersionForAdmins extends AbstractNotification { private admins: MUserDefault[] diff --git a/server/lib/notifier/shared/instance/registration-request-for-moderators.ts b/server/server/lib/notifier/shared/instance/registration-request-for-moderators.ts similarity index 82% rename from server/lib/notifier/shared/instance/registration-request-for-moderators.ts rename to server/server/lib/notifier/shared/instance/registration-request-for-moderators.ts index 79920245a..29dda28be 100644 --- a/server/lib/notifier/shared/instance/registration-request-for-moderators.ts +++ b/server/server/lib/notifier/shared/instance/registration-request-for-moderators.ts @@ -1,9 +1,9 @@ -import { logger } from '@server/helpers/logger' -import { UserModel } from '@server/models/user/user' -import { UserNotificationModel } from '@server/models/user/user-notification' -import { MRegistration, MUserDefault, MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/types/models' -import { UserNotificationType, UserRight } from '@shared/models' -import { AbstractNotification } from '../common/abstract-notification' +import { logger } from '@server/helpers/logger.js' +import { UserModel } from '@server/models/user/user.js' +import { UserNotificationModel } from '@server/models/user/user-notification.js' +import { MRegistration, MUserDefault, MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/types/models/index.js' +import { UserNotificationType, UserRight } from '@peertube/peertube-models' +import { AbstractNotification } from '../common/abstract-notification.js' export class RegistrationRequestForModerators extends AbstractNotification { private moderators: MUserDefault[] diff --git a/server/lib/notifier/shared/video-publication/abstract-owned-video-publication.ts b/server/server/lib/notifier/shared/video-publication/abstract-owned-video-publication.ts similarity index 81% rename from server/lib/notifier/shared/video-publication/abstract-owned-video-publication.ts rename to server/server/lib/notifier/shared/video-publication/abstract-owned-video-publication.ts index a940cde69..c0bb33620 100644 --- a/server/lib/notifier/shared/video-publication/abstract-owned-video-publication.ts +++ b/server/server/lib/notifier/shared/video-publication/abstract-owned-video-publication.ts @@ -1,10 +1,10 @@ -import { logger } from '@server/helpers/logger' -import { WEBSERVER } from '@server/initializers/constants' -import { UserModel } from '@server/models/user/user' -import { UserNotificationModel } from '@server/models/user/user-notification' -import { MUserDefault, MUserWithNotificationSetting, MVideoFullLight, UserNotificationModelForApi } from '@server/types/models' -import { UserNotificationType } from '@shared/models' -import { AbstractNotification } from '../common/abstract-notification' +import { logger } from '@server/helpers/logger.js' +import { WEBSERVER } from '@server/initializers/constants.js' +import { UserModel } from '@server/models/user/user.js' +import { UserNotificationModel } from '@server/models/user/user-notification.js' +import { MUserDefault, MUserWithNotificationSetting, MVideoFullLight, UserNotificationModelForApi } from '@server/types/models/index.js' +import { UserNotificationType } from '@peertube/peertube-models' +import { AbstractNotification } from '../common/abstract-notification.js' export abstract class AbstractOwnedVideoPublication extends AbstractNotification { protected user: MUserDefault diff --git a/server/lib/notifier/shared/video-publication/import-finished-for-owner.ts b/server/server/lib/notifier/shared/video-publication/import-finished-for-owner.ts similarity index 90% rename from server/lib/notifier/shared/video-publication/import-finished-for-owner.ts rename to server/server/lib/notifier/shared/video-publication/import-finished-for-owner.ts index 3bd64692f..38f12d8cf 100644 --- a/server/lib/notifier/shared/video-publication/import-finished-for-owner.ts +++ b/server/server/lib/notifier/shared/video-publication/import-finished-for-owner.ts @@ -1,10 +1,10 @@ -import { logger } from '@server/helpers/logger' -import { WEBSERVER } from '@server/initializers/constants' -import { UserModel } from '@server/models/user/user' -import { UserNotificationModel } from '@server/models/user/user-notification' -import { MUserDefault, MUserWithNotificationSetting, MVideoImportVideo, UserNotificationModelForApi } from '@server/types/models' -import { UserNotificationType } from '@shared/models' -import { AbstractNotification } from '../common/abstract-notification' +import { logger } from '@server/helpers/logger.js' +import { WEBSERVER } from '@server/initializers/constants.js' +import { UserModel } from '@server/models/user/user.js' +import { UserNotificationModel } from '@server/models/user/user-notification.js' +import { MUserDefault, MUserWithNotificationSetting, MVideoImportVideo, UserNotificationModelForApi } from '@server/types/models/index.js' +import { UserNotificationType } from '@peertube/peertube-models' +import { AbstractNotification } from '../common/abstract-notification.js' export type ImportFinishedForOwnerPayload = { videoImport: MVideoImportVideo diff --git a/server/server/lib/notifier/shared/video-publication/index.ts b/server/server/lib/notifier/shared/video-publication/index.ts new file mode 100644 index 000000000..fc36a9899 --- /dev/null +++ b/server/server/lib/notifier/shared/video-publication/index.ts @@ -0,0 +1,6 @@ +export * from './new-video-for-subscribers.js' +export * from './import-finished-for-owner.js' +export * from './owned-publication-after-auto-unblacklist.js' +export * from './owned-publication-after-schedule-update.js' +export * from './owned-publication-after-transcoding.js' +export * from './studio-edition-finished-for-owner.js' diff --git a/server/lib/notifier/shared/video-publication/new-video-for-subscribers.ts b/server/server/lib/notifier/shared/video-publication/new-video-for-subscribers.ts similarity index 86% rename from server/lib/notifier/shared/video-publication/new-video-for-subscribers.ts rename to server/server/lib/notifier/shared/video-publication/new-video-for-subscribers.ts index df7a5561d..df2d89fc9 100644 --- a/server/lib/notifier/shared/video-publication/new-video-for-subscribers.ts +++ b/server/server/lib/notifier/shared/video-publication/new-video-for-subscribers.ts @@ -1,10 +1,10 @@ -import { logger } from '@server/helpers/logger' -import { WEBSERVER } from '@server/initializers/constants' -import { UserModel } from '@server/models/user/user' -import { UserNotificationModel } from '@server/models/user/user-notification' -import { MUserWithNotificationSetting, MVideoAccountLight, UserNotificationModelForApi } from '@server/types/models' -import { UserNotificationType, VideoPrivacy, VideoState } from '@shared/models' -import { AbstractNotification } from '../common/abstract-notification' +import { logger } from '@server/helpers/logger.js' +import { WEBSERVER } from '@server/initializers/constants.js' +import { UserModel } from '@server/models/user/user.js' +import { UserNotificationModel } from '@server/models/user/user-notification.js' +import { MUserWithNotificationSetting, MVideoAccountLight, UserNotificationModelForApi } from '@server/types/models/index.js' +import { UserNotificationType, VideoPrivacy, VideoState } from '@peertube/peertube-models' +import { AbstractNotification } from '../common/abstract-notification.js' export class NewVideoForSubscribers extends AbstractNotification { private users: MUserWithNotificationSetting[] diff --git a/server/lib/notifier/shared/video-publication/owned-publication-after-auto-unblacklist.ts b/server/server/lib/notifier/shared/video-publication/owned-publication-after-auto-unblacklist.ts similarity index 83% rename from server/lib/notifier/shared/video-publication/owned-publication-after-auto-unblacklist.ts rename to server/server/lib/notifier/shared/video-publication/owned-publication-after-auto-unblacklist.ts index 27d89a5c7..3dbb6e05f 100644 --- a/server/lib/notifier/shared/video-publication/owned-publication-after-auto-unblacklist.ts +++ b/server/server/lib/notifier/shared/video-publication/owned-publication-after-auto-unblacklist.ts @@ -1,6 +1,6 @@ -import { VideoState } from '@shared/models' -import { AbstractOwnedVideoPublication } from './abstract-owned-video-publication' +import { VideoState } from '@peertube/peertube-models' +import { AbstractOwnedVideoPublication } from './abstract-owned-video-publication.js' export class OwnedPublicationAfterAutoUnblacklist extends AbstractOwnedVideoPublication { diff --git a/server/lib/notifier/shared/video-publication/owned-publication-after-schedule-update.ts b/server/server/lib/notifier/shared/video-publication/owned-publication-after-schedule-update.ts similarity index 83% rename from server/lib/notifier/shared/video-publication/owned-publication-after-schedule-update.ts rename to server/server/lib/notifier/shared/video-publication/owned-publication-after-schedule-update.ts index 2e253b358..d8f6e848a 100644 --- a/server/lib/notifier/shared/video-publication/owned-publication-after-schedule-update.ts +++ b/server/server/lib/notifier/shared/video-publication/owned-publication-after-schedule-update.ts @@ -1,5 +1,5 @@ -import { VideoState } from '@shared/models' -import { AbstractOwnedVideoPublication } from './abstract-owned-video-publication' +import { VideoState } from '@peertube/peertube-models' +import { AbstractOwnedVideoPublication } from './abstract-owned-video-publication.js' export class OwnedPublicationAfterScheduleUpdate extends AbstractOwnedVideoPublication { diff --git a/server/lib/notifier/shared/video-publication/owned-publication-after-transcoding.ts b/server/server/lib/notifier/shared/video-publication/owned-publication-after-transcoding.ts similarity index 94% rename from server/lib/notifier/shared/video-publication/owned-publication-after-transcoding.ts rename to server/server/lib/notifier/shared/video-publication/owned-publication-after-transcoding.ts index 4fab1090f..56b4aaaa9 100644 --- a/server/lib/notifier/shared/video-publication/owned-publication-after-transcoding.ts +++ b/server/server/lib/notifier/shared/video-publication/owned-publication-after-transcoding.ts @@ -1,4 +1,4 @@ -import { AbstractOwnedVideoPublication } from './abstract-owned-video-publication' +import { AbstractOwnedVideoPublication } from './abstract-owned-video-publication.js' export class OwnedPublicationAfterTranscoding extends AbstractOwnedVideoPublication { diff --git a/server/lib/notifier/shared/video-publication/studio-edition-finished-for-owner.ts b/server/server/lib/notifier/shared/video-publication/studio-edition-finished-for-owner.ts similarity index 81% rename from server/lib/notifier/shared/video-publication/studio-edition-finished-for-owner.ts rename to server/server/lib/notifier/shared/video-publication/studio-edition-finished-for-owner.ts index f36399f05..a4d72567c 100644 --- a/server/lib/notifier/shared/video-publication/studio-edition-finished-for-owner.ts +++ b/server/server/lib/notifier/shared/video-publication/studio-edition-finished-for-owner.ts @@ -1,10 +1,10 @@ -import { logger } from '@server/helpers/logger' -import { WEBSERVER } from '@server/initializers/constants' -import { UserModel } from '@server/models/user/user' -import { UserNotificationModel } from '@server/models/user/user-notification' -import { MUserDefault, MUserWithNotificationSetting, MVideoFullLight, UserNotificationModelForApi } from '@server/types/models' -import { UserNotificationType } from '@shared/models' -import { AbstractNotification } from '../common/abstract-notification' +import { logger } from '@server/helpers/logger.js' +import { WEBSERVER } from '@server/initializers/constants.js' +import { UserModel } from '@server/models/user/user.js' +import { UserNotificationModel } from '@server/models/user/user-notification.js' +import { MUserDefault, MUserWithNotificationSetting, MVideoFullLight, UserNotificationModelForApi } from '@server/types/models/index.js' +import { UserNotificationType } from '@peertube/peertube-models' +import { AbstractNotification } from '../common/abstract-notification.js' export class StudioEditionFinishedForOwner extends AbstractNotification { private user: MUserDefault diff --git a/server/server/lib/object-storage/index.ts b/server/server/lib/object-storage/index.ts new file mode 100644 index 000000000..238a652a6 --- /dev/null +++ b/server/server/lib/object-storage/index.ts @@ -0,0 +1,5 @@ +export * from './keys.js' +export * from './proxy.js' +export * from './pre-signed-urls.js' +export * from './urls.js' +export * from './videos.js' diff --git a/server/lib/object-storage/keys.ts b/server/server/lib/object-storage/keys.ts similarity index 88% rename from server/lib/object-storage/keys.ts rename to server/server/lib/object-storage/keys.ts index 6d2098298..9e52a7f19 100644 --- a/server/lib/object-storage/keys.ts +++ b/server/server/lib/object-storage/keys.ts @@ -1,5 +1,5 @@ import { join } from 'path' -import { MStreamingPlaylistVideo } from '@server/types/models' +import { MStreamingPlaylistVideo } from '@server/types/models/index.js' function generateHLSObjectStorageKey (playlist: MStreamingPlaylistVideo, filename: string) { return join(generateHLSObjectBaseStorageKey(playlist), filename) diff --git a/server/lib/object-storage/pre-signed-urls.ts b/server/server/lib/object-storage/pre-signed-urls.ts similarity index 67% rename from server/lib/object-storage/pre-signed-urls.ts rename to server/server/lib/object-storage/pre-signed-urls.ts index caf149bb8..bbb19a57c 100644 --- a/server/lib/object-storage/pre-signed-urls.ts +++ b/server/server/lib/object-storage/pre-signed-urls.ts @@ -1,10 +1,8 @@ -import { GetObjectCommand } from '@aws-sdk/client-s3' -import { getSignedUrl } from '@aws-sdk/s3-request-presigner' -import { CONFIG } from '@server/initializers/config' -import { MStreamingPlaylistVideo, MVideoFile } from '@server/types/models' -import { generateHLSObjectStorageKey, generateWebVideoObjectStorageKey } from './keys' -import { buildKey, getClient } from './shared' -import { getHLSPublicFileUrl, getWebVideoPublicFileUrl } from './urls' +import { CONFIG } from '@server/initializers/config.js' +import { MStreamingPlaylistVideo, MVideoFile } from '@server/types/models/index.js' +import { generateHLSObjectStorageKey, generateWebVideoObjectStorageKey } from './keys.js' +import { buildKey, getClient } from './shared/index.js' +import { getHLSPublicFileUrl, getWebVideoPublicFileUrl } from './urls.js' export async function generateWebVideoPresignedUrl (options: { file: MVideoFile @@ -14,13 +12,16 @@ export async function generateWebVideoPresignedUrl (options: { const key = generateWebVideoObjectStorageKey(file.filename) + const { GetObjectCommand } = await import('@aws-sdk/client-s3') + const { getSignedUrl } = await import('@aws-sdk/s3-request-presigner') + const command = new GetObjectCommand({ Bucket: CONFIG.OBJECT_STORAGE.WEB_VIDEOS.BUCKET_NAME, Key: buildKey(key, CONFIG.OBJECT_STORAGE.WEB_VIDEOS), ResponseContentDisposition: `attachment; filename=${downloadFilename}` }) - const url = await getSignedUrl(getClient(), command, { expiresIn: 3600 * 24 }) + const url = await getSignedUrl(await getClient(), command, { expiresIn: 3600 * 24 }) return getWebVideoPublicFileUrl(url) } @@ -34,13 +35,16 @@ export async function generateHLSFilePresignedUrl (options: { const key = generateHLSObjectStorageKey(streamingPlaylist, file.filename) + const { GetObjectCommand } = await import('@aws-sdk/client-s3') + const { getSignedUrl } = await import('@aws-sdk/s3-request-presigner') + const command = new GetObjectCommand({ Bucket: CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS.BUCKET_NAME, Key: buildKey(key, CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS), ResponseContentDisposition: `attachment; filename=${downloadFilename}` }) - const url = await getSignedUrl(getClient(), command, { expiresIn: 3600 * 24 }) + const url = await getSignedUrl(await getClient(), command, { expiresIn: 3600 * 24 }) return getHLSPublicFileUrl(url) } diff --git a/server/lib/object-storage/proxy.ts b/server/server/lib/object-storage/proxy.ts similarity index 88% rename from server/lib/object-storage/proxy.ts rename to server/server/lib/object-storage/proxy.ts index c09a0d1b0..bef899fed 100644 --- a/server/lib/object-storage/proxy.ts +++ b/server/server/lib/object-storage/proxy.ts @@ -1,13 +1,14 @@ import express from 'express' import { PassThrough, pipeline } from 'stream' -import { GetObjectCommandOutput } from '@aws-sdk/client-s3' -import { buildReinjectVideoFileTokenQuery } from '@server/controllers/shared/m3u8-playlist' -import { logger } from '@server/helpers/logger' -import { StreamReplacer } from '@server/helpers/stream-replacer' -import { MStreamingPlaylist, MVideo } from '@server/types/models' -import { HttpStatusCode } from '@shared/models' -import { injectQueryToPlaylistUrls } from '../hls' -import { getHLSFileReadStream, getWebVideoFileReadStream } from './videos' +import { HttpStatusCode } from '@peertube/peertube-models' +import { buildReinjectVideoFileTokenQuery } from '@server/controllers/shared/m3u8-playlist.js' +import { logger } from '@server/helpers/logger.js' +import { StreamReplacer } from '@server/helpers/stream-replacer.js' +import { MStreamingPlaylist, MVideo } from '@server/types/models/index.js' +import { injectQueryToPlaylistUrls } from '../hls.js' +import { getHLSFileReadStream, getWebVideoFileReadStream } from './videos.js' + +import type { GetObjectCommandOutput } from '@aws-sdk/client-s3' export async function proxifyWebVideoFile (options: { req: express.Request diff --git a/server/server/lib/object-storage/shared/client.ts b/server/server/lib/object-storage/shared/client.ts new file mode 100644 index 000000000..085bdbc4c --- /dev/null +++ b/server/server/lib/object-storage/shared/client.ts @@ -0,0 +1,78 @@ +import type { S3Client } from '@aws-sdk/client-s3' +import { logger } from '@server/helpers/logger.js' +import { isProxyEnabled } from '@server/helpers/proxy.js' +import { getAgent } from '@server/helpers/requests.js' +import { CONFIG } from '@server/initializers/config.js' +import { lTags } from './logger.js' + +async function getProxyRequestHandler () { + if (!isProxyEnabled()) return null + + const { agent } = getAgent() + + const { NodeHttpHandler } = await import('@aws-sdk/node-http-handler') + + return new NodeHttpHandler({ + httpAgent: agent.http, + httpsAgent: agent.https + }) +} + +let endpointParsed: URL +function getEndpointParsed () { + if (endpointParsed) return endpointParsed + + endpointParsed = new URL(getEndpoint()) + + return endpointParsed +} + +let s3ClientPromise: Promise +function getClient () { + if (s3ClientPromise) return s3ClientPromise + + s3ClientPromise = (async () => { + const OBJECT_STORAGE = CONFIG.OBJECT_STORAGE + + const { S3Client } = await import('@aws-sdk/client-s3') + + const s3Client = new S3Client({ + endpoint: getEndpoint(), + region: OBJECT_STORAGE.REGION, + credentials: OBJECT_STORAGE.CREDENTIALS.ACCESS_KEY_ID + ? { + accessKeyId: OBJECT_STORAGE.CREDENTIALS.ACCESS_KEY_ID, + secretAccessKey: OBJECT_STORAGE.CREDENTIALS.SECRET_ACCESS_KEY + } + : undefined, + requestHandler: await getProxyRequestHandler() + }) + + logger.info('Initialized S3 client %s with region %s.', getEndpoint(), OBJECT_STORAGE.REGION, lTags()) + + return s3Client + })() + + return s3ClientPromise +} + +// --------------------------------------------------------------------------- + +export { + getEndpointParsed, + getClient +} + +// --------------------------------------------------------------------------- + +let endpoint: string +function getEndpoint () { + if (endpoint) return endpoint + + const endpointConfig = CONFIG.OBJECT_STORAGE.ENDPOINT + endpoint = endpointConfig.startsWith('http://') || endpointConfig.startsWith('https://') + ? CONFIG.OBJECT_STORAGE.ENDPOINT + : 'https://' + CONFIG.OBJECT_STORAGE.ENDPOINT + + return endpoint +} diff --git a/server/server/lib/object-storage/shared/index.ts b/server/server/lib/object-storage/shared/index.ts new file mode 100644 index 000000000..d6b76a3d5 --- /dev/null +++ b/server/server/lib/object-storage/shared/index.ts @@ -0,0 +1,3 @@ +export * from './client.js' +export * from './logger.js' +export * from './object-storage-helpers.js' diff --git a/server/lib/object-storage/shared/logger.ts b/server/server/lib/object-storage/shared/logger.ts similarity index 53% rename from server/lib/object-storage/shared/logger.ts rename to server/server/lib/object-storage/shared/logger.ts index 8ab7cbd71..8b8e19f68 100644 --- a/server/lib/object-storage/shared/logger.ts +++ b/server/server/lib/object-storage/shared/logger.ts @@ -1,4 +1,4 @@ -import { loggerTagsFactory } from '@server/helpers/logger' +import { loggerTagsFactory } from '@server/helpers/logger.js' const lTags = loggerTagsFactory('object-storage') diff --git a/server/lib/object-storage/shared/object-storage-helpers.ts b/server/server/lib/object-storage/shared/object-storage-helpers.ts similarity index 81% rename from server/lib/object-storage/shared/object-storage-helpers.ts rename to server/server/lib/object-storage/shared/object-storage-helpers.ts index 0d8878bd2..ce96696e5 100644 --- a/server/lib/object-storage/shared/object-storage-helpers.ts +++ b/server/server/lib/object-storage/shared/object-storage-helpers.ts @@ -1,25 +1,17 @@ -import { map } from 'bluebird' -import { createReadStream, createWriteStream, ensureDir, ReadStream } from 'fs-extra' +import { pipelinePromise } from '@server/helpers/core-utils.js' +import { isArray } from '@server/helpers/custom-validators/misc.js' +import { logger } from '@server/helpers/logger.js' +import { CONFIG } from '@server/initializers/config.js' +import Bluebird from 'bluebird' +import { createReadStream, createWriteStream, ReadStream } from 'fs' +import { ensureDir } from 'fs-extra/esm' import { dirname } from 'path' import { Readable } from 'stream' -import { - _Object, - CompleteMultipartUploadCommandOutput, - DeleteObjectCommand, - GetObjectCommand, - ListObjectsV2Command, - PutObjectAclCommand, - PutObjectCommandInput, - S3Client -} from '@aws-sdk/client-s3' -import { Upload } from '@aws-sdk/lib-storage' -import { pipelinePromise } from '@server/helpers/core-utils' -import { isArray } from '@server/helpers/custom-validators/misc' -import { logger } from '@server/helpers/logger' -import { CONFIG } from '@server/initializers/config' -import { getInternalUrl } from '../urls' -import { getClient } from './client' -import { lTags } from './logger' +import { getInternalUrl } from '../urls.js' +import { getClient } from './client.js' +import { lTags } from './logger.js' + +import type { _Object, CompleteMultipartUploadCommandOutput, PutObjectCommandInput, S3Client } from '@aws-sdk/client-s3' type BucketInfo = { BUCKET_NAME: string @@ -27,7 +19,9 @@ type BucketInfo = { } async function listKeysOfPrefix (prefix: string, bucketInfo: BucketInfo) { - const s3Client = getClient() + const s3Client = await getClient() + + const { ListObjectsV2Command } = await import('@aws-sdk/client-s3') const commandPrefix = bucketInfo.PREFIX + prefix const listCommand = new ListObjectsV2Command({ @@ -89,16 +83,19 @@ async function updateObjectACL (options: { logger.debug('Updating ACL file %s in bucket %s', key, bucketInfo.BUCKET_NAME, lTags()) + const { PutObjectAclCommand } = await import('@aws-sdk/client-s3') + const command = new PutObjectAclCommand({ Bucket: bucketInfo.BUCKET_NAME, Key: key, ACL: acl }) - await getClient().send(command) + const client = await getClient() + await client.send(command) } -function updatePrefixACL (options: { +async function updatePrefixACL (options: { prefix: string bucketInfo: BucketInfo isPrivate: boolean @@ -108,6 +105,8 @@ function updatePrefixACL (options: { const acl = getACL(isPrivate) if (!acl) return + const { PutObjectAclCommand } = await import('@aws-sdk/client-s3') + logger.debug('Updating ACL of files in prefix %s in bucket %s', prefix, bucketInfo.BUCKET_NAME, lTags()) return applyOnPrefix({ @@ -133,20 +132,26 @@ function removeObject (objectStorageKey: string, bucketInfo: BucketInfo) { return removeObjectByFullKey(key, bucketInfo) } -function removeObjectByFullKey (fullKey: string, bucketInfo: BucketInfo) { +async function removeObjectByFullKey (fullKey: string, bucketInfo: BucketInfo) { logger.debug('Removing file %s in bucket %s', fullKey, bucketInfo.BUCKET_NAME, lTags()) + const { DeleteObjectCommand } = await import('@aws-sdk/client-s3') + const command = new DeleteObjectCommand({ Bucket: bucketInfo.BUCKET_NAME, Key: fullKey }) - return getClient().send(command) + const client = await getClient() + + return client.send(command) } async function removePrefix (prefix: string, bucketInfo: BucketInfo) { logger.debug('Removing prefix %s in bucket %s', prefix, bucketInfo.BUCKET_NAME, lTags()) + const { DeleteObjectCommand } = await import('@aws-sdk/client-s3') + return applyOnPrefix({ prefix, bucketInfo, @@ -172,11 +177,15 @@ async function makeAvailable (options: { await ensureDir(dirname(options.destination)) + const { GetObjectCommand } = await import('@aws-sdk/client-s3') + const command = new GetObjectCommand({ Bucket: bucketInfo.BUCKET_NAME, Key: buildKey(key, bucketInfo) }) - const response = await getClient().send(command) + + const client = await getClient() + const response = await client.send(command) const file = createWriteStream(destination) await pipelinePromise(response.Body as Readable, file) @@ -197,13 +206,16 @@ async function createObjectReadStream (options: { }) { const { key, bucketInfo, rangeHeader } = options + const { GetObjectCommand } = await import('@aws-sdk/client-s3') + const command = new GetObjectCommand({ Bucket: bucketInfo.BUCKET_NAME, Key: buildKey(key, bucketInfo), Range: rangeHeader }) - const response = await getClient().send(command) + const client = await getClient() + const response = await client.send(command) return { response, @@ -214,7 +226,8 @@ async function createObjectReadStream (options: { // --------------------------------------------------------------------------- export { - BucketInfo, + type BucketInfo, + buildKey, storeObject, @@ -252,8 +265,10 @@ async function uploadToStorage (options: { const acl = getACL(isPrivate) if (acl) input.ACL = acl + const { Upload } = await import('@aws-sdk/lib-storage') + const parallelUploads3 = new Upload({ - client: getClient(), + client: await getClient(), queueSize: 4, partSize: CONFIG.OBJECT_STORAGE.MAX_UPLOAD_PART, @@ -291,7 +306,9 @@ async function applyOnPrefix (options: { }) { const { prefix, bucketInfo, commandBuilder, continuationToken } = options - const s3Client = getClient() + const s3Client = await getClient() + + const { ListObjectsV2Command } = await import('@aws-sdk/client-s3') const commandPrefix = buildKey(prefix, bucketInfo) const listCommand = new ListObjectsV2Command({ @@ -309,7 +326,7 @@ async function applyOnPrefix (options: { throw new Error(message) } - await map(listedObjects.Contents, object => { + await Bluebird.map(listedObjects.Contents, object => { const command = commandBuilder(object) return s3Client.send(command) diff --git a/server/lib/object-storage/urls.ts b/server/server/lib/object-storage/urls.ts similarity index 92% rename from server/lib/object-storage/urls.ts rename to server/server/lib/object-storage/urls.ts index 40619cd5a..0bd469ea8 100644 --- a/server/lib/object-storage/urls.ts +++ b/server/server/lib/object-storage/urls.ts @@ -1,7 +1,7 @@ -import { CONFIG } from '@server/initializers/config' -import { OBJECT_STORAGE_PROXY_PATHS, WEBSERVER } from '@server/initializers/constants' -import { MVideoUUID } from '@server/types/models' -import { BucketInfo, buildKey, getEndpointParsed } from './shared' +import { CONFIG } from '@server/initializers/config.js' +import { OBJECT_STORAGE_PROXY_PATHS, WEBSERVER } from '@server/initializers/constants.js' +import { MVideoUUID } from '@server/types/models/index.js' +import { BucketInfo, buildKey, getEndpointParsed } from './shared/index.js' function getInternalUrl (config: BucketInfo, keyWithoutPrefix: string) { return getBaseUrl(config) + buildKey(keyWithoutPrefix, config) diff --git a/server/lib/object-storage/videos.ts b/server/server/lib/object-storage/videos.ts similarity index 94% rename from server/lib/object-storage/videos.ts rename to server/server/lib/object-storage/videos.ts index 891e9ff76..46d32b566 100644 --- a/server/lib/object-storage/videos.ts +++ b/server/server/lib/object-storage/videos.ts @@ -1,10 +1,10 @@ import { basename, join } from 'path' -import { logger } from '@server/helpers/logger' -import { CONFIG } from '@server/initializers/config' -import { MStreamingPlaylistVideo, MVideo, MVideoFile } from '@server/types/models' -import { getHLSDirectory } from '../paths' -import { VideoPathManager } from '../video-path-manager' -import { generateHLSObjectBaseStorageKey, generateHLSObjectStorageKey, generateWebVideoObjectStorageKey } from './keys' +import { logger } from '@server/helpers/logger.js' +import { CONFIG } from '@server/initializers/config.js' +import { MStreamingPlaylistVideo, MVideo, MVideoFile } from '@server/types/models/index.js' +import { getHLSDirectory } from '../paths.js' +import { VideoPathManager } from '../video-path-manager.js' +import { generateHLSObjectBaseStorageKey, generateHLSObjectStorageKey, generateWebVideoObjectStorageKey } from './keys.js' import { createObjectReadStream, listKeysOfPrefix, @@ -17,7 +17,7 @@ import { storeObject, updateObjectACL, updatePrefixACL -} from './shared' +} from './shared/index.js' function listHLSFileKeysOf (playlist: MStreamingPlaylistVideo) { return listKeysOfPrefix(generateHLSObjectBaseStorageKey(playlist), CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS) diff --git a/server/lib/opentelemetry/metric-helpers/bittorrent-tracker-observers-builder.ts b/server/server/lib/opentelemetry/metric-helpers/bittorrent-tracker-observers-builder.ts similarity index 100% rename from server/lib/opentelemetry/metric-helpers/bittorrent-tracker-observers-builder.ts rename to server/server/lib/opentelemetry/metric-helpers/bittorrent-tracker-observers-builder.ts diff --git a/server/server/lib/opentelemetry/metric-helpers/index.ts b/server/server/lib/opentelemetry/metric-helpers/index.ts new file mode 100644 index 000000000..ec9c35408 --- /dev/null +++ b/server/server/lib/opentelemetry/metric-helpers/index.ts @@ -0,0 +1,7 @@ +export * from './bittorrent-tracker-observers-builder.js' +export * from './lives-observers-builder.js' +export * from './job-queue-observers-builder.js' +export * from './nodejs-observers-builder.js' +export * from './playback-metrics.js' +export * from './stats-observers-builder.js' +export * from './viewers-observers-builder.js' diff --git a/server/lib/opentelemetry/metric-helpers/job-queue-observers-builder.ts b/server/server/lib/opentelemetry/metric-helpers/job-queue-observers-builder.ts similarity index 91% rename from server/lib/opentelemetry/metric-helpers/job-queue-observers-builder.ts rename to server/server/lib/opentelemetry/metric-helpers/job-queue-observers-builder.ts index 56713ede8..c0bcb517e 100644 --- a/server/lib/opentelemetry/metric-helpers/job-queue-observers-builder.ts +++ b/server/server/lib/opentelemetry/metric-helpers/job-queue-observers-builder.ts @@ -1,5 +1,5 @@ import { Meter } from '@opentelemetry/api' -import { JobQueue } from '@server/lib/job-queue' +import { JobQueue } from '@server/lib/job-queue/index.js' export class JobQueueObserversBuilder { diff --git a/server/lib/opentelemetry/metric-helpers/lives-observers-builder.ts b/server/server/lib/opentelemetry/metric-helpers/lives-observers-builder.ts similarity index 91% rename from server/lib/opentelemetry/metric-helpers/lives-observers-builder.ts rename to server/server/lib/opentelemetry/metric-helpers/lives-observers-builder.ts index 5effc18e1..45676ed2b 100644 --- a/server/lib/opentelemetry/metric-helpers/lives-observers-builder.ts +++ b/server/server/lib/opentelemetry/metric-helpers/lives-observers-builder.ts @@ -1,5 +1,5 @@ import { Meter } from '@opentelemetry/api' -import { VideoModel } from '@server/models/video/video' +import { VideoModel } from '@server/models/video/video.js' export class LivesObserversBuilder { diff --git a/server/lib/opentelemetry/metric-helpers/nodejs-observers-builder.ts b/server/server/lib/opentelemetry/metric-helpers/nodejs-observers-builder.ts similarity index 98% rename from server/lib/opentelemetry/metric-helpers/nodejs-observers-builder.ts rename to server/server/lib/opentelemetry/metric-helpers/nodejs-observers-builder.ts index 8ed219e9e..40df12b8d 100644 --- a/server/lib/opentelemetry/metric-helpers/nodejs-observers-builder.ts +++ b/server/server/lib/opentelemetry/metric-helpers/nodejs-observers-builder.ts @@ -1,10 +1,10 @@ -import { readdir } from 'fs-extra' +import { readdir } from 'fs/promises' import { constants, NodeGCPerformanceDetail, PerformanceObserver } from 'perf_hooks' import * as process from 'process' import { Meter, ObservableResult } from '@opentelemetry/api' import { ExplicitBucketHistogramAggregation } from '@opentelemetry/sdk-metrics' -import { View } from '@opentelemetry/sdk-metrics/build/src/view/View' -import { logger } from '@server/helpers/logger' +import { View } from '@opentelemetry/sdk-metrics/build/src/view/View.js' +import { logger } from '@server/helpers/logger.js' // Thanks to https://github.com/siimon/prom-client // We took their logic and adapter it for opentelemetry diff --git a/server/lib/opentelemetry/metric-helpers/playback-metrics.ts b/server/server/lib/opentelemetry/metric-helpers/playback-metrics.ts similarity index 95% rename from server/lib/opentelemetry/metric-helpers/playback-metrics.ts rename to server/server/lib/opentelemetry/metric-helpers/playback-metrics.ts index 1eb08b5a6..ec139f331 100644 --- a/server/lib/opentelemetry/metric-helpers/playback-metrics.ts +++ b/server/server/lib/opentelemetry/metric-helpers/playback-metrics.ts @@ -1,6 +1,6 @@ import { Counter, Meter } from '@opentelemetry/api' -import { MVideoImmutable } from '@server/types/models' -import { PlaybackMetricCreate } from '@shared/models' +import { MVideoImmutable } from '@server/types/models/index.js' +import { PlaybackMetricCreate } from '@peertube/peertube-models' export class PlaybackMetrics { private errorsCounter: Counter diff --git a/server/lib/opentelemetry/metric-helpers/stats-observers-builder.ts b/server/server/lib/opentelemetry/metric-helpers/stats-observers-builder.ts similarity index 98% rename from server/lib/opentelemetry/metric-helpers/stats-observers-builder.ts rename to server/server/lib/opentelemetry/metric-helpers/stats-observers-builder.ts index 9f5f22e1b..05e6431a4 100644 --- a/server/lib/opentelemetry/metric-helpers/stats-observers-builder.ts +++ b/server/server/lib/opentelemetry/metric-helpers/stats-observers-builder.ts @@ -1,8 +1,8 @@ import memoizee from 'memoizee' import { Meter } from '@opentelemetry/api' -import { MEMOIZE_TTL } from '@server/initializers/constants' -import { buildAvailableActivities } from '@server/lib/activitypub/activity' -import { StatsManager } from '@server/lib/stat-manager' +import { MEMOIZE_TTL } from '@server/initializers/constants.js' +import { buildAvailableActivities } from '@server/lib/activitypub/activity.js' +import { StatsManager } from '@server/lib/stat-manager.js' export class StatsObserversBuilder { diff --git a/server/lib/opentelemetry/metric-helpers/viewers-observers-builder.ts b/server/server/lib/opentelemetry/metric-helpers/viewers-observers-builder.ts similarity index 97% rename from server/lib/opentelemetry/metric-helpers/viewers-observers-builder.ts rename to server/server/lib/opentelemetry/metric-helpers/viewers-observers-builder.ts index c65f8ddae..a1e1c7496 100644 --- a/server/lib/opentelemetry/metric-helpers/viewers-observers-builder.ts +++ b/server/server/lib/opentelemetry/metric-helpers/viewers-observers-builder.ts @@ -1,6 +1,6 @@ import { Meter } from '@opentelemetry/api' -import { VideoScope, ViewerScope } from '@server/lib/views/shared' -import { VideoViewsManager } from '@server/lib/views/video-views-manager' +import { VideoScope, ViewerScope } from '@server/lib/views/shared/index.js' +import { VideoViewsManager } from '@server/lib/views/video-views-manager.js' export class ViewersObserversBuilder { diff --git a/server/lib/opentelemetry/metrics.ts b/server/server/lib/opentelemetry/metrics.ts similarity index 92% rename from server/lib/opentelemetry/metrics.ts rename to server/server/lib/opentelemetry/metrics.ts index bffe00840..7276182ef 100644 --- a/server/lib/opentelemetry/metrics.ts +++ b/server/server/lib/opentelemetry/metrics.ts @@ -2,10 +2,10 @@ import { Application, Request, Response } from 'express' import { Meter, metrics } from '@opentelemetry/api' import { PrometheusExporter } from '@opentelemetry/exporter-prometheus' import { MeterProvider } from '@opentelemetry/sdk-metrics' -import { logger } from '@server/helpers/logger' -import { CONFIG } from '@server/initializers/config' -import { MVideoImmutable } from '@server/types/models' -import { PlaybackMetricCreate } from '@shared/models' +import { logger } from '@server/helpers/logger.js' +import { CONFIG } from '@server/initializers/config.js' +import { MVideoImmutable } from '@server/types/models/index.js' +import { PlaybackMetricCreate } from '@peertube/peertube-models' import { BittorrentTrackerObserversBuilder, JobQueueObserversBuilder, @@ -14,7 +14,7 @@ import { PlaybackMetrics, StatsObserversBuilder, ViewersObserversBuilder -} from './metric-helpers' +} from './metric-helpers/index.js' class OpenTelemetryMetrics { diff --git a/server/server/lib/opentelemetry/tracing.ts b/server/server/lib/opentelemetry/tracing.ts new file mode 100644 index 000000000..b306fa40c --- /dev/null +++ b/server/server/lib/opentelemetry/tracing.ts @@ -0,0 +1,140 @@ +import type { Span, Tracer } from '@opentelemetry/api' +import { logger } from '@server/helpers/logger.js' +import { CONFIG } from '@server/initializers/config.js' + +let tracer: Tracer | TrackerMock + +async function registerOpentelemetryTracing () { + if (CONFIG.OPEN_TELEMETRY.TRACING.ENABLED !== true) { + tracer = new TrackerMock() + + return + } + + const { diag, DiagLogLevel, trace } = await import('@opentelemetry/api') + tracer = trace.getTracer('peertube') + + const [ + { JaegerExporter }, + { registerInstrumentations }, + DnsInstrumentation, + ExpressInstrumentation, + { FsInstrumentation }, + { HttpInstrumentation }, + IORedisInstrumentation, + PgInstrumentation, + { SequelizeInstrumentation }, + Resource, + BatchSpanProcessor, + NodeTracerProvider, + SemanticResourceAttributes + ] = await Promise.all([ + import('@opentelemetry/exporter-jaeger'), + import('@opentelemetry/instrumentation'), + import('@opentelemetry/instrumentation-dns'), + import('@opentelemetry/instrumentation-express'), + import('@opentelemetry/instrumentation-fs'), + import('@opentelemetry/instrumentation-http'), + import('@opentelemetry/instrumentation-ioredis'), + import('@opentelemetry/instrumentation-pg'), + import('opentelemetry-instrumentation-sequelize'), + import('@opentelemetry/resources'), + import('@opentelemetry/sdk-trace-base'), + import('@opentelemetry/sdk-trace-node'), + import('@opentelemetry/semantic-conventions') + ]) + + logger.info('Registering Open Telemetry tracing') + + const customLogger = (level: string) => { + return (message: string, ...args: unknown[]) => { + let fullMessage = message + + for (const arg of args) { + if (typeof arg === 'string') fullMessage += arg + else break + } + + logger[level](fullMessage) + } + } + + diag.setLogger({ + error: customLogger('error'), + warn: customLogger('warn'), + info: customLogger('info'), + debug: customLogger('debug'), + verbose: customLogger('verbose') + }, DiagLogLevel.INFO) + + const tracerProvider = new NodeTracerProvider.default.NodeTracerProvider({ + resource: new Resource.default.Resource({ + [SemanticResourceAttributes.default.SemanticResourceAttributes.SERVICE_NAME]: 'peertube' + }) + }) + + registerInstrumentations({ + tracerProvider, + instrumentations: [ + new PgInstrumentation.default.PgInstrumentation({ + enhancedDatabaseReporting: true + }), + new DnsInstrumentation.default.DnsInstrumentation(), + new HttpInstrumentation(), + new ExpressInstrumentation.default.ExpressInstrumentation(), + new IORedisInstrumentation.default.IORedisInstrumentation({ + dbStatementSerializer: function (cmdName, cmdArgs) { + return [ cmdName, ...cmdArgs ].join(' ') + } + }), + new FsInstrumentation(), + new SequelizeInstrumentation() + ] + }) + + tracerProvider.addSpanProcessor( + new BatchSpanProcessor.default.BatchSpanProcessor( + new JaegerExporter({ endpoint: CONFIG.OPEN_TELEMETRY.TRACING.JAEGER_EXPORTER.ENDPOINT }) + ) + ) + + tracerProvider.register() +} + +async function wrapWithSpanAndContext (spanName: string, cb: () => Promise) { + const { context, trace } = await import('@opentelemetry/api') + + if (CONFIG.OPEN_TELEMETRY.TRACING.ENABLED !== true) { + return cb() + } + + const span = tracer.startSpan(spanName) + const activeContext = trace.setSpan(context.active(), span as Span) + + const result = await context.with(activeContext, () => cb()) + span.end() + + return result +} + +export { + registerOpentelemetryTracing, + tracer, + wrapWithSpanAndContext +} + +// --------------------------------------------------------------------------- +// Private +// --------------------------------------------------------------------------- + +class TrackerMock { + startSpan () { + return new SpanMock() + } +} + +class SpanMock { + end () { + + } +} diff --git a/server/lib/paths.ts b/server/server/lib/paths.ts similarity index 88% rename from server/lib/paths.ts rename to server/server/lib/paths.ts index db1cdede2..208e78efa 100644 --- a/server/lib/paths.ts +++ b/server/server/lib/paths.ts @@ -1,10 +1,10 @@ import { join } from 'path' -import { CONFIG } from '@server/initializers/config' -import { DIRECTORIES, VIDEO_LIVE } from '@server/initializers/constants' -import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoUUID } from '@server/types/models' -import { removeFragmentedMP4Ext } from '@shared/core-utils' -import { buildUUID } from '@shared/extra-utils' -import { isVideoInPrivateDirectory } from './video-privacy' +import { CONFIG } from '@server/initializers/config.js' +import { DIRECTORIES, VIDEO_LIVE } from '@server/initializers/constants.js' +import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoUUID } from '@server/types/models/index.js' +import { removeFragmentedMP4Ext } from '@peertube/peertube-core-utils' +import { buildUUID } from '@peertube/peertube-node-utils' +import { isVideoInPrivateDirectory } from './video-privacy.js' // ################## Video file name ################## diff --git a/server/lib/peertube-socket.ts b/server/server/lib/peertube-socket.ts similarity index 91% rename from server/lib/peertube-socket.ts rename to server/server/lib/peertube-socket.ts index 3e41a2def..4bb82189e 100644 --- a/server/lib/peertube-socket.ts +++ b/server/server/lib/peertube-socket.ts @@ -1,13 +1,13 @@ import { Server as HTTPServer } from 'http' import { Namespace, Server as SocketServer, Socket } from 'socket.io' -import { isIdValid } from '@server/helpers/custom-validators/misc' -import { Debounce } from '@server/helpers/debounce' -import { MVideo, MVideoImmutable } from '@server/types/models' -import { MRunner } from '@server/types/models/runners' -import { UserNotificationModelForApi } from '@server/types/models/user' -import { LiveVideoEventPayload, LiveVideoEventType } from '@shared/models' -import { logger } from '../helpers/logger' -import { authenticateRunnerSocket, authenticateSocket } from '../middlewares' +import { isIdValid } from '@server/helpers/custom-validators/misc.js' +import { Debounce } from '@server/helpers/debounce.js' +import { MVideo, MVideoImmutable } from '@server/types/models/index.js' +import { MRunner } from '@server/types/models/runners/index.js' +import { UserNotificationModelForApi } from '@server/types/models/user/index.js' +import { LiveVideoEventPayload, LiveVideoEventType } from '@peertube/peertube-models' +import { logger } from '../helpers/logger.js' +import { authenticateRunnerSocket, authenticateSocket } from '../middlewares/index.js' class PeerTubeSocket { diff --git a/server/lib/plugins/hooks.ts b/server/server/lib/plugins/hooks.ts similarity index 84% rename from server/lib/plugins/hooks.ts rename to server/server/lib/plugins/hooks.ts index 694527c12..70aaf4786 100644 --- a/server/lib/plugins/hooks.ts +++ b/server/server/lib/plugins/hooks.ts @@ -1,7 +1,7 @@ import Bluebird from 'bluebird' -import { ServerActionHookName, ServerFilterHookName } from '../../../shared/models' -import { logger } from '../../helpers/logger' -import { PluginManager } from './plugin-manager' +import { ServerActionHookName, ServerFilterHookName } from '@peertube/peertube-models' +import { logger } from '../../helpers/logger.js' +import { PluginManager } from './plugin-manager.js' type PromiseFunction = (params: U) => Promise | Bluebird type RawFunction = (params: U) => T diff --git a/server/lib/plugins/plugin-helpers-builder.ts b/server/server/lib/plugins/plugin-helpers-builder.ts similarity index 88% rename from server/lib/plugins/plugin-helpers-builder.ts rename to server/server/lib/plugins/plugin-helpers-builder.ts index b4e3eece4..4c1bd2bf7 100644 --- a/server/lib/plugins/plugin-helpers-builder.ts +++ b/server/server/lib/plugins/plugin-helpers-builder.ts @@ -1,27 +1,27 @@ import express from 'express' import { Server } from 'http' import { join } from 'path' -import { buildLogger } from '@server/helpers/logger' -import { CONFIG } from '@server/initializers/config' -import { WEBSERVER } from '@server/initializers/constants' -import { sequelizeTypescript } from '@server/initializers/database' -import { AccountModel } from '@server/models/account/account' -import { AccountBlocklistModel } from '@server/models/account/account-blocklist' -import { getServerActor } from '@server/models/application/application' -import { ServerModel } from '@server/models/server/server' -import { ServerBlocklistModel } from '@server/models/server/server-blocklist' -import { UserModel } from '@server/models/user/user' -import { VideoModel } from '@server/models/video/video' -import { VideoBlacklistModel } from '@server/models/video/video-blacklist' -import { MPlugin, MVideo, UserNotificationModelForApi } from '@server/types/models' -import { PeerTubeHelpers } from '@server/types/plugins' -import { ffprobePromise } from '@shared/ffmpeg' -import { VideoBlacklistCreate, VideoStorage } from '@shared/models' -import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../blocklist' -import { PeerTubeSocket } from '../peertube-socket' -import { ServerConfigManager } from '../server-config-manager' -import { blacklistVideo, unblacklistVideo } from '../video-blacklist' -import { VideoPathManager } from '../video-path-manager' +import { buildLogger } from '@server/helpers/logger.js' +import { CONFIG } from '@server/initializers/config.js' +import { WEBSERVER } from '@server/initializers/constants.js' +import { sequelizeTypescript } from '@server/initializers/database.js' +import { AccountModel } from '@server/models/account/account.js' +import { AccountBlocklistModel } from '@server/models/account/account-blocklist.js' +import { getServerActor } from '@server/models/application/application.js' +import { ServerModel } from '@server/models/server/server.js' +import { ServerBlocklistModel } from '@server/models/server/server-blocklist.js' +import { UserModel } from '@server/models/user/user.js' +import { VideoModel } from '@server/models/video/video.js' +import { VideoBlacklistModel } from '@server/models/video/video-blacklist.js' +import { MPlugin, MVideo, UserNotificationModelForApi } from '@server/types/models/index.js' +import { PeerTubeHelpers } from '@server/types/plugins/index.js' +import { ffprobePromise } from '@peertube/peertube-ffmpeg' +import { VideoBlacklistCreate, VideoStorage } from '@peertube/peertube-models' +import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../blocklist.js' +import { PeerTubeSocket } from '../peertube-socket.js' +import { ServerConfigManager } from '../server-config-manager.js' +import { blacklistVideo, unblacklistVideo } from '../video-blacklist.js' +import { VideoPathManager } from '../video-path-manager.js' function buildPluginHelpers (httpServer: Server, pluginModel: MPlugin, npmName: string): PeerTubeHelpers { const logger = buildPluginLogger(npmName) diff --git a/server/lib/plugins/plugin-index.ts b/server/server/lib/plugins/plugin-index.ts similarity index 85% rename from server/lib/plugins/plugin-index.ts rename to server/server/lib/plugins/plugin-index.ts index 119cee8e0..0f436f6b8 100644 --- a/server/lib/plugins/plugin-index.ts +++ b/server/server/lib/plugins/plugin-index.ts @@ -1,17 +1,17 @@ -import { sanitizeUrl } from '@server/helpers/core-utils' -import { logger } from '@server/helpers/logger' -import { doJSONRequest } from '@server/helpers/requests' -import { CONFIG } from '@server/initializers/config' -import { PEERTUBE_VERSION } from '@server/initializers/constants' -import { PluginModel } from '@server/models/server/plugin' +import { sanitizeUrl } from '@server/helpers/core-utils.js' +import { logger } from '@server/helpers/logger.js' +import { doJSONRequest } from '@server/helpers/requests.js' +import { CONFIG } from '@server/initializers/config.js' +import { PEERTUBE_VERSION } from '@server/initializers/constants.js' +import { PluginModel } from '@server/models/server/plugin.js' import { PeerTubePluginIndex, PeertubePluginIndexList, PeertubePluginLatestVersionRequest, PeertubePluginLatestVersionResponse, ResultList -} from '@shared/models' -import { PluginManager } from './plugin-manager' +} from '@peertube/peertube-models' +import { PluginManager } from './plugin-manager.js' async function listAvailablePluginsFromIndex (options: PeertubePluginIndexList) { const { start = 0, count = 20, search, sort = 'npmName', pluginType } = options diff --git a/server/lib/plugins/plugin-manager.ts b/server/server/lib/plugins/plugin-manager.ts similarity index 94% rename from server/lib/plugins/plugin-manager.ts rename to server/server/lib/plugins/plugin-manager.ts index 88c5b60d7..c4b4fae43 100644 --- a/server/lib/plugins/plugin-manager.ts +++ b/server/server/lib/plugins/plugin-manager.ts @@ -1,31 +1,40 @@ import express from 'express' import { createReadStream, createWriteStream } from 'fs' -import { ensureDir, outputFile, readJSON } from 'fs-extra' +import { ensureDir, outputFile, readJSON } from 'fs-extra/esm' import { Server } from 'http' +import { createRequire } from 'module' import { basename, join } from 'path' -import { decachePlugin } from '@server/helpers/decache' -import { ApplicationModel } from '@server/models/application/application' -import { MOAuthTokenUser, MUser } from '@server/types/models' -import { getCompleteLocale } from '@shared/core-utils' +import { getCompleteLocale, getHookType, internalRunHook } from '@peertube/peertube-core-utils' import { ClientScriptJSON, PluginPackageJSON, PluginTranslation, PluginTranslationPathsJSON, - RegisterServerHookOptions -} from '@shared/models' -import { getHookType, internalRunHook } from '../../../shared/core-utils/plugins/hooks' -import { PluginType } from '../../../shared/models/plugins/plugin.type' -import { ServerHook, ServerHookName } from '../../../shared/models/plugins/server/server-hook.model' -import { isLibraryCodeValid, isPackageJSONValid } from '../../helpers/custom-validators/plugins' -import { logger } from '../../helpers/logger' -import { CONFIG } from '../../initializers/config' -import { PLUGIN_GLOBAL_CSS_PATH } from '../../initializers/constants' -import { PluginModel } from '../../models/server/plugin' -import { PluginLibrary, RegisterServerAuthExternalOptions, RegisterServerAuthPassOptions, RegisterServerOptions } from '../../types/plugins' -import { ClientHtml } from '../client-html' -import { RegisterHelpers } from './register-helpers' -import { installNpmPlugin, installNpmPluginFromDisk, rebuildNativePlugins, removeNpmPlugin } from './yarn' + PluginType, + PluginType_Type, + RegisterServerHookOptions, + ServerHook, + ServerHookName +} from '@peertube/peertube-models' +import { decachePlugin } from '@server/helpers/decache.js' +import { ApplicationModel } from '@server/models/application/application.js' +import { MOAuthTokenUser, MUser } from '@server/types/models/index.js' +import { isLibraryCodeValid, isPackageJSONValid } from '../../helpers/custom-validators/plugins.js' +import { logger } from '../../helpers/logger.js' +import { CONFIG } from '../../initializers/config.js' +import { PLUGIN_GLOBAL_CSS_PATH } from '../../initializers/constants.js' +import { PluginModel } from '../../models/server/plugin.js' +import { + PluginLibrary, + RegisterServerAuthExternalOptions, + RegisterServerAuthPassOptions, + RegisterServerOptions +} from '../../types/plugins/index.js' +import { ClientHtml } from '../client-html.js' +import { RegisterHelpers } from './register-helpers.js' +import { installNpmPlugin, installNpmPluginFromDisk, rebuildNativePlugins, removeNpmPlugin } from './yarn.js' + +const require = createRequire(import.meta.url) export interface RegisteredPlugin { npmName: string @@ -34,7 +43,7 @@ export interface RegisteredPlugin { description: string peertubeEngine: string - type: PluginType + type: PluginType_Type path: string @@ -496,7 +505,7 @@ export class PluginManager implements ServerHook { // Delete cache if needed const modulePath = join(pluginPath, packageJSON.library) - decachePlugin(modulePath) + decachePlugin(require, modulePath) const library: PluginLibrary = require(modulePath) if (!isLibraryCodeValid(library)) { @@ -582,13 +591,13 @@ export class PluginManager implements ServerHook { } } - private getPackageJSON (pluginName: string, pluginType: PluginType) { + private getPackageJSON (pluginName: string, pluginType: PluginType_Type) { const pluginPath = join(this.getPluginPath(pluginName, pluginType), 'package.json') return readJSON(pluginPath) as Promise } - private getPluginPath (pluginName: string, pluginType: PluginType) { + private getPluginPath (pluginName: string, pluginType: PluginType_Type) { const npmName = PluginModel.buildNpmName(pluginName, pluginType) return join(CONFIG.STORAGE.PLUGINS_DIR, 'node_modules', npmName) @@ -606,7 +615,7 @@ export class PluginManager implements ServerHook { // ###################### Private getters ###################### - private getRegisteredPluginsOrThemes (type: PluginType) { + private getRegisteredPluginsOrThemes (type: PluginType_Type) { const plugins: RegisteredPlugin[] = [] for (const npmName of Object.keys(this.registeredPlugins)) { @@ -644,7 +653,7 @@ export class PluginManager implements ServerHook { } } - private sanitizeAndCheckPackageJSONOrThrow (packageJSON: PluginPackageJSON, pluginType: PluginType) { + private sanitizeAndCheckPackageJSONOrThrow (packageJSON: PluginPackageJSON, pluginType: PluginType_Type) { if (!packageJSON.staticDirs) packageJSON.staticDirs = {} if (!packageJSON.css) packageJSON.css = [] if (!packageJSON.clientScripts) packageJSON.clientScripts = [] diff --git a/server/lib/plugins/register-helpers.ts b/server/server/lib/plugins/register-helpers.ts similarity index 95% rename from server/lib/plugins/register-helpers.ts rename to server/server/lib/plugins/register-helpers.ts index 1aaef3606..7c44bff88 100644 --- a/server/lib/plugins/register-helpers.ts +++ b/server/server/lib/plugins/register-helpers.ts @@ -1,17 +1,5 @@ import express from 'express' import { Server } from 'http' -import { logger } from '@server/helpers/logger' -import { onExternalUserAuthenticated } from '@server/lib/auth/external-auth' -import { VideoConstantManagerFactory } from '@server/lib/plugins/video-constant-manager-factory' -import { PluginModel } from '@server/models/server/plugin' -import { - RegisterServerAuthExternalOptions, - RegisterServerAuthExternalResult, - RegisterServerAuthPassOptions, - RegisterServerExternalAuthenticatedResult, - RegisterServerOptions, - RegisterServerWebSocketRouteOptions -} from '@server/types/plugins' import { EncoderOptionsBuilder, PluginSettingsManager, @@ -20,11 +8,23 @@ import { RegisterServerSettingOptions, serverHookObject, SettingsChangeCallback, - VideoPlaylistPrivacy, - VideoPrivacy -} from '@shared/models' -import { VideoTranscodingProfilesManager } from '../transcoding/default-transcoding-profiles' -import { buildPluginHelpers } from './plugin-helpers-builder' + VideoPlaylistPrivacyType, + VideoPrivacyType +} from '@peertube/peertube-models' +import { logger } from '@server/helpers/logger.js' +import { onExternalUserAuthenticated } from '@server/lib/auth/external-auth.js' +import { VideoConstantManagerFactory } from '@server/lib/plugins/video-constant-manager-factory.js' +import { PluginModel } from '@server/models/server/plugin.js' +import { + RegisterServerAuthExternalOptions, + RegisterServerAuthExternalResult, + RegisterServerAuthPassOptions, + RegisterServerExternalAuthenticatedResult, + RegisterServerOptions, + RegisterServerWebSocketRouteOptions +} from '@server/types/plugins/index.js' +import { VideoTranscodingProfilesManager } from '../transcoding/default-transcoding-profiles.js' +import { buildPluginHelpers } from './plugin-helpers-builder.js' export class RegisterHelpers { private readonly transcodingProfiles: { @@ -81,8 +81,8 @@ export class RegisterHelpers { const videoLicenceManager = this.videoConstantManagerFactory.createVideoConstantManager('licence') const videoCategoryManager = this.videoConstantManagerFactory.createVideoConstantManager('category') - const videoPrivacyManager = this.videoConstantManagerFactory.createVideoConstantManager('privacy') - const playlistPrivacyManager = this.videoConstantManagerFactory.createVideoConstantManager('playlistPrivacy') + const videoPrivacyManager = this.videoConstantManagerFactory.createVideoConstantManager('privacy') + const playlistPrivacyManager = this.videoConstantManagerFactory.createVideoConstantManager('playlistPrivacy') const transcodingManager = this.buildTranscodingManager() diff --git a/server/lib/plugins/theme-utils.ts b/server/server/lib/plugins/theme-utils.ts similarity index 82% rename from server/lib/plugins/theme-utils.ts rename to server/server/lib/plugins/theme-utils.ts index 76c671f1c..4a64a579a 100644 --- a/server/lib/plugins/theme-utils.ts +++ b/server/server/lib/plugins/theme-utils.ts @@ -1,6 +1,6 @@ -import { DEFAULT_THEME_NAME, DEFAULT_USER_THEME_NAME } from '../../initializers/constants' -import { PluginManager } from './plugin-manager' -import { CONFIG } from '../../initializers/config' +import { DEFAULT_THEME_NAME, DEFAULT_USER_THEME_NAME } from '../../initializers/constants.js' +import { PluginManager } from './plugin-manager.js' +import { CONFIG } from '../../initializers/config.js' function getThemeOrDefault (name: string, defaultTheme: string) { if (isThemeRegistered(name)) return name diff --git a/server/lib/plugins/video-constant-manager-factory.ts b/server/server/lib/plugins/video-constant-manager-factory.ts similarity index 95% rename from server/lib/plugins/video-constant-manager-factory.ts rename to server/server/lib/plugins/video-constant-manager-factory.ts index 5f7edfbe2..04c30cf69 100644 --- a/server/lib/plugins/video-constant-manager-factory.ts +++ b/server/server/lib/plugins/video-constant-manager-factory.ts @@ -1,12 +1,12 @@ -import { logger } from '@server/helpers/logger' +import { ConstantManager } from '@peertube/peertube-models' +import { logger } from '@server/helpers/logger.js' import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PLAYLIST_PRIVACIES, VIDEO_PRIVACIES -} from '@server/initializers/constants' -import { ConstantManager } from '@shared/models/plugins/server/plugin-constant-manager.model' +} from '@server/initializers/constants.js' type AlterableVideoConstant = 'language' | 'licence' | 'category' | 'privacy' | 'playlistPrivacy' type VideoConstant = Record diff --git a/server/lib/plugins/yarn.ts b/server/server/lib/plugins/yarn.ts similarity index 85% rename from server/lib/plugins/yarn.ts rename to server/server/lib/plugins/yarn.ts index 9cf6ec9e9..470880f44 100644 --- a/server/lib/plugins/yarn.ts +++ b/server/server/lib/plugins/yarn.ts @@ -1,10 +1,10 @@ -import { outputJSON, pathExists } from 'fs-extra' +import { outputJSON, pathExists } from 'fs-extra/esm' import { join } from 'path' -import { execShell } from '../../helpers/core-utils' -import { isNpmPluginNameValid, isPluginStableOrUnstableVersionValid } from '../../helpers/custom-validators/plugins' -import { logger } from '../../helpers/logger' -import { CONFIG } from '../../initializers/config' -import { getLatestPluginVersion } from './plugin-index' +import { execShell } from '../../helpers/core-utils.js' +import { isNpmPluginNameValid, isPluginStableOrUnstableVersionValid } from '../../helpers/custom-validators/plugins.js' +import { logger } from '../../helpers/logger.js' +import { CONFIG } from '../../initializers/config.js' +import { getLatestPluginVersion } from './plugin-index.js' async function installNpmPlugin (npmName: string, versionArg?: string) { // Security check diff --git a/server/lib/redis.ts b/server/server/lib/redis.ts similarity index 97% rename from server/lib/redis.ts rename to server/server/lib/redis.ts index 48d9986b5..7c87bf2e3 100644 --- a/server/lib/redis.ts +++ b/server/server/lib/redis.ts @@ -1,20 +1,20 @@ -import IoRedis, { RedisOptions } from 'ioredis' -import { exists } from '@server/helpers/custom-validators/misc' -import { sha256 } from '@shared/extra-utils' -import { logger } from '../helpers/logger' -import { generateRandomString } from '../helpers/utils' -import { CONFIG } from '../initializers/config' +import { Redis as IoRedis, RedisOptions } from 'ioredis' +import { exists } from '@server/helpers/custom-validators/misc.js' +import { sha256 } from '@peertube/peertube-node-utils' +import { logger } from '../helpers/logger.js' +import { generateRandomString } from '../helpers/utils.js' +import { CONFIG } from '../initializers/config.js' import { AP_CLEANER, CONTACT_FORM_LIFETIME, + EMAIL_VERIFY_LIFETIME, RESUMABLE_UPLOAD_SESSION_LIFETIME, TWO_FACTOR_AUTH_REQUEST_TOKEN_LIFETIME, - EMAIL_VERIFY_LIFETIME, USER_PASSWORD_CREATE_LIFETIME, USER_PASSWORD_RESET_LIFETIME, VIEW_LIFETIME, WEBSERVER -} from '../initializers/constants' +} from '../initializers/constants.js' class Redis { diff --git a/server/lib/redundancy.ts b/server/server/lib/redundancy.ts similarity index 88% rename from server/lib/redundancy.ts rename to server/server/lib/redundancy.ts index 2613d01be..b470373ce 100644 --- a/server/lib/redundancy.ts +++ b/server/server/lib/redundancy.ts @@ -1,12 +1,12 @@ import { Transaction } from 'sequelize' -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { CONFIG } from '@server/initializers/config' -import { ActorFollowModel } from '@server/models/actor/actor-follow' -import { getServerActor } from '@server/models/application/application' -import { MActorSignature, MVideoRedundancyVideo } from '@server/types/models' -import { Activity } from '@shared/models' -import { VideoRedundancyModel } from '../models/redundancy/video-redundancy' -import { sendUndoCacheFile } from './activitypub/send' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { CONFIG } from '@server/initializers/config.js' +import { ActorFollowModel } from '@server/models/actor/actor-follow.js' +import { getServerActor } from '@server/models/application/application.js' +import { MActorSignature, MVideoRedundancyVideo } from '@server/types/models/index.js' +import { Activity } from '@peertube/peertube-models' +import { VideoRedundancyModel } from '../models/redundancy/video-redundancy.js' +import { sendUndoCacheFile } from './activitypub/send/index.js' const lTags = loggerTagsFactory('redundancy') diff --git a/server/server/lib/runners/index.ts b/server/server/lib/runners/index.ts new file mode 100644 index 000000000..43eb7351e --- /dev/null +++ b/server/server/lib/runners/index.ts @@ -0,0 +1,3 @@ +export * from './job-handlers/index.js' +export * from './runner.js' +export * from './runner-urls.js' diff --git a/server/lib/runners/job-handlers/abstract-job-handler.ts b/server/server/lib/runners/job-handlers/abstract-job-handler.ts similarity index 93% rename from server/lib/runners/job-handlers/abstract-job-handler.ts rename to server/server/lib/runners/job-handlers/abstract-job-handler.ts index 329977de1..b7e9a0a9d 100644 --- a/server/lib/runners/job-handlers/abstract-job-handler.ts +++ b/server/server/lib/runners/job-handlers/abstract-job-handler.ts @@ -1,29 +1,30 @@ -import { throttle } from 'lodash' -import { saveInTransactionWithRetries } from '@server/helpers/database-utils' -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { RUNNER_JOBS } from '@server/initializers/constants' -import { sequelizeTypescript } from '@server/initializers/database' -import { PeerTubeSocket } from '@server/lib/peertube-socket' -import { RunnerJobModel } from '@server/models/runner/runner-job' -import { setAsUpdated } from '@server/models/shared' -import { MRunnerJob } from '@server/types/models/runners' -import { pick } from '@shared/core-utils' +import { pick } from '@peertube/peertube-core-utils' import { RunnerJobLiveRTMPHLSTranscodingPayload, RunnerJobLiveRTMPHLSTranscodingPrivatePayload, RunnerJobState, + RunnerJobStateType, RunnerJobStudioTranscodingPayload, RunnerJobSuccessPayload, RunnerJobType, RunnerJobUpdatePayload, - RunnerJobVideoStudioTranscodingPrivatePayload, RunnerJobVODAudioMergeTranscodingPayload, RunnerJobVODAudioMergeTranscodingPrivatePayload, RunnerJobVODHLSTranscodingPayload, RunnerJobVODHLSTranscodingPrivatePayload, RunnerJobVODWebVideoTranscodingPayload, - RunnerJobVODWebVideoTranscodingPrivatePayload -} from '@shared/models' + RunnerJobVODWebVideoTranscodingPrivatePayload, + RunnerJobVideoStudioTranscodingPrivatePayload +} from '@peertube/peertube-models' +import { saveInTransactionWithRetries } from '@server/helpers/database-utils.js' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { RUNNER_JOBS } from '@server/initializers/constants.js' +import { sequelizeTypescript } from '@server/initializers/database.js' +import { PeerTubeSocket } from '@server/lib/peertube-socket.js' +import { RunnerJobModel } from '@server/models/runner/runner-job.js' +import { setAsUpdated } from '@server/models/shared/index.js' +import { MRunnerJob } from '@server/types/models/runners/index.js' +import throttle from 'lodash-es/throttle.js' type CreateRunnerJobArg = { @@ -264,6 +265,6 @@ export abstract class AbstractJobHandler | void } diff --git a/server/lib/runners/job-handlers/abstract-vod-transcoding-job-handler.ts b/server/server/lib/runners/job-handlers/abstract-vod-transcoding-job-handler.ts similarity index 78% rename from server/lib/runners/job-handlers/abstract-vod-transcoding-job-handler.ts rename to server/server/lib/runners/job-handlers/abstract-vod-transcoding-job-handler.ts index f425828d9..392ff9aec 100644 --- a/server/lib/runners/job-handlers/abstract-vod-transcoding-job-handler.ts +++ b/server/server/lib/runners/job-handlers/abstract-vod-transcoding-job-handler.ts @@ -1,12 +1,18 @@ -import { retryTransactionWrapper } from '@server/helpers/database-utils' -import { logger } from '@server/helpers/logger' -import { moveToFailedTranscodingState, moveToNextState } from '@server/lib/video-state' -import { VideoJobInfoModel } from '@server/models/video/video-job-info' -import { MRunnerJob } from '@server/types/models/runners' -import { RunnerJobState, RunnerJobSuccessPayload, RunnerJobUpdatePayload, RunnerJobVODPrivatePayload } from '@shared/models' -import { AbstractJobHandler } from './abstract-job-handler' -import { loadTranscodingRunnerVideo } from './shared' +import { + RunnerJobState, + RunnerJobStateType, + RunnerJobSuccessPayload, + RunnerJobUpdatePayload, + RunnerJobVODPrivatePayload +} from '@peertube/peertube-models' +import { retryTransactionWrapper } from '@server/helpers/database-utils.js' +import { logger } from '@server/helpers/logger.js' +import { moveToFailedTranscodingState, moveToNextState } from '@server/lib/video-state.js' +import { VideoJobInfoModel } from '@server/models/video/video-job-info.js' +import { MRunnerJob } from '@server/types/models/runners/index.js' +import { AbstractJobHandler } from './abstract-job-handler.js' +import { loadTranscodingRunnerVideo } from './shared/index.js' // eslint-disable-next-line max-len export abstract class AbstractVODTranscodingJobHandler extends AbstractJobHandler { @@ -29,7 +35,7 @@ export abstract class AbstractVODTranscodingJobHandler AbstractJobHandler> = { 'vod-web-video-transcoding': VODWebVideoTranscodingJobHandler, diff --git a/server/server/lib/runners/job-handlers/shared/index.ts b/server/server/lib/runners/job-handlers/shared/index.ts new file mode 100644 index 000000000..bec61e3a0 --- /dev/null +++ b/server/server/lib/runners/job-handlers/shared/index.ts @@ -0,0 +1 @@ +export * from './vod-helpers.js' diff --git a/server/lib/runners/job-handlers/shared/vod-helpers.ts b/server/server/lib/runners/job-handlers/shared/vod-helpers.ts similarity index 74% rename from server/lib/runners/job-handlers/shared/vod-helpers.ts rename to server/server/lib/runners/job-handlers/shared/vod-helpers.ts index 1a2ad02ca..f7c1b73c9 100644 --- a/server/lib/runners/job-handlers/shared/vod-helpers.ts +++ b/server/server/lib/runners/job-handlers/shared/vod-helpers.ts @@ -1,13 +1,13 @@ -import { move } from 'fs-extra' +import { move } from 'fs-extra/esm' import { dirname, join } from 'path' -import { logger, LoggerTagsFn } from '@server/helpers/logger' -import { onTranscodingEnded } from '@server/lib/transcoding/ended-transcoding' -import { onWebVideoFileTranscoding } from '@server/lib/transcoding/web-transcoding' -import { buildNewFile } from '@server/lib/video-file' -import { VideoModel } from '@server/models/video/video' -import { MVideoFullLight } from '@server/types/models' -import { MRunnerJob } from '@server/types/models/runners' -import { RunnerJobVODAudioMergeTranscodingPrivatePayload, RunnerJobVODWebVideoTranscodingPrivatePayload } from '@shared/models' +import { logger, LoggerTagsFn } from '@server/helpers/logger.js' +import { onTranscodingEnded } from '@server/lib/transcoding/ended-transcoding.js' +import { onWebVideoFileTranscoding } from '@server/lib/transcoding/web-transcoding.js' +import { buildNewFile } from '@server/lib/video-file.js' +import { VideoModel } from '@server/models/video/video.js' +import { MVideoFullLight } from '@server/types/models/index.js' +import { MRunnerJob } from '@server/types/models/runners/index.js' +import { RunnerJobVODAudioMergeTranscodingPrivatePayload, RunnerJobVODWebVideoTranscodingPrivatePayload } from '@peertube/peertube-models' export async function onVODWebVideoOrAudioMergeTranscodingJob (options: { video: MVideoFullLight diff --git a/server/lib/runners/job-handlers/video-studio-transcoding-job-handler.ts b/server/server/lib/runners/job-handlers/video-studio-transcoding-job-handler.ts similarity index 86% rename from server/lib/runners/job-handlers/video-studio-transcoding-job-handler.ts rename to server/server/lib/runners/job-handlers/video-studio-transcoding-job-handler.ts index f604382b7..952e3a3c6 100644 --- a/server/lib/runners/job-handlers/video-studio-transcoding-job-handler.ts +++ b/server/server/lib/runners/job-handlers/video-studio-transcoding-job-handler.ts @@ -1,25 +1,26 @@ -import { basename } from 'path' -import { logger } from '@server/helpers/logger' -import { onVideoStudioEnded, safeCleanupStudioTMPFiles } from '@server/lib/video-studio' -import { MVideo } from '@server/types/models' -import { MRunnerJob } from '@server/types/models/runners' -import { buildUUID } from '@shared/extra-utils' import { + RunnerJobState, + RunnerJobStateType, + RunnerJobStudioTranscodingPayload, + RunnerJobUpdatePayload, + RunnerJobVideoStudioTranscodingPrivatePayload, + VideoState, + VideoStudioTaskPayload, + VideoStudioTranscodingSuccess, isVideoStudioTaskIntro, isVideoStudioTaskOutro, - isVideoStudioTaskWatermark, - RunnerJobState, - RunnerJobUpdatePayload, - RunnerJobStudioTranscodingPayload, - RunnerJobVideoStudioTranscodingPrivatePayload, - VideoStudioTranscodingSuccess, - VideoState, - VideoStudioTaskPayload -} from '@shared/models' -import { generateRunnerEditionTranscodingVideoInputFileUrl, generateRunnerTranscodingVideoInputFileUrl } from '../runner-urls' -import { AbstractJobHandler } from './abstract-job-handler' -import { loadTranscodingRunnerVideo } from './shared' + isVideoStudioTaskWatermark +} from '@peertube/peertube-models' +import { buildUUID } from '@peertube/peertube-node-utils' +import { logger } from '@server/helpers/logger.js' +import { onVideoStudioEnded, safeCleanupStudioTMPFiles } from '@server/lib/video-studio.js' +import { MVideo } from '@server/types/models/index.js' +import { MRunnerJob } from '@server/types/models/runners/index.js' +import { basename } from 'path' +import { generateRunnerEditionTranscodingVideoInputFileUrl, generateRunnerTranscodingVideoInputFileUrl } from '../runner-urls.js' +import { AbstractJobHandler } from './abstract-job-handler.js' +import { loadTranscodingRunnerVideo } from './shared/index.js' type CreateOptions = { video: MVideo @@ -126,7 +127,7 @@ export class VideoStudioTranscodingJobHandler extends AbstractJobHandler([ + const allowedStates = new Set([ RunnerJobState.PENDING, RunnerJobState.PROCESSING, RunnerJobState.WAITING_FOR_PARENT_JOB diff --git a/server/lib/schedulers/abstract-scheduler.ts b/server/server/lib/schedulers/abstract-scheduler.ts similarity index 94% rename from server/lib/schedulers/abstract-scheduler.ts rename to server/server/lib/schedulers/abstract-scheduler.ts index f3d51a22e..8b6eef3f4 100644 --- a/server/lib/schedulers/abstract-scheduler.ts +++ b/server/server/lib/schedulers/abstract-scheduler.ts @@ -1,5 +1,5 @@ import Bluebird from 'bluebird' -import { logger } from '../../helpers/logger' +import { logger } from '../../helpers/logger.js' export abstract class AbstractScheduler { diff --git a/server/lib/schedulers/actor-follow-scheduler.ts b/server/server/lib/schedulers/actor-follow-scheduler.ts similarity index 88% rename from server/lib/schedulers/actor-follow-scheduler.ts rename to server/server/lib/schedulers/actor-follow-scheduler.ts index e1c56c135..86b83f60b 100644 --- a/server/lib/schedulers/actor-follow-scheduler.ts +++ b/server/server/lib/schedulers/actor-follow-scheduler.ts @@ -1,9 +1,9 @@ -import { isTestOrDevInstance } from '../../helpers/core-utils' -import { logger } from '../../helpers/logger' -import { ACTOR_FOLLOW_SCORE, SCHEDULER_INTERVALS_MS } from '../../initializers/constants' -import { ActorFollowModel } from '../../models/actor/actor-follow' -import { ActorFollowHealthCache } from '../actor-follow-health-cache' -import { AbstractScheduler } from './abstract-scheduler' +import { isTestOrDevInstance } from '@peertube/peertube-node-utils' +import { logger } from '../../helpers/logger.js' +import { ACTOR_FOLLOW_SCORE, SCHEDULER_INTERVALS_MS } from '../../initializers/constants.js' +import { ActorFollowModel } from '../../models/actor/actor-follow.js' +import { ActorFollowHealthCache } from '../actor-follow-health-cache.js' +import { AbstractScheduler } from './abstract-scheduler.js' export class ActorFollowScheduler extends AbstractScheduler { diff --git a/server/lib/schedulers/auto-follow-index-instances.ts b/server/server/lib/schedulers/auto-follow-index-instances.ts similarity index 84% rename from server/lib/schedulers/auto-follow-index-instances.ts rename to server/server/lib/schedulers/auto-follow-index-instances.ts index 956ece749..47a01ec0c 100644 --- a/server/lib/schedulers/auto-follow-index-instances.ts +++ b/server/server/lib/schedulers/auto-follow-index-instances.ts @@ -1,12 +1,12 @@ -import { chunk } from 'lodash' -import { doJSONRequest } from '@server/helpers/requests' -import { JobQueue } from '@server/lib/job-queue' -import { ActorFollowModel } from '@server/models/actor/actor-follow' -import { getServerActor } from '@server/models/application/application' -import { logger } from '../../helpers/logger' -import { CONFIG } from '../../initializers/config' -import { SCHEDULER_INTERVALS_MS, SERVER_ACTOR_NAME } from '../../initializers/constants' -import { AbstractScheduler } from './abstract-scheduler' +import { doJSONRequest } from '@server/helpers/requests.js' +import { JobQueue } from '@server/lib/job-queue/index.js' +import { ActorFollowModel } from '@server/models/actor/actor-follow.js' +import { getServerActor } from '@server/models/application/application.js' +import chunk from 'lodash-es/chunk.js' +import { logger } from '../../helpers/logger.js' +import { CONFIG } from '../../initializers/config.js' +import { SCHEDULER_INTERVALS_MS, SERVER_ACTOR_NAME } from '../../initializers/constants.js' +import { AbstractScheduler } from './abstract-scheduler.js' export class AutoFollowIndexInstances extends AbstractScheduler { diff --git a/server/lib/schedulers/geo-ip-update-scheduler.ts b/server/server/lib/schedulers/geo-ip-update-scheduler.ts similarity index 79% rename from server/lib/schedulers/geo-ip-update-scheduler.ts rename to server/server/lib/schedulers/geo-ip-update-scheduler.ts index b06f5a9b5..b59aa71e5 100644 --- a/server/lib/schedulers/geo-ip-update-scheduler.ts +++ b/server/server/lib/schedulers/geo-ip-update-scheduler.ts @@ -1,6 +1,6 @@ -import { GeoIP } from '@server/helpers/geo-ip' -import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' -import { AbstractScheduler } from './abstract-scheduler' +import { GeoIP } from '@server/helpers/geo-ip.js' +import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants.js' +import { AbstractScheduler } from './abstract-scheduler.js' export class GeoIPUpdateScheduler extends AbstractScheduler { diff --git a/server/lib/schedulers/peertube-version-check-scheduler.ts b/server/server/lib/schedulers/peertube-version-check-scheduler.ts similarity index 76% rename from server/lib/schedulers/peertube-version-check-scheduler.ts rename to server/server/lib/schedulers/peertube-version-check-scheduler.ts index bc38ed49f..c706aba63 100644 --- a/server/lib/schedulers/peertube-version-check-scheduler.ts +++ b/server/server/lib/schedulers/peertube-version-check-scheduler.ts @@ -1,13 +1,13 @@ -import { doJSONRequest } from '@server/helpers/requests' -import { ApplicationModel } from '@server/models/application/application' -import { compareSemVer } from '@shared/core-utils' -import { JoinPeerTubeVersions } from '@shared/models' -import { logger } from '../../helpers/logger' -import { CONFIG } from '../../initializers/config' -import { PEERTUBE_VERSION, SCHEDULER_INTERVALS_MS } from '../../initializers/constants' -import { Notifier } from '../notifier' -import { AbstractScheduler } from './abstract-scheduler' +import { doJSONRequest } from '@server/helpers/requests.js' +import { ApplicationModel } from '@server/models/application/application.js' +import { compareSemVer } from '@peertube/peertube-core-utils' +import { JoinPeerTubeVersions } from '@peertube/peertube-models' +import { logger } from '../../helpers/logger.js' +import { CONFIG } from '../../initializers/config.js' +import { PEERTUBE_VERSION, SCHEDULER_INTERVALS_MS } from '../../initializers/constants.js' +import { Notifier } from '../notifier/index.js' +import { AbstractScheduler } from './abstract-scheduler.js' export class PeerTubeVersionCheckScheduler extends AbstractScheduler { diff --git a/server/lib/schedulers/plugins-check-scheduler.ts b/server/server/lib/schedulers/plugins-check-scheduler.ts similarity index 84% rename from server/lib/schedulers/plugins-check-scheduler.ts rename to server/server/lib/schedulers/plugins-check-scheduler.ts index 820c01693..627289663 100644 --- a/server/lib/schedulers/plugins-check-scheduler.ts +++ b/server/server/lib/schedulers/plugins-check-scheduler.ts @@ -1,12 +1,12 @@ -import { chunk } from 'lodash' -import { compareSemVer } from '@shared/core-utils' -import { logger } from '../../helpers/logger' -import { CONFIG } from '../../initializers/config' -import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' -import { PluginModel } from '../../models/server/plugin' -import { Notifier } from '../notifier' -import { getLatestPluginsVersion } from '../plugins/plugin-index' -import { AbstractScheduler } from './abstract-scheduler' +import { compareSemVer } from '@peertube/peertube-core-utils' +import chunk from 'lodash-es/chunk.js' +import { logger } from '../../helpers/logger.js' +import { CONFIG } from '../../initializers/config.js' +import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants.js' +import { PluginModel } from '../../models/server/plugin.js' +import { Notifier } from '../notifier/index.js' +import { getLatestPluginsVersion } from '../plugins/plugin-index.js' +import { AbstractScheduler } from './abstract-scheduler.js' export class PluginsCheckScheduler extends AbstractScheduler { diff --git a/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts b/server/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts similarity index 90% rename from server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts rename to server/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts index 61e93eafa..6d5e70b08 100644 --- a/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts +++ b/server/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts @@ -1,8 +1,8 @@ -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { SCHEDULER_INTERVALS_MS } from '@server/initializers/constants' -import { uploadx } from '../uploadx' -import { AbstractScheduler } from './abstract-scheduler' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { SCHEDULER_INTERVALS_MS } from '@server/initializers/constants.js' +import { uploadx } from '../uploadx.js' +import { AbstractScheduler } from './abstract-scheduler.js' const lTags = loggerTagsFactory('scheduler', 'resumable-upload', 'cleaner') diff --git a/server/lib/schedulers/remove-old-history-scheduler.ts b/server/server/lib/schedulers/remove-old-history-scheduler.ts similarity index 80% rename from server/lib/schedulers/remove-old-history-scheduler.ts rename to server/server/lib/schedulers/remove-old-history-scheduler.ts index 34b160799..3a557ae97 100644 --- a/server/lib/schedulers/remove-old-history-scheduler.ts +++ b/server/server/lib/schedulers/remove-old-history-scheduler.ts @@ -1,8 +1,8 @@ -import { logger } from '../../helpers/logger' -import { AbstractScheduler } from './abstract-scheduler' -import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' -import { UserVideoHistoryModel } from '../../models/user/user-video-history' -import { CONFIG } from '../../initializers/config' +import { logger } from '../../helpers/logger.js' +import { AbstractScheduler } from './abstract-scheduler.js' +import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants.js' +import { UserVideoHistoryModel } from '../../models/user/user-video-history.js' +import { CONFIG } from '../../initializers/config.js' export class RemoveOldHistoryScheduler extends AbstractScheduler { diff --git a/server/lib/schedulers/remove-old-views-scheduler.ts b/server/server/lib/schedulers/remove-old-views-scheduler.ts similarity index 75% rename from server/lib/schedulers/remove-old-views-scheduler.ts rename to server/server/lib/schedulers/remove-old-views-scheduler.ts index 8bc53a045..7bd28b17b 100644 --- a/server/lib/schedulers/remove-old-views-scheduler.ts +++ b/server/server/lib/schedulers/remove-old-views-scheduler.ts @@ -1,8 +1,8 @@ -import { VideoViewModel } from '@server/models/view/video-view' -import { logger } from '../../helpers/logger' -import { CONFIG } from '../../initializers/config' -import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' -import { AbstractScheduler } from './abstract-scheduler' +import { VideoViewModel } from '@server/models/view/video-view.js' +import { logger } from '../../helpers/logger.js' +import { CONFIG } from '../../initializers/config.js' +import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants.js' +import { AbstractScheduler } from './abstract-scheduler.js' export class RemoveOldViewsScheduler extends AbstractScheduler { diff --git a/server/lib/schedulers/runner-job-watch-dog-scheduler.ts b/server/server/lib/schedulers/runner-job-watch-dog-scheduler.ts similarity index 82% rename from server/lib/schedulers/runner-job-watch-dog-scheduler.ts rename to server/server/lib/schedulers/runner-job-watch-dog-scheduler.ts index f7a26d2bc..941e79c3e 100644 --- a/server/lib/schedulers/runner-job-watch-dog-scheduler.ts +++ b/server/server/lib/schedulers/runner-job-watch-dog-scheduler.ts @@ -1,9 +1,9 @@ -import { CONFIG } from '@server/initializers/config' -import { RunnerJobModel } from '@server/models/runner/runner-job' -import { logger, loggerTagsFactory } from '../../helpers/logger' -import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' -import { getRunnerJobHandlerClass } from '../runners' -import { AbstractScheduler } from './abstract-scheduler' +import { CONFIG } from '@server/initializers/config.js' +import { RunnerJobModel } from '@server/models/runner/runner-job.js' +import { logger, loggerTagsFactory } from '../../helpers/logger.js' +import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants.js' +import { getRunnerJobHandlerClass } from '../runners/index.js' +import { AbstractScheduler } from './abstract-scheduler.js' const lTags = loggerTagsFactory('runner') diff --git a/server/lib/schedulers/update-videos-scheduler.ts b/server/server/lib/schedulers/update-videos-scheduler.ts similarity index 78% rename from server/lib/schedulers/update-videos-scheduler.ts rename to server/server/lib/schedulers/update-videos-scheduler.ts index e38685c04..2d4892013 100644 --- a/server/lib/schedulers/update-videos-scheduler.ts +++ b/server/server/lib/schedulers/update-videos-scheduler.ts @@ -1,15 +1,15 @@ -import { VideoModel } from '@server/models/video/video' -import { MScheduleVideoUpdate } from '@server/types/models' -import { VideoPrivacy, VideoState } from '@shared/models' -import { logger } from '../../helpers/logger' -import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' -import { sequelizeTypescript } from '../../initializers/database' -import { ScheduleVideoUpdateModel } from '../../models/video/schedule-video-update' -import { Notifier } from '../notifier' -import { addVideoJobsAfterUpdate } from '../video' -import { VideoPathManager } from '../video-path-manager' -import { setVideoPrivacy } from '../video-privacy' -import { AbstractScheduler } from './abstract-scheduler' +import { VideoPrivacy, VideoPrivacyType, VideoState } from '@peertube/peertube-models' +import { VideoModel } from '@server/models/video/video.js' +import { MScheduleVideoUpdate } from '@server/types/models/index.js' +import { logger } from '../../helpers/logger.js' +import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants.js' +import { sequelizeTypescript } from '../../initializers/database.js' +import { ScheduleVideoUpdateModel } from '../../models/video/schedule-video-update.js' +import { Notifier } from '../notifier/index.js' +import { VideoPathManager } from '../video-path-manager.js' +import { setVideoPrivacy } from '../video-privacy.js' +import { addVideoJobsAfterUpdate } from '../video.js' +import { AbstractScheduler } from './abstract-scheduler.js' export class UpdateVideosScheduler extends AbstractScheduler { @@ -47,7 +47,7 @@ export class UpdateVideosScheduler extends AbstractScheduler { } private async updateAVideo (schedule: MScheduleVideoUpdate) { - let oldPrivacy: VideoPrivacy + let oldPrivacy: VideoPrivacyType let isNewVideo: boolean let published = false diff --git a/server/lib/schedulers/video-channel-sync-latest-scheduler.ts b/server/server/lib/schedulers/video-channel-sync-latest-scheduler.ts similarity index 85% rename from server/lib/schedulers/video-channel-sync-latest-scheduler.ts rename to server/server/lib/schedulers/video-channel-sync-latest-scheduler.ts index efb957fac..2a3ad18b1 100644 --- a/server/lib/schedulers/video-channel-sync-latest-scheduler.ts +++ b/server/server/lib/schedulers/video-channel-sync-latest-scheduler.ts @@ -1,10 +1,10 @@ -import { logger } from '@server/helpers/logger' -import { CONFIG } from '@server/initializers/config' -import { VideoChannelModel } from '@server/models/video/video-channel' -import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync' -import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' -import { synchronizeChannel } from '../sync-channel' -import { AbstractScheduler } from './abstract-scheduler' +import { logger } from '@server/helpers/logger.js' +import { CONFIG } from '@server/initializers/config.js' +import { VideoChannelModel } from '@server/models/video/video-channel.js' +import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync.js' +import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants.js' +import { synchronizeChannel } from '../sync-channel.js' +import { AbstractScheduler } from './abstract-scheduler.js' export class VideoChannelSyncLatestScheduler extends AbstractScheduler { private static instance: AbstractScheduler diff --git a/server/lib/schedulers/video-views-buffer-scheduler.ts b/server/server/lib/schedulers/video-views-buffer-scheduler.ts similarity index 86% rename from server/lib/schedulers/video-views-buffer-scheduler.ts rename to server/server/lib/schedulers/video-views-buffer-scheduler.ts index 244a88b14..fd8a61324 100644 --- a/server/lib/schedulers/video-views-buffer-scheduler.ts +++ b/server/server/lib/schedulers/video-views-buffer-scheduler.ts @@ -1,9 +1,9 @@ -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { VideoModel } from '@server/models/video/video' -import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' -import { federateVideoIfNeeded } from '../activitypub/videos' -import { Redis } from '../redis' -import { AbstractScheduler } from './abstract-scheduler' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { VideoModel } from '@server/models/video/video.js' +import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants.js' +import { federateVideoIfNeeded } from '../activitypub/videos/index.js' +import { Redis } from '../redis.js' +import { AbstractScheduler } from './abstract-scheduler.js' const lTags = loggerTagsFactory('views') diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/server/lib/schedulers/videos-redundancy-scheduler.ts similarity index 94% rename from server/lib/schedulers/videos-redundancy-scheduler.ts rename to server/server/lib/schedulers/videos-redundancy-scheduler.ts index 91625ccb5..60d8686b2 100644 --- a/server/lib/schedulers/videos-redundancy-scheduler.ts +++ b/server/server/lib/schedulers/videos-redundancy-scheduler.ts @@ -1,7 +1,7 @@ -import { move } from 'fs-extra' +import { move } from 'fs-extra/esm' import { join } from 'path' -import { getServerActor } from '@server/models/application/application' -import { VideoModel } from '@server/models/video/video' +import { getServerActor } from '@server/models/application/application.js' +import { VideoModel } from '@server/models/video/video.js' import { MStreamingPlaylistFiles, MVideoAccountLight, @@ -11,20 +11,20 @@ import { MVideoRedundancyStreamingPlaylistVideo, MVideoRedundancyVideo, MVideoWithAllFiles -} from '@server/types/models' -import { VideosRedundancyStrategy } from '../../../shared/models/redundancy' -import { logger, loggerTagsFactory } from '../../helpers/logger' -import { downloadWebTorrentVideo } from '../../helpers/webtorrent' -import { CONFIG } from '../../initializers/config' -import { DIRECTORIES, REDUNDANCY, VIDEO_IMPORT_TIMEOUT } from '../../initializers/constants' -import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' -import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send' -import { getLocalVideoCacheFileActivityPubUrl, getLocalVideoCacheStreamingPlaylistActivityPubUrl } from '../activitypub/url' -import { getOrCreateAPVideo } from '../activitypub/videos' -import { downloadPlaylistSegments } from '../hls' -import { removeVideoRedundancy } from '../redundancy' -import { generateHLSRedundancyUrl, generateWebVideoRedundancyUrl } from '../video-urls' -import { AbstractScheduler } from './abstract-scheduler' +} from '@server/types/models/index.js' +import { VideosRedundancyStrategy } from '@peertube/peertube-models' +import { logger, loggerTagsFactory } from '../../helpers/logger.js' +import { downloadWebTorrentVideo } from '../../helpers/webtorrent.js' +import { CONFIG } from '../../initializers/config.js' +import { DIRECTORIES, REDUNDANCY, VIDEO_IMPORT_TIMEOUT } from '../../initializers/constants.js' +import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy.js' +import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send/index.js' +import { getLocalVideoCacheFileActivityPubUrl, getLocalVideoCacheStreamingPlaylistActivityPubUrl } from '../activitypub/url.js' +import { getOrCreateAPVideo } from '../activitypub/videos/index.js' +import { downloadPlaylistSegments } from '../hls.js' +import { removeVideoRedundancy } from '../redundancy.js' +import { generateHLSRedundancyUrl, generateWebVideoRedundancyUrl } from '../video-urls.js' +import { AbstractScheduler } from './abstract-scheduler.js' const lTags = loggerTagsFactory('redundancy') diff --git a/server/lib/schedulers/youtube-dl-update-scheduler.ts b/server/server/lib/schedulers/youtube-dl-update-scheduler.ts similarity index 77% rename from server/lib/schedulers/youtube-dl-update-scheduler.ts rename to server/server/lib/schedulers/youtube-dl-update-scheduler.ts index 1ee4ae1b2..9e3cbf7b2 100644 --- a/server/lib/schedulers/youtube-dl-update-scheduler.ts +++ b/server/server/lib/schedulers/youtube-dl-update-scheduler.ts @@ -1,6 +1,6 @@ -import { YoutubeDLCLI } from '@server/helpers/youtube-dl' -import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' -import { AbstractScheduler } from './abstract-scheduler' +import { YoutubeDLCLI } from '@server/helpers/youtube-dl/index.js' +import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants.js' +import { AbstractScheduler } from './abstract-scheduler.js' export class YoutubeDlUpdateScheduler extends AbstractScheduler { diff --git a/server/lib/search.ts b/server/server/lib/search.ts similarity index 88% rename from server/lib/search.ts rename to server/server/lib/search.ts index b3363fbec..567eced7c 100644 --- a/server/lib/search.ts +++ b/server/server/lib/search.ts @@ -1,9 +1,9 @@ import express from 'express' -import { CONFIG } from '@server/initializers/config' -import { AccountBlocklistModel } from '@server/models/account/account-blocklist' -import { getServerActor } from '@server/models/application/application' -import { ServerBlocklistModel } from '@server/models/server/server-blocklist' -import { SearchTargetQuery } from '@shared/models' +import { CONFIG } from '@server/initializers/config.js' +import { AccountBlocklistModel } from '@server/models/account/account-blocklist.js' +import { getServerActor } from '@server/models/application/application.js' +import { ServerBlocklistModel } from '@server/models/server/server-blocklist.js' +import { SearchTargetQuery } from '@peertube/peertube-models' function isSearchIndexSearch (query: SearchTargetQuery) { if (query.searchTarget === 'search-index') return true diff --git a/server/lib/server-config-manager.ts b/server/server/lib/server-config-manager.ts similarity index 94% rename from server/lib/server-config-manager.ts rename to server/server/lib/server-config-manager.ts index beb5d4d82..8b3b957fe 100644 --- a/server/lib/server-config-manager.ts +++ b/server/server/lib/server-config-manager.ts @@ -1,14 +1,20 @@ -import { getServerCommit } from '@server/helpers/version' -import { CONFIG, isEmailEnabled } from '@server/initializers/config' -import { CONSTRAINTS_FIELDS, DEFAULT_THEME_NAME, PEERTUBE_VERSION } from '@server/initializers/constants' -import { isSignupAllowed, isSignupAllowedForCurrentIP } from '@server/lib/signup' -import { ActorCustomPageModel } from '@server/models/account/actor-custom-page' -import { PluginModel } from '@server/models/server/plugin' -import { HTMLServerConfig, RegisteredExternalAuthConfig, RegisteredIdAndPassAuthConfig, ServerConfig } from '@shared/models' -import { Hooks } from './plugins/hooks' -import { PluginManager } from './plugins/plugin-manager' -import { getThemeOrDefault } from './plugins/theme-utils' -import { VideoTranscodingProfilesManager } from './transcoding/default-transcoding-profiles' +import { + HTMLServerConfig, + RegisteredExternalAuthConfig, + RegisteredIdAndPassAuthConfig, + ServerConfig, + VideoResolutionType +} from '@peertube/peertube-models' +import { getServerCommit } from '@server/helpers/version.js' +import { CONFIG, isEmailEnabled } from '@server/initializers/config.js' +import { CONSTRAINTS_FIELDS, DEFAULT_THEME_NAME, PEERTUBE_VERSION } from '@server/initializers/constants.js' +import { isSignupAllowed, isSignupAllowedForCurrentIP } from '@server/lib/signup.js' +import { ActorCustomPageModel } from '@server/models/account/actor-custom-page.js' +import { PluginModel } from '@server/models/server/plugin.js' +import { Hooks } from './plugins/hooks.js' +import { PluginManager } from './plugins/plugin-manager.js' +import { getThemeOrDefault } from './plugins/theme-utils.js' +import { VideoTranscodingProfilesManager } from './transcoding/default-transcoding-profiles.js' /** * @@ -333,7 +339,7 @@ class ServerConfigManager { return Object.keys(transcoding.RESOLUTIONS) .filter(key => transcoding.ENABLED && transcoding.RESOLUTIONS[key] === true) - .map(r => parseInt(r, 10)) + .map(r => parseInt(r, 10) as VideoResolutionType) } private getIdAndPassAuthPlugins () { diff --git a/server/lib/signup.ts b/server/server/lib/signup.ts similarity index 73% rename from server/lib/signup.ts rename to server/server/lib/signup.ts index 6702c22cb..5ad5be9c3 100644 --- a/server/lib/signup.ts +++ b/server/server/lib/signup.ts @@ -1,8 +1,7 @@ -import { IPv4, IPv6, parse, subnetMatch } from 'ipaddr.js' -import { CONFIG } from '../initializers/config' -import { UserModel } from '../models/user/user' - -const isCidr = require('is-cidr') +import ipaddr from 'ipaddr.js' +import isCidr from 'is-cidr' +import { CONFIG } from '../initializers/config.js' +import { UserModel } from '../models/user/user.js' export type SignupMode = 'direct-registration' | 'request-registration' @@ -35,7 +34,7 @@ async function isSignupAllowed (options: { function isSignupAllowedForCurrentIP (ip: string) { if (!ip) return false - const addr = parse(ip) + const addr = ipaddr.parse(ip) const excludeList = [ 'blacklist' ] let matched = '' @@ -45,23 +44,23 @@ function isSignupAllowedForCurrentIP (ip: string) { } if (addr.kind() === 'ipv4') { - const addrV4 = IPv4.parse(ip) + const addrV4 = ipaddr.IPv4.parse(ip) const rangeList = { whitelist: CONFIG.SIGNUP.FILTERS.CIDR.WHITELIST.filter(cidr => isCidr.v4(cidr)) - .map(cidr => IPv4.parseCIDR(cidr)), + .map(cidr => ipaddr.IPv4.parseCIDR(cidr)), blacklist: CONFIG.SIGNUP.FILTERS.CIDR.BLACKLIST.filter(cidr => isCidr.v4(cidr)) - .map(cidr => IPv4.parseCIDR(cidr)) + .map(cidr => ipaddr.IPv4.parseCIDR(cidr)) } - matched = subnetMatch(addrV4, rangeList, 'unknown') + matched = ipaddr.subnetMatch(addrV4, rangeList, 'unknown') } else if (addr.kind() === 'ipv6') { - const addrV6 = IPv6.parse(ip) + const addrV6 = ipaddr.IPv6.parse(ip) const rangeList = { whitelist: CONFIG.SIGNUP.FILTERS.CIDR.WHITELIST.filter(cidr => isCidr.v6(cidr)) - .map(cidr => IPv6.parseCIDR(cidr)), + .map(cidr => ipaddr.IPv6.parseCIDR(cidr)), blacklist: CONFIG.SIGNUP.FILTERS.CIDR.BLACKLIST.filter(cidr => isCidr.v6(cidr)) - .map(cidr => IPv6.parseCIDR(cidr)) + .map(cidr => ipaddr.IPv6.parseCIDR(cidr)) } - matched = subnetMatch(addrV6, rangeList, 'unknown') + matched = ipaddr.subnetMatch(addrV6, rangeList, 'unknown') } return !excludeList.includes(matched) diff --git a/server/lib/stat-manager.ts b/server/server/lib/stat-manager.ts similarity index 93% rename from server/lib/stat-manager.ts rename to server/server/lib/stat-manager.ts index 0516e7f1a..f27266571 100644 --- a/server/lib/stat-manager.ts +++ b/server/server/lib/stat-manager.ts @@ -1,14 +1,14 @@ -import { mapSeries } from 'bluebird' -import { CONFIG } from '@server/initializers/config' -import { ActorFollowModel } from '@server/models/actor/actor-follow' -import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy' -import { UserModel } from '@server/models/user/user' -import { VideoModel } from '@server/models/video/video' -import { VideoChannelModel } from '@server/models/video/video-channel' -import { VideoCommentModel } from '@server/models/video/video-comment' -import { VideoFileModel } from '@server/models/video/video-file' -import { VideoPlaylistModel } from '@server/models/video/video-playlist' -import { ActivityType, ServerStats, VideoRedundancyStrategyWithManual } from '@shared/models' +import Bluebird from 'bluebird' +import { CONFIG } from '@server/initializers/config.js' +import { ActorFollowModel } from '@server/models/actor/actor-follow.js' +import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy.js' +import { UserModel } from '@server/models/user/user.js' +import { VideoModel } from '@server/models/video/video.js' +import { VideoChannelModel } from '@server/models/video/video-channel.js' +import { VideoCommentModel } from '@server/models/video/video-comment.js' +import { VideoFileModel } from '@server/models/video/video-file.js' +import { VideoPlaylistModel } from '@server/models/video/video-playlist.js' +import { ActivityType, ServerStats, VideoRedundancyStrategyWithManual } from '@peertube/peertube-models' class StatsManager { @@ -107,7 +107,7 @@ class StatsManager { strategies.push({ strategy: 'manual', size: null }) - return mapSeries(strategies, r => { + return Bluebird.mapSeries(strategies, r => { return VideoRedundancyModel.getStats(r.strategy) .then(stats => Object.assign(stats, { strategy: r.strategy, totalSize: r.size })) }) diff --git a/server/lib/sync-channel.ts b/server/server/lib/sync-channel.ts similarity index 86% rename from server/lib/sync-channel.ts rename to server/server/lib/sync-channel.ts index 3a805a943..b0cbf43ba 100644 --- a/server/lib/sync-channel.ts +++ b/server/server/lib/sync-channel.ts @@ -1,13 +1,13 @@ -import { logger } from '@server/helpers/logger' -import { YoutubeDLWrapper } from '@server/helpers/youtube-dl' -import { CONFIG } from '@server/initializers/config' -import { buildYoutubeDLImport } from '@server/lib/video-pre-import' -import { UserModel } from '@server/models/user/user' -import { VideoImportModel } from '@server/models/video/video-import' -import { MChannel, MChannelAccountDefault, MChannelSync } from '@server/types/models' -import { VideoChannelSyncState, VideoPrivacy } from '@shared/models' -import { CreateJobArgument, JobQueue } from './job-queue' -import { ServerConfigManager } from './server-config-manager' +import { logger } from '@server/helpers/logger.js' +import { YoutubeDLWrapper } from '@server/helpers/youtube-dl/index.js' +import { CONFIG } from '@server/initializers/config.js' +import { buildYoutubeDLImport } from '@server/lib/video-pre-import.js' +import { UserModel } from '@server/models/user/user.js' +import { VideoImportModel } from '@server/models/video/video-import.js' +import { MChannel, MChannelAccountDefault, MChannelSync } from '@server/types/models/index.js' +import { VideoChannelSyncState, VideoPrivacy } from '@peertube/peertube-models' +import { CreateJobArgument, JobQueue } from './job-queue/index.js' +import { ServerConfigManager } from './server-config-manager.js' export async function synchronizeChannel (options: { channel: MChannelAccountDefault diff --git a/server/lib/thumbnail.ts b/server/server/lib/thumbnail.ts similarity index 93% rename from server/lib/thumbnail.ts rename to server/server/lib/thumbnail.ts index 0b98da14f..e5424973b 100644 --- a/server/lib/thumbnail.ts +++ b/server/server/lib/thumbnail.ts @@ -1,14 +1,14 @@ import { join } from 'path' -import { ThumbnailType } from '@shared/models' -import { generateImageFilename, generateImageFromVideoFile } from '../helpers/image-utils' -import { CONFIG } from '../initializers/config' -import { ASSETS_PATH, PREVIEWS_SIZE, THUMBNAILS_SIZE } from '../initializers/constants' -import { ThumbnailModel } from '../models/video/thumbnail' -import { MVideoFile, MVideoThumbnail, MVideoUUID, MVideoWithAllFiles } from '../types/models' -import { MThumbnail } from '../types/models/video/thumbnail' -import { MVideoPlaylistThumbnail } from '../types/models/video/video-playlist' -import { VideoPathManager } from './video-path-manager' -import { downloadImageFromWorker, processImageFromWorker } from './worker/parent-process' +import { ThumbnailType, ThumbnailType_Type } from '@peertube/peertube-models' +import { generateImageFilename, generateImageFromVideoFile } from '../helpers/image-utils.js' +import { CONFIG } from '../initializers/config.js' +import { ASSETS_PATH, PREVIEWS_SIZE, THUMBNAILS_SIZE } from '../initializers/constants.js' +import { ThumbnailModel } from '../models/video/thumbnail.js' +import { MVideoFile, MVideoThumbnail, MVideoUUID, MVideoWithAllFiles } from '../types/models/index.js' +import { MThumbnail } from '../types/models/video/thumbnail.js' +import { MVideoPlaylistThumbnail } from '../types/models/video/video-playlist.js' +import { VideoPathManager } from './video-path-manager.js' +import { downloadImageFromWorker, processImageFromWorker } from './worker/parent-process.js' type ImageSize = { height?: number, width?: number } @@ -63,7 +63,7 @@ function updateRemotePlaylistMiniatureFromUrl (options: { function updateLocalVideoMiniatureFromExisting (options: { inputPath: string video: MVideoThumbnail - type: ThumbnailType + type: ThumbnailType_Type automaticallyGenerated: boolean size?: ImageSize keepOriginal?: boolean // default to false @@ -91,7 +91,7 @@ function updateLocalVideoMiniatureFromExisting (options: { function generateLocalVideoMiniature (options: { video: MVideoThumbnail videoFile: MVideoFile - type: ThumbnailType + type: ThumbnailType_Type }) { const { video, videoFile, type } = options @@ -130,7 +130,7 @@ function generateLocalVideoMiniature (options: { function updateLocalVideoMiniatureFromUrl (options: { downloadUrl: string video: MVideoThumbnail - type: ThumbnailType + type: ThumbnailType_Type size?: ImageSize }) { const { downloadUrl, video, type, size } = options @@ -162,7 +162,7 @@ function updateLocalVideoMiniatureFromUrl (options: { function updateRemoteVideoThumbnail (options: { fileUrl: string video: MVideoThumbnail - type: ThumbnailType + type: ThumbnailType_Type size: ImageSize onDisk: boolean }) { @@ -246,7 +246,7 @@ function buildMetadataFromPlaylist (playlist: MVideoPlaylistThumbnail, size: Ima } } -function buildMetadataFromVideo (video: MVideoThumbnail, type: ThumbnailType, size?: ImageSize) { +function buildMetadataFromVideo (video: MVideoThumbnail, type: ThumbnailType_Type, size?: ImageSize) { const existingThumbnail = Array.isArray(video.Thumbnails) ? video.Thumbnails.find(t => t.type === type) : undefined @@ -287,7 +287,7 @@ async function updateThumbnailFromFunction (parameters: { filename: string height: number width: number - type: ThumbnailType + type: ThumbnailType_Type onDisk: boolean automaticallyGenerated?: boolean fileUrl?: string diff --git a/server/lib/timeserie.ts b/server/server/lib/timeserie.ts similarity index 97% rename from server/lib/timeserie.ts rename to server/server/lib/timeserie.ts index 08b12129a..9723266ff 100644 --- a/server/lib/timeserie.ts +++ b/server/server/lib/timeserie.ts @@ -1,4 +1,4 @@ -import { logger } from '@server/helpers/logger' +import { logger } from '@server/helpers/logger.js' function buildGroupByAndBoundaries (startDateString: string, endDateString: string) { const startDate = new Date(startDateString) diff --git a/server/lib/transcoding/create-transcoding-job.ts b/server/server/lib/transcoding/create-transcoding-job.ts similarity index 91% rename from server/lib/transcoding/create-transcoding-job.ts rename to server/server/lib/transcoding/create-transcoding-job.ts index d78e68b87..aea18b632 100644 --- a/server/lib/transcoding/create-transcoding-job.ts +++ b/server/server/lib/transcoding/create-transcoding-job.ts @@ -1,6 +1,6 @@ -import { CONFIG } from '@server/initializers/config' -import { MUserId, MVideoFile, MVideoFullLight } from '@server/types/models' -import { TranscodingJobQueueBuilder, TranscodingRunnerJobBuilder } from './shared' +import { CONFIG } from '@server/initializers/config.js' +import { MUserId, MVideoFile, MVideoFullLight } from '@server/types/models/index.js' +import { TranscodingJobQueueBuilder, TranscodingRunnerJobBuilder } from './shared/index.js' export function createOptimizeOrMergeAudioJobs (options: { video: MVideoFullLight diff --git a/server/lib/transcoding/default-transcoding-profiles.ts b/server/server/lib/transcoding/default-transcoding-profiles.ts similarity index 95% rename from server/lib/transcoding/default-transcoding-profiles.ts rename to server/server/lib/transcoding/default-transcoding-profiles.ts index 8f8fdd026..90407d103 100644 --- a/server/lib/transcoding/default-transcoding-profiles.ts +++ b/server/server/lib/transcoding/default-transcoding-profiles.ts @@ -1,7 +1,7 @@ -import { logger } from '@server/helpers/logger' -import { FFmpegCommandWrapper, getDefaultAvailableEncoders } from '@shared/ffmpeg' -import { AvailableEncoders, EncoderOptionsBuilder } from '@shared/models' +import { logger } from '@server/helpers/logger.js' +import { FFmpegCommandWrapper, getDefaultAvailableEncoders } from '@peertube/peertube-ffmpeg' +import { AvailableEncoders, EncoderOptionsBuilder } from '@peertube/peertube-models' // --------------------------------------------------------------------------- // Profile manager to get and change default profiles diff --git a/server/lib/transcoding/ended-transcoding.ts b/server/server/lib/transcoding/ended-transcoding.ts similarity index 79% rename from server/lib/transcoding/ended-transcoding.ts rename to server/server/lib/transcoding/ended-transcoding.ts index d31674ede..468a3aa83 100644 --- a/server/lib/transcoding/ended-transcoding.ts +++ b/server/server/lib/transcoding/ended-transcoding.ts @@ -1,7 +1,7 @@ -import { retryTransactionWrapper } from '@server/helpers/database-utils' -import { VideoJobInfoModel } from '@server/models/video/video-job-info' -import { MVideo } from '@server/types/models' -import { moveToNextState } from '../video-state' +import { retryTransactionWrapper } from '@server/helpers/database-utils.js' +import { VideoJobInfoModel } from '@server/models/video/video-job-info.js' +import { MVideo } from '@server/types/models/index.js' +import { moveToNextState } from '../video-state.js' export async function onTranscodingEnded (options: { video: MVideo diff --git a/server/lib/transcoding/hls-transcoding.ts b/server/server/lib/transcoding/hls-transcoding.ts similarity index 86% rename from server/lib/transcoding/hls-transcoding.ts rename to server/server/lib/transcoding/hls-transcoding.ts index 2c325d9ee..5f07f112a 100644 --- a/server/lib/transcoding/hls-transcoding.ts +++ b/server/server/lib/transcoding/hls-transcoding.ts @@ -1,28 +1,28 @@ import { MutexInterface } from 'async-mutex' import { Job } from 'bullmq' -import { ensureDir, move, stat } from 'fs-extra' +import { ensureDir, move } from 'fs-extra/esm' +import { stat } from 'fs/promises' import { basename, extname as extnameUtil, join } from 'path' -import { retryTransactionWrapper } from '@server/helpers/database-utils' -import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' -import { sequelizeTypescript } from '@server/initializers/database' -import { MVideo, MVideoFile } from '@server/types/models' -import { pick } from '@shared/core-utils' -import { getVideoStreamDuration, getVideoStreamFPS } from '@shared/ffmpeg' -import { VideoResolution } from '@shared/models' -import { CONFIG } from '../../initializers/config' -import { VideoFileModel } from '../../models/video/video-file' -import { VideoStreamingPlaylistModel } from '../../models/video/video-streaming-playlist' -import { updatePlaylistAfterFileChange } from '../hls' -import { generateHLSVideoFilename, getHlsResolutionPlaylistFilename } from '../paths' -import { buildFileMetadata } from '../video-file' -import { VideoPathManager } from '../video-path-manager' -import { buildFFmpegVOD } from './shared' +import { pick } from '@peertube/peertube-core-utils' +import { retryTransactionWrapper } from '@server/helpers/database-utils.js' +import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent.js' +import { sequelizeTypescript } from '@server/initializers/database.js' +import { MVideo, MVideoFile } from '@server/types/models/index.js' +import { getVideoStreamDuration, getVideoStreamFPS } from '@peertube/peertube-ffmpeg' +import { CONFIG } from '../../initializers/config.js' +import { VideoFileModel } from '../../models/video/video-file.js' +import { VideoStreamingPlaylistModel } from '../../models/video/video-streaming-playlist.js' +import { updatePlaylistAfterFileChange } from '../hls.js' +import { generateHLSVideoFilename, getHlsResolutionPlaylistFilename } from '../paths.js' +import { buildFileMetadata } from '../video-file.js' +import { VideoPathManager } from '../video-path-manager.js' +import { buildFFmpegVOD } from './shared/index.js' // Concat TS segments from a live video to a fragmented mp4 HLS playlist export async function generateHlsPlaylistResolutionFromTS (options: { video: MVideo concatenatedTsFilePath: string - resolution: VideoResolution + resolution: number fps: number isAAC: boolean inputFileMutexReleaser: MutexInterface.Releaser @@ -39,7 +39,7 @@ export async function generateHlsPlaylistResolutionFromTS (options: { export function generateHlsPlaylistResolution (options: { video: MVideo videoInputPath: string - resolution: VideoResolution + resolution: number fps: number copyCodecs: boolean inputFileMutexReleaser: MutexInterface.Releaser @@ -125,7 +125,7 @@ async function generateHlsPlaylistCommon (options: { video: MVideo inputPath: string - resolution: VideoResolution + resolution: number fps: number inputFileMutexReleaser: MutexInterface.Releaser diff --git a/server/lib/transcoding/shared/ffmpeg-builder.ts b/server/server/lib/transcoding/shared/ffmpeg-builder.ts similarity index 78% rename from server/lib/transcoding/shared/ffmpeg-builder.ts rename to server/server/lib/transcoding/shared/ffmpeg-builder.ts index 441445ec4..b28ffdb1f 100644 --- a/server/lib/transcoding/shared/ffmpeg-builder.ts +++ b/server/server/lib/transcoding/shared/ffmpeg-builder.ts @@ -1,8 +1,8 @@ import { Job } from 'bullmq' -import { getFFmpegCommandWrapperOptions } from '@server/helpers/ffmpeg' -import { logger } from '@server/helpers/logger' -import { FFmpegVOD } from '@shared/ffmpeg' -import { VideoTranscodingProfilesManager } from '../default-transcoding-profiles' +import { getFFmpegCommandWrapperOptions } from '@server/helpers/ffmpeg/index.js' +import { logger } from '@server/helpers/logger.js' +import { FFmpegVOD } from '@peertube/peertube-ffmpeg' +import { VideoTranscodingProfilesManager } from '../default-transcoding-profiles.js' export function buildFFmpegVOD (job?: Job) { return new FFmpegVOD({ diff --git a/server/server/lib/transcoding/shared/index.ts b/server/server/lib/transcoding/shared/index.ts new file mode 100644 index 000000000..835ee6632 --- /dev/null +++ b/server/server/lib/transcoding/shared/index.ts @@ -0,0 +1,2 @@ +export * from './job-builders/index.js' +export * from './ffmpeg-builder.js' diff --git a/server/lib/transcoding/shared/job-builders/abstract-job-builder.ts b/server/server/lib/transcoding/shared/job-builders/abstract-job-builder.ts similarity index 96% rename from server/lib/transcoding/shared/job-builders/abstract-job-builder.ts rename to server/server/lib/transcoding/shared/job-builders/abstract-job-builder.ts index 15fc814ae..96c8f990b 100644 --- a/server/lib/transcoding/shared/job-builders/abstract-job-builder.ts +++ b/server/server/lib/transcoding/shared/job-builders/abstract-job-builder.ts @@ -1,5 +1,5 @@ -import { MUserId, MVideoFile, MVideoFullLight } from '@server/types/models' +import { MUserId, MVideoFile, MVideoFullLight } from '@server/types/models/index.js' export abstract class AbstractJobBuilder { diff --git a/server/server/lib/transcoding/shared/job-builders/index.ts b/server/server/lib/transcoding/shared/job-builders/index.ts new file mode 100644 index 000000000..099c6646e --- /dev/null +++ b/server/server/lib/transcoding/shared/job-builders/index.ts @@ -0,0 +1,2 @@ +export * from './transcoding-job-queue-builder.js' +export * from './transcoding-runner-job-builder.js' diff --git a/server/lib/transcoding/shared/job-builders/transcoding-job-queue-builder.ts b/server/server/lib/transcoding/shared/job-builders/transcoding-job-queue-builder.ts similarity index 95% rename from server/lib/transcoding/shared/job-builders/transcoding-job-queue-builder.ts rename to server/server/lib/transcoding/shared/job-builders/transcoding-job-queue-builder.ts index 0505c2b2f..0f221472f 100644 --- a/server/lib/transcoding/shared/job-builders/transcoding-job-queue-builder.ts +++ b/server/server/lib/transcoding/shared/job-builders/transcoding-job-queue-builder.ts @@ -1,25 +1,25 @@ import Bluebird from 'bluebird' -import { computeOutputFPS } from '@server/helpers/ffmpeg' -import { logger } from '@server/helpers/logger' -import { CONFIG } from '@server/initializers/config' -import { DEFAULT_AUDIO_RESOLUTION, VIDEO_TRANSCODING_FPS } from '@server/initializers/constants' -import { CreateJobArgument, JobQueue } from '@server/lib/job-queue' -import { Hooks } from '@server/lib/plugins/hooks' -import { VideoPathManager } from '@server/lib/video-path-manager' -import { VideoJobInfoModel } from '@server/models/video/video-job-info' -import { MUserId, MVideoFile, MVideoFullLight, MVideoWithFileThumbnail } from '@server/types/models' -import { ffprobePromise, getVideoStreamDimensionsInfo, getVideoStreamFPS, hasAudioStream, isAudioFile } from '@shared/ffmpeg' +import { computeOutputFPS } from '@server/helpers/ffmpeg/index.js' +import { logger } from '@server/helpers/logger.js' +import { CONFIG } from '@server/initializers/config.js' +import { DEFAULT_AUDIO_RESOLUTION, VIDEO_TRANSCODING_FPS } from '@server/initializers/constants.js' +import { CreateJobArgument, JobQueue } from '@server/lib/job-queue/index.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { VideoPathManager } from '@server/lib/video-path-manager.js' +import { VideoJobInfoModel } from '@server/models/video/video-job-info.js' +import { MUserId, MVideoFile, MVideoFullLight, MVideoWithFileThumbnail } from '@server/types/models/index.js' +import { ffprobePromise, getVideoStreamDimensionsInfo, getVideoStreamFPS, hasAudioStream, isAudioFile } from '@peertube/peertube-ffmpeg' import { HLSTranscodingPayload, MergeAudioTranscodingPayload, NewWebVideoResolutionTranscodingPayload, OptimizeTranscodingPayload, VideoTranscodingPayload -} from '@shared/models' -import { getTranscodingJobPriority } from '../../transcoding-priority' -import { canDoQuickTranscode } from '../../transcoding-quick-transcode' -import { buildOriginalFileResolution, computeResolutionsToTranscode } from '../../transcoding-resolutions' -import { AbstractJobBuilder } from './abstract-job-builder' +} from '@peertube/peertube-models' +import { getTranscodingJobPriority } from '../../transcoding-priority.js' +import { canDoQuickTranscode } from '../../transcoding-quick-transcode.js' +import { buildOriginalFileResolution, computeResolutionsToTranscode } from '../../transcoding-resolutions.js' +import { AbstractJobBuilder } from './abstract-job-builder.js' export class TranscodingJobQueueBuilder extends AbstractJobBuilder { diff --git a/server/lib/transcoding/shared/job-builders/transcoding-runner-job-builder.ts b/server/server/lib/transcoding/shared/job-builders/transcoding-runner-job-builder.ts similarity index 91% rename from server/lib/transcoding/shared/job-builders/transcoding-runner-job-builder.ts rename to server/server/lib/transcoding/shared/job-builders/transcoding-runner-job-builder.ts index f0671bd7a..68d84a286 100644 --- a/server/lib/transcoding/shared/job-builders/transcoding-runner-job-builder.ts +++ b/server/server/lib/transcoding/shared/job-builders/transcoding-runner-job-builder.ts @@ -1,16 +1,20 @@ -import { computeOutputFPS } from '@server/helpers/ffmpeg' -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { CONFIG } from '@server/initializers/config' -import { DEFAULT_AUDIO_RESOLUTION, VIDEO_TRANSCODING_FPS } from '@server/initializers/constants' -import { Hooks } from '@server/lib/plugins/hooks' -import { VODAudioMergeTranscodingJobHandler, VODHLSTranscodingJobHandler, VODWebVideoTranscodingJobHandler } from '@server/lib/runners' -import { VideoPathManager } from '@server/lib/video-path-manager' -import { MUserId, MVideoFile, MVideoFullLight, MVideoWithFileThumbnail } from '@server/types/models' -import { MRunnerJob } from '@server/types/models/runners' -import { ffprobePromise, getVideoStreamDimensionsInfo, getVideoStreamFPS, hasAudioStream, isAudioFile } from '@shared/ffmpeg' -import { getTranscodingJobPriority } from '../../transcoding-priority' -import { computeResolutionsToTranscode } from '../../transcoding-resolutions' -import { AbstractJobBuilder } from './abstract-job-builder' +import { computeOutputFPS } from '@server/helpers/ffmpeg/index.js' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { CONFIG } from '@server/initializers/config.js' +import { DEFAULT_AUDIO_RESOLUTION, VIDEO_TRANSCODING_FPS } from '@server/initializers/constants.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { + VODAudioMergeTranscodingJobHandler, + VODHLSTranscodingJobHandler, + VODWebVideoTranscodingJobHandler +} from '@server/lib/runners/index.js' +import { VideoPathManager } from '@server/lib/video-path-manager.js' +import { MUserId, MVideoFile, MVideoFullLight, MVideoWithFileThumbnail } from '@server/types/models/index.js' +import { MRunnerJob } from '@server/types/models/runners/index.js' +import { ffprobePromise, getVideoStreamDimensionsInfo, getVideoStreamFPS, hasAudioStream, isAudioFile } from '@peertube/peertube-ffmpeg' +import { getTranscodingJobPriority } from '../../transcoding-priority.js' +import { computeResolutionsToTranscode } from '../../transcoding-resolutions.js' +import { AbstractJobBuilder } from './abstract-job-builder.js' /** * diff --git a/server/lib/transcoding/transcoding-priority.ts b/server/server/lib/transcoding/transcoding-priority.ts similarity index 74% rename from server/lib/transcoding/transcoding-priority.ts rename to server/server/lib/transcoding/transcoding-priority.ts index 82ab6f2f1..42061d0f9 100644 --- a/server/lib/transcoding/transcoding-priority.ts +++ b/server/server/lib/transcoding/transcoding-priority.ts @@ -1,6 +1,6 @@ -import { JOB_PRIORITY } from '@server/initializers/constants' -import { VideoModel } from '@server/models/video/video' -import { MUserId } from '@server/types/models' +import { JOB_PRIORITY } from '@server/initializers/constants.js' +import { VideoModel } from '@server/models/video/video.js' +import { MUserId } from '@server/types/models/index.js' export async function getTranscodingJobPriority (options: { user: MUserId diff --git a/server/lib/transcoding/transcoding-quick-transcode.ts b/server/server/lib/transcoding/transcoding-quick-transcode.ts similarity index 81% rename from server/lib/transcoding/transcoding-quick-transcode.ts rename to server/server/lib/transcoding/transcoding-quick-transcode.ts index 53f12cd06..1d054ece3 100644 --- a/server/lib/transcoding/transcoding-quick-transcode.ts +++ b/server/server/lib/transcoding/transcoding-quick-transcode.ts @@ -1,6 +1,6 @@ import { FfprobeData } from 'fluent-ffmpeg' -import { CONFIG } from '@server/initializers/config' -import { canDoQuickAudioTranscode, canDoQuickVideoTranscode, ffprobePromise } from '@shared/ffmpeg' +import { CONFIG } from '@server/initializers/config.js' +import { canDoQuickAudioTranscode, canDoQuickVideoTranscode, ffprobePromise } from '@peertube/peertube-ffmpeg' export async function canDoQuickTranscode (path: string, existingProbe?: FfprobeData): Promise { if (CONFIG.TRANSCODING.PROFILE !== 'default') return false diff --git a/server/lib/transcoding/transcoding-resolutions.ts b/server/server/lib/transcoding/transcoding-resolutions.ts similarity index 88% rename from server/lib/transcoding/transcoding-resolutions.ts rename to server/server/lib/transcoding/transcoding-resolutions.ts index 9a6bf5722..b1c55edf9 100644 --- a/server/lib/transcoding/transcoding-resolutions.ts +++ b/server/server/lib/transcoding/transcoding-resolutions.ts @@ -1,6 +1,6 @@ -import { CONFIG } from '@server/initializers/config' -import { toEven } from '@shared/core-utils' -import { VideoResolution } from '@shared/models' +import { toEven } from '@peertube/peertube-core-utils' +import { VideoResolution, VideoResolutionType } from '@peertube/peertube-models' +import { CONFIG } from '@server/initializers/config.js' export function buildOriginalFileResolution (inputResolution: number) { if (CONFIG.TRANSCODING.ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION === true) { @@ -39,7 +39,7 @@ export function computeResolutionsToTranscode (options: { const resolutionsEnabled = new Set() // Put in the order we want to proceed jobs - const availableResolutions: VideoResolution[] = [ + const availableResolutions: VideoResolutionType[] = [ VideoResolution.H_NOVIDEO, VideoResolution.H_480P, VideoResolution.H_360P, diff --git a/server/lib/transcoding/web-transcoding.ts b/server/server/lib/transcoding/web-transcoding.ts similarity index 90% rename from server/lib/transcoding/web-transcoding.ts rename to server/server/lib/transcoding/web-transcoding.ts index f92d457a0..e8247e958 100644 --- a/server/lib/transcoding/web-transcoding.ts +++ b/server/server/lib/transcoding/web-transcoding.ts @@ -1,20 +1,21 @@ import { Job } from 'bullmq' -import { copyFile, move, remove, stat } from 'fs-extra' +import { move, remove } from 'fs-extra/esm' +import { copyFile, stat } from 'fs/promises' import { basename, join } from 'path' -import { computeOutputFPS } from '@server/helpers/ffmpeg' -import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' -import { VideoModel } from '@server/models/video/video' -import { MVideoFile, MVideoFullLight } from '@server/types/models' -import { ffprobePromise, getVideoStreamDuration, getVideoStreamFPS, TranscodeVODOptionsType } from '@shared/ffmpeg' -import { VideoResolution, VideoStorage } from '@shared/models' -import { CONFIG } from '../../initializers/config' -import { VideoFileModel } from '../../models/video/video-file' -import { JobQueue } from '../job-queue' -import { generateWebVideoFilename } from '../paths' -import { buildFileMetadata } from '../video-file' -import { VideoPathManager } from '../video-path-manager' -import { buildFFmpegVOD } from './shared' -import { buildOriginalFileResolution } from './transcoding-resolutions' +import { VideoStorage } from '@peertube/peertube-models' +import { computeOutputFPS } from '@server/helpers/ffmpeg/index.js' +import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent.js' +import { VideoModel } from '@server/models/video/video.js' +import { MVideoFile, MVideoFullLight } from '@server/types/models/index.js' +import { ffprobePromise, getVideoStreamDuration, getVideoStreamFPS, TranscodeVODOptionsType } from '@peertube/peertube-ffmpeg' +import { CONFIG } from '../../initializers/config.js' +import { VideoFileModel } from '../../models/video/video-file.js' +import { JobQueue } from '../job-queue/index.js' +import { generateWebVideoFilename } from '../paths.js' +import { buildFileMetadata } from '../video-file.js' +import { VideoPathManager } from '../video-path-manager.js' +import { buildFFmpegVOD } from './shared/index.js' +import { buildOriginalFileResolution } from './transcoding-resolutions.js' // Optimize the original video file and replace it. The resolution is not changed. export async function optimizeOriginalVideofile (options: { @@ -86,7 +87,7 @@ export async function optimizeOriginalVideofile (options: { // Transcode the original video file to a lower resolution compatible with web browsers export async function transcodeNewWebVideoResolution (options: { video: MVideoFullLight - resolution: VideoResolution + resolution: number fps: number job: Job }) { @@ -138,7 +139,7 @@ export async function transcodeNewWebVideoResolution (options: { // Merge an image with an audio file to create a video export async function mergeAudioVideofile (options: { video: MVideoFullLight - resolution: VideoResolution + resolution: number fps: number job: Job }) { diff --git a/server/lib/uploadx.ts b/server/server/lib/uploadx.ts similarity index 81% rename from server/lib/uploadx.ts rename to server/server/lib/uploadx.ts index c7e0eb414..81c93f77c 100644 --- a/server/lib/uploadx.ts +++ b/server/server/lib/uploadx.ts @@ -1,7 +1,7 @@ import express from 'express' -import { buildLogger } from '@server/helpers/logger' -import { getResumableUploadPath } from '@server/helpers/upload' -import { CONFIG } from '@server/initializers/config' +import { buildLogger } from '@server/helpers/logger.js' +import { getResumableUploadPath } from '@server/helpers/upload.js' +import { CONFIG } from '@server/initializers/config.js' import { LogLevel, Uploadx } from '@uploadx/core' import { extname } from 'path' diff --git a/server/lib/user.ts b/server/server/lib/user.ts similarity index 88% rename from server/lib/user.ts rename to server/server/lib/user.ts index 56995cca3..d391f384b 100644 --- a/server/lib/user.ts +++ b/server/server/lib/user.ts @@ -1,24 +1,31 @@ -import { Transaction } from 'sequelize/types' -import { logger } from '@server/helpers/logger' -import { CONFIG } from '@server/initializers/config' -import { UserModel } from '@server/models/user/user' -import { MActorDefault } from '@server/types/models/actor' -import { ActivityPubActorType } from '../../shared/models/activitypub' -import { UserAdminFlag, UserNotificationSetting, UserNotificationSettingValue, UserRole } from '../../shared/models/users' -import { SERVER_ACTOR_NAME, WEBSERVER } from '../initializers/constants' -import { sequelizeTypescript } from '../initializers/database' -import { AccountModel } from '../models/account/account' -import { UserNotificationSettingModel } from '../models/user/user-notification-setting' -import { MAccountDefault, MChannelActor } from '../types/models' -import { MRegistration, MUser, MUserDefault, MUserId } from '../types/models/user' -import { generateAndSaveActorKeys } from './activitypub/actors' -import { getLocalAccountActivityPubUrl } from './activitypub/url' -import { Emailer } from './emailer' -import { LiveQuotaStore } from './live/live-quota-store' -import { buildActorInstance, findAvailableLocalActorName } from './local-actor' -import { Redis } from './redis' -import { createLocalVideoChannel } from './video-channel' -import { createWatchLaterPlaylist } from './video-playlist' +import { Transaction } from 'sequelize' +import { + ActivityPubActorType, + UserAdminFlag, + UserAdminFlagType, + UserNotificationSetting, + UserNotificationSettingValue, + UserRole, + UserRoleType +} from '@peertube/peertube-models' +import { logger } from '@server/helpers/logger.js' +import { CONFIG } from '@server/initializers/config.js' +import { UserModel } from '@server/models/user/user.js' +import { MActorDefault } from '@server/types/models/actor/index.js' +import { SERVER_ACTOR_NAME, WEBSERVER } from '../initializers/constants.js' +import { sequelizeTypescript } from '../initializers/database.js' +import { AccountModel } from '../models/account/account.js' +import { UserNotificationSettingModel } from '../models/user/user-notification-setting.js' +import { MAccountDefault, MChannelActor } from '../types/models/index.js' +import { MRegistration, MUser, MUserDefault, MUserId } from '../types/models/user/index.js' +import { generateAndSaveActorKeys } from './activitypub/actors/index.js' +import { getLocalAccountActivityPubUrl } from './activitypub/url.js' +import { Emailer } from './emailer.js' +import { LiveQuotaStore } from './live/live-quota-store.js' +import { buildActorInstance, findAvailableLocalActorName } from './local-actor.js' +import { Redis } from './redis.js' +import { createLocalVideoChannel } from './video-channel.js' +import { createWatchLaterPlaylist } from './video-playlist.js' type ChannelNames = { name: string, displayName: string } @@ -27,8 +34,8 @@ function buildUser (options: { password: string email: string - role?: UserRole // Default to UserRole.User - adminFlags?: UserAdminFlag // Default to UserAdminFlag.NONE + role?: UserRoleType // Default to UserRole.User + adminFlags?: UserAdminFlagType // Default to UserAdminFlag.NONE emailVerified: boolean | null diff --git a/server/lib/video-blacklist.ts b/server/server/lib/video-blacklist.ts similarity index 87% rename from server/lib/video-blacklist.ts rename to server/server/lib/video-blacklist.ts index d5664a1b9..3fd0a59ed 100644 --- a/server/lib/video-blacklist.ts +++ b/server/server/lib/video-blacklist.ts @@ -1,6 +1,7 @@ import { Transaction } from 'sequelize' -import { afterCommitIfTransaction } from '@server/helpers/database-utils' -import { sequelizeTypescript } from '@server/initializers/database' +import { LiveVideoError, UserAdminFlag, UserRight, VideoBlacklistCreate, VideoBlacklistType } from '@peertube/peertube-models' +import { afterCommitIfTransaction } from '@server/helpers/database-utils.js' +import { sequelizeTypescript } from '@server/initializers/database.js' import { MUser, MVideoAccountLight, @@ -8,17 +9,15 @@ import { MVideoBlacklistVideo, MVideoFullLight, MVideoWithBlacklistLight -} from '@server/types/models' -import { LiveVideoError, UserRight, VideoBlacklistCreate, VideoBlacklistType } from '../../shared/models' -import { UserAdminFlag } from '../../shared/models/users/user-flag.model' -import { logger, loggerTagsFactory } from '../helpers/logger' -import { CONFIG } from '../initializers/config' -import { VideoBlacklistModel } from '../models/video/video-blacklist' -import { sendDeleteVideo } from './activitypub/send' -import { federateVideoIfNeeded } from './activitypub/videos' -import { LiveManager } from './live/live-manager' -import { Notifier } from './notifier' -import { Hooks } from './plugins/hooks' +} from '@server/types/models/index.js' +import { logger, loggerTagsFactory } from '../helpers/logger.js' +import { CONFIG } from '../initializers/config.js' +import { VideoBlacklistModel } from '../models/video/video-blacklist.js' +import { sendDeleteVideo } from './activitypub/send/index.js' +import { federateVideoIfNeeded } from './activitypub/videos/index.js' +import { LiveManager } from './live/live-manager.js' +import { Notifier } from './notifier/index.js' +import { Hooks } from './plugins/hooks.js' const lTags = loggerTagsFactory('blacklist') diff --git a/server/lib/video-channel.ts b/server/server/lib/video-channel.ts similarity index 82% rename from server/lib/video-channel.ts rename to server/server/lib/video-channel.ts index 8322c9ad2..ea24b5f1d 100644 --- a/server/lib/video-channel.ts +++ b/server/server/lib/video-channel.ts @@ -1,11 +1,11 @@ import * as Sequelize from 'sequelize' -import { VideoChannelCreate } from '../../shared/models' -import { VideoModel } from '../models/video/video' -import { VideoChannelModel } from '../models/video/video-channel' -import { MAccountId, MChannelId } from '../types/models' -import { getLocalVideoChannelActivityPubUrl } from './activitypub/url' -import { federateVideoIfNeeded } from './activitypub/videos' -import { buildActorInstance } from './local-actor' +import { VideoChannelCreate } from '@peertube/peertube-models' +import { VideoChannelModel } from '../models/video/video-channel.js' +import { VideoModel } from '../models/video/video.js' +import { MAccountId, MChannelId } from '../types/models/index.js' +import { getLocalVideoChannelActivityPubUrl } from './activitypub/url.js' +import { federateVideoIfNeeded } from './activitypub/videos/index.js' +import { buildActorInstance } from './local-actor.js' async function createLocalVideoChannel (videoChannelInfo: VideoChannelCreate, account: MAccountId, t: Sequelize.Transaction) { const url = getLocalVideoChannelActivityPubUrl(videoChannelInfo.name) diff --git a/server/lib/video-comment.ts b/server/server/lib/video-comment.ts similarity index 90% rename from server/lib/video-comment.ts rename to server/server/lib/video-comment.ts index 6eb865f7f..f89215671 100644 --- a/server/lib/video-comment.ts +++ b/server/server/lib/video-comment.ts @@ -1,11 +1,10 @@ +import { ResultList, VideoCommentThreadTree } from '@peertube/peertube-models' +import { logger } from '@server/helpers/logger.js' +import { sequelizeTypescript } from '@server/initializers/database.js' import express from 'express' -import { cloneDeep } from 'lodash' +import cloneDeep from 'lodash-es/cloneDeep.js' import * as Sequelize from 'sequelize' -import { logger } from '@server/helpers/logger' -import { sequelizeTypescript } from '@server/initializers/database' -import { ResultList } from '../../shared/models' -import { VideoCommentThreadTree } from '../../shared/models/videos/comment/video-comment.model' -import { VideoCommentModel } from '../models/video/video-comment' +import { VideoCommentModel } from '../models/video/video-comment.js' import { MAccountDefault, MComment, @@ -13,10 +12,10 @@ import { MCommentOwnerVideo, MCommentOwnerVideoReply, MVideoFullLight -} from '../types/models' -import { sendCreateVideoComment, sendDeleteVideoComment } from './activitypub/send' -import { getLocalVideoCommentActivityPubUrl } from './activitypub/url' -import { Hooks } from './plugins/hooks' +} from '../types/models/index.js' +import { sendCreateVideoComment, sendDeleteVideoComment } from './activitypub/send/index.js' +import { getLocalVideoCommentActivityPubUrl } from './activitypub/url.js' +import { Hooks } from './plugins/hooks.js' async function removeComment (commentArg: MComment, req: express.Request, res: express.Response) { let videoCommentInstanceBefore: MCommentOwnerVideo diff --git a/server/lib/video-file.ts b/server/server/lib/video-file.ts similarity index 87% rename from server/lib/video-file.ts rename to server/server/lib/video-file.ts index 46af67ccd..9d8a6e8fc 100644 --- a/server/lib/video-file.ts +++ b/server/server/lib/video-file.ts @@ -1,14 +1,13 @@ import { FfprobeData } from 'fluent-ffmpeg' -import { logger } from '@server/helpers/logger' -import { VideoFileModel } from '@server/models/video/video-file' -import { MVideoWithAllFiles } from '@server/types/models' -import { getLowercaseExtension } from '@shared/core-utils' -import { getFileSize } from '@shared/extra-utils' -import { ffprobePromise, getVideoStreamDimensionsInfo, getVideoStreamFPS, isAudioFile } from '@shared/ffmpeg' -import { VideoFileMetadata, VideoResolution } from '@shared/models' -import { lTags } from './object-storage/shared' -import { generateHLSVideoFilename, generateWebVideoFilename } from './paths' -import { VideoPathManager } from './video-path-manager' +import { VideoFileMetadata, VideoResolution } from '@peertube/peertube-models' +import { logger } from '@server/helpers/logger.js' +import { VideoFileModel } from '@server/models/video/video-file.js' +import { MVideoWithAllFiles } from '@server/types/models/index.js' +import { getFileSize, getLowercaseExtension } from '@peertube/peertube-node-utils' +import { ffprobePromise, getVideoStreamDimensionsInfo, getVideoStreamFPS, isAudioFile } from '@peertube/peertube-ffmpeg' +import { lTags } from './object-storage/shared/index.js' +import { generateHLSVideoFilename, generateWebVideoFilename } from './paths.js' +import { VideoPathManager } from './video-path-manager.js' async function buildNewFile (options: { path: string diff --git a/server/lib/video-path-manager.ts b/server/server/lib/video-path-manager.ts similarity index 88% rename from server/lib/video-path-manager.ts rename to server/server/lib/video-path-manager.ts index 133544bb2..0a8604a58 100644 --- a/server/lib/video-path-manager.ts +++ b/server/server/lib/video-path-manager.ts @@ -1,16 +1,22 @@ import { Mutex } from 'async-mutex' -import { remove } from 'fs-extra' +import { remove } from 'fs-extra/esm' import { extname, join } from 'path' -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { extractVideo } from '@server/helpers/video' -import { CONFIG } from '@server/initializers/config' -import { DIRECTORIES } from '@server/initializers/constants' -import { MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoFileStreamingPlaylistVideo, MVideoFileVideo } from '@server/types/models' -import { buildUUID } from '@shared/extra-utils' -import { VideoStorage } from '@shared/models' -import { makeHLSFileAvailable, makeWebVideoFileAvailable } from './object-storage' -import { getHLSDirectory, getHLSRedundancyDirectory, getHlsResolutionPlaylistFilename } from './paths' -import { isVideoInPrivateDirectory } from './video-privacy' +import { VideoStorage } from '@peertube/peertube-models' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { extractVideo } from '@server/helpers/video.js' +import { CONFIG } from '@server/initializers/config.js' +import { DIRECTORIES } from '@server/initializers/constants.js' +import { + MStreamingPlaylistVideo, + MVideo, + MVideoFile, + MVideoFileStreamingPlaylistVideo, + MVideoFileVideo +} from '@server/types/models/index.js' +import { buildUUID } from '@peertube/peertube-node-utils' +import { makeHLSFileAvailable, makeWebVideoFileAvailable } from './object-storage/index.js' +import { getHLSDirectory, getHLSRedundancyDirectory, getHlsResolutionPlaylistFilename } from './paths.js' +import { isVideoInPrivateDirectory } from './video-privacy.js' type MakeAvailableCB = (path: string) => Promise | T diff --git a/server/lib/video-playlist.ts b/server/server/lib/video-playlist.ts similarity index 77% rename from server/lib/video-playlist.ts rename to server/server/lib/video-playlist.ts index a1af2e1af..5c97f9c9a 100644 --- a/server/lib/video-playlist.ts +++ b/server/server/lib/video-playlist.ts @@ -1,10 +1,9 @@ import * as Sequelize from 'sequelize' -import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model' -import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model' -import { VideoPlaylistModel } from '../models/video/video-playlist' -import { MAccount } from '../types/models' -import { MVideoPlaylistOwner } from '../types/models/video/video-playlist' -import { getLocalVideoPlaylistActivityPubUrl } from './activitypub/url' +import { VideoPlaylistPrivacy, VideoPlaylistType } from '@peertube/peertube-models' +import { VideoPlaylistModel } from '../models/video/video-playlist.js' +import { MAccount } from '../types/models/index.js' +import { MVideoPlaylistOwner } from '../types/models/video/video-playlist.js' +import { getLocalVideoPlaylistActivityPubUrl } from './activitypub/url.js' async function createWatchLaterPlaylist (account: MAccount, t: Sequelize.Transaction) { const videoPlaylist: MVideoPlaylistOwner = new VideoPlaylistModel({ diff --git a/server/lib/video-pre-import.ts b/server/server/lib/video-pre-import.ts similarity index 91% rename from server/lib/video-pre-import.ts rename to server/server/lib/video-pre-import.ts index fcb9f77d7..0298e121e 100644 --- a/server/lib/video-pre-import.ts +++ b/server/server/lib/video-pre-import.ts @@ -1,20 +1,30 @@ -import { remove } from 'fs-extra' -import { moveAndProcessCaptionFile } from '@server/helpers/captions-utils' -import { isVTTFileValid } from '@server/helpers/custom-validators/video-captions' -import { isVideoFileExtnameValid } from '@server/helpers/custom-validators/videos' -import { isResolvingToUnicastOnly } from '@server/helpers/dns' -import { logger } from '@server/helpers/logger' -import { YoutubeDLInfo, YoutubeDLWrapper } from '@server/helpers/youtube-dl' -import { CONFIG } from '@server/initializers/config' -import { sequelizeTypescript } from '@server/initializers/database' -import { Hooks } from '@server/lib/plugins/hooks' -import { ServerConfigManager } from '@server/lib/server-config-manager' -import { setVideoTags } from '@server/lib/video' -import { autoBlacklistVideoIfNeeded } from '@server/lib/video-blacklist' -import { VideoModel } from '@server/models/video/video' -import { VideoCaptionModel } from '@server/models/video/video-caption' -import { VideoImportModel } from '@server/models/video/video-import' -import { FilteredModelAttributes } from '@server/types' +import { remove } from 'fs-extra/esm' +import { + ThumbnailType, + ThumbnailType_Type, + VideoImportCreate, + VideoImportPayload, + VideoImportState, + VideoPrivacy, + VideoState +} from '@peertube/peertube-models' +import { moveAndProcessCaptionFile } from '@server/helpers/captions-utils.js' +import { isVTTFileValid } from '@server/helpers/custom-validators/video-captions.js' +import { isVideoFileExtnameValid } from '@server/helpers/custom-validators/videos.js' +import { isResolvingToUnicastOnly } from '@server/helpers/dns.js' +import { logger } from '@server/helpers/logger.js' +import { YoutubeDLInfo, YoutubeDLWrapper } from '@server/helpers/youtube-dl/index.js' +import { CONFIG } from '@server/initializers/config.js' +import { sequelizeTypescript } from '@server/initializers/database.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { ServerConfigManager } from '@server/lib/server-config-manager.js' +import { autoBlacklistVideoIfNeeded } from '@server/lib/video-blacklist.js' +import { setVideoTags } from '@server/lib/video.js' +import { VideoCaptionModel } from '@server/models/video/video-caption.js' +import { VideoImportModel } from '@server/models/video/video-import.js' +import { VideoPasswordModel } from '@server/models/video/video-password.js' +import { VideoModel } from '@server/models/video/video.js' +import { FilteredModelAttributes } from '@server/types/index.js' import { MChannelAccountDefault, MChannelSync, @@ -26,11 +36,9 @@ import { MVideoTag, MVideoThumbnail, MVideoWithBlacklistLight -} from '@server/types/models' -import { ThumbnailType, VideoImportCreate, VideoImportPayload, VideoImportState, VideoPrivacy, VideoState } from '@shared/models' -import { getLocalVideoActivityPubUrl } from './activitypub/url' -import { updateLocalVideoMiniatureFromExisting, updateLocalVideoMiniatureFromUrl } from './thumbnail' -import { VideoPasswordModel } from '@server/models/video/video-password' +} from '@server/types/models/index.js' +import { getLocalVideoActivityPubUrl } from './activitypub/url.js' +import { updateLocalVideoMiniatureFromExisting, updateLocalVideoMiniatureFromUrl } from './thumbnail.js' class YoutubeDlImportError extends Error { code: YoutubeDlImportError.CODE @@ -254,7 +262,7 @@ async function forgeThumbnail ({ inputPath, video, downloadUrl, type }: { inputPath?: string downloadUrl?: string video: MVideoThumbnail - type: ThumbnailType + type: ThumbnailType_Type }): Promise { if (inputPath) { return updateLocalVideoMiniatureFromExisting({ diff --git a/server/lib/video-privacy.ts b/server/server/lib/video-privacy.ts similarity index 90% rename from server/lib/video-privacy.ts rename to server/server/lib/video-privacy.ts index 5dd4d9781..df8ac974b 100644 --- a/server/lib/video-privacy.ts +++ b/server/server/lib/video-privacy.ts @@ -1,10 +1,10 @@ -import { move } from 'fs-extra' +import { move } from 'fs-extra/esm' import { join } from 'path' -import { logger } from '@server/helpers/logger' -import { DIRECTORIES } from '@server/initializers/constants' -import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models' -import { VideoPrivacy, VideoStorage } from '@shared/models' -import { updateHLSFilesACL, updateWebVideoFileACL } from './object-storage' +import { VideoPrivacy, VideoPrivacyType, VideoStorage } from '@peertube/peertube-models' +import { logger } from '@server/helpers/logger.js' +import { DIRECTORIES } from '@server/initializers/constants.js' +import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models/index.js' +import { updateHLSFilesACL, updateWebVideoFileACL } from './object-storage/index.js' const validPrivacySet = new Set([ VideoPrivacy.PRIVATE, @@ -12,7 +12,7 @@ const validPrivacySet = new Set([ VideoPrivacy.PASSWORD_PROTECTED ]) -function setVideoPrivacy (video: MVideo, newPrivacy: VideoPrivacy) { +function setVideoPrivacy (video: MVideo, newPrivacy: VideoPrivacyType) { if (video.privacy === VideoPrivacy.PRIVATE && newPrivacy !== VideoPrivacy.PRIVATE) { video.publishedAt = new Date() } @@ -24,11 +24,11 @@ function isVideoInPrivateDirectory (privacy) { return validPrivacySet.has(privacy) } -function isVideoInPublicDirectory (privacy: VideoPrivacy) { +function isVideoInPublicDirectory (privacy: VideoPrivacyType) { return !isVideoInPrivateDirectory(privacy) } -async function moveFilesIfPrivacyChanged (video: MVideoFullLight, oldPrivacy: VideoPrivacy) { +async function moveFilesIfPrivacyChanged (video: MVideoFullLight, oldPrivacy: VideoPrivacyType) { // Now public, previously private if (isVideoInPublicDirectory(video.privacy) && isVideoInPrivateDirectory(oldPrivacy)) { await moveFiles({ type: 'private-to-public', video }) diff --git a/server/lib/video-state.ts b/server/server/lib/video-state.ts similarity index 87% rename from server/lib/video-state.ts rename to server/server/lib/video-state.ts index 893725d85..3b17877af 100644 --- a/server/lib/video-state.ts +++ b/server/server/lib/video-state.ts @@ -1,18 +1,18 @@ import { Transaction } from 'sequelize' -import { retryTransactionWrapper } from '@server/helpers/database-utils' -import { logger } from '@server/helpers/logger' -import { CONFIG } from '@server/initializers/config' -import { sequelizeTypescript } from '@server/initializers/database' -import { VideoModel } from '@server/models/video/video' -import { VideoJobInfoModel } from '@server/models/video/video-job-info' -import { MVideo, MVideoFullLight, MVideoUUID } from '@server/types/models' -import { VideoState } from '@shared/models' -import { federateVideoIfNeeded } from './activitypub/videos' -import { JobQueue } from './job-queue' -import { Notifier } from './notifier' -import { buildMoveToObjectStorageJob } from './video' +import { VideoState, VideoStateType } from '@peertube/peertube-models' +import { retryTransactionWrapper } from '@server/helpers/database-utils.js' +import { logger } from '@server/helpers/logger.js' +import { CONFIG } from '@server/initializers/config.js' +import { sequelizeTypescript } from '@server/initializers/database.js' +import { VideoJobInfoModel } from '@server/models/video/video-job-info.js' +import { VideoModel } from '@server/models/video/video.js' +import { MVideo, MVideoFullLight, MVideoUUID } from '@server/types/models/index.js' +import { federateVideoIfNeeded } from './activitypub/videos/index.js' +import { JobQueue } from './job-queue/index.js' +import { Notifier } from './notifier/index.js' +import { buildMoveToObjectStorageJob } from './video.js' -function buildNextVideoState (currentState?: VideoState) { +function buildNextVideoState (currentState?: VideoStateType) { if (currentState === VideoState.PUBLISHED) { throw new Error('Video is already in its final state') } @@ -38,7 +38,7 @@ function buildNextVideoState (currentState?: VideoState) { function moveToNextState (options: { video: MVideoUUID - previousVideoState?: VideoState + previousVideoState?: VideoStateType isNewVideo?: boolean // Default true }) { const { video, previousVideoState, isNewVideo = true } = options @@ -128,7 +128,7 @@ async function moveToPublishedState (options: { video: MVideoFullLight isNewVideo: boolean transaction: Transaction - previousVideoState?: VideoState + previousVideoState?: VideoStateType }) { const { video, isNewVideo, transaction, previousVideoState } = options const previousState = previousVideoState ?? video.state diff --git a/server/lib/video-studio.ts b/server/server/lib/video-studio.ts similarity index 86% rename from server/lib/video-studio.ts rename to server/server/lib/video-studio.ts index f549a7084..79b07cf4a 100644 --- a/server/lib/video-studio.ts +++ b/server/server/lib/video-studio.ts @@ -1,19 +1,19 @@ -import { move, remove } from 'fs-extra' +import { move, remove } from 'fs-extra/esm' import { join } from 'path' -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { createTorrentAndSetInfoHashFromPath } from '@server/helpers/webtorrent' -import { CONFIG } from '@server/initializers/config' -import { UserModel } from '@server/models/user/user' -import { MUser, MVideo, MVideoFile, MVideoFullLight, MVideoWithAllFiles } from '@server/types/models' -import { getVideoStreamDuration } from '@shared/ffmpeg' -import { VideoStudioEditionPayload, VideoStudioTask, VideoStudioTaskPayload } from '@shared/models' -import { federateVideoIfNeeded } from './activitypub/videos' -import { JobQueue } from './job-queue' -import { VideoStudioTranscodingJobHandler } from './runners' -import { createOptimizeOrMergeAudioJobs } from './transcoding/create-transcoding-job' -import { getTranscodingJobPriority } from './transcoding/transcoding-priority' -import { buildNewFile, removeHLSPlaylist, removeWebVideoFile } from './video-file' -import { VideoPathManager } from './video-path-manager' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { createTorrentAndSetInfoHashFromPath } from '@server/helpers/webtorrent.js' +import { CONFIG } from '@server/initializers/config.js' +import { UserModel } from '@server/models/user/user.js' +import { MUser, MVideo, MVideoFile, MVideoFullLight, MVideoWithAllFiles } from '@server/types/models/index.js' +import { getVideoStreamDuration } from '@peertube/peertube-ffmpeg' +import { VideoStudioEditionPayload, VideoStudioTask, VideoStudioTaskPayload } from '@peertube/peertube-models' +import { federateVideoIfNeeded } from './activitypub/videos/index.js' +import { JobQueue } from './job-queue/index.js' +import { VideoStudioTranscodingJobHandler } from './runners/index.js' +import { createOptimizeOrMergeAudioJobs } from './transcoding/create-transcoding-job.js' +import { getTranscodingJobPriority } from './transcoding/transcoding-priority.js' +import { buildNewFile, removeHLSPlaylist, removeWebVideoFile } from './video-file.js' +import { VideoPathManager } from './video-path-manager.js' const lTags = loggerTagsFactory('video-studio') diff --git a/server/lib/video-tokens-manager.ts b/server/server/lib/video-tokens-manager.ts similarity index 88% rename from server/lib/video-tokens-manager.ts rename to server/server/lib/video-tokens-manager.ts index e28e55cf7..57128721a 100644 --- a/server/lib/video-tokens-manager.ts +++ b/server/server/lib/video-tokens-manager.ts @@ -1,8 +1,8 @@ import { LRUCache } from 'lru-cache' -import { LRU_CACHE } from '@server/initializers/constants' -import { MUserAccountUrl } from '@server/types/models' -import { pick } from '@shared/core-utils' -import { buildUUID } from '@shared/extra-utils' +import { LRU_CACHE } from '@server/initializers/constants.js' +import { MUserAccountUrl } from '@server/types/models/index.js' +import { pick } from '@peertube/peertube-core-utils' +import { buildUUID } from '@peertube/peertube-node-utils' // --------------------------------------------------------------------------- // Create temporary tokens that can be used as URL query parameters to access video static files diff --git a/server/lib/video-urls.ts b/server/server/lib/video-urls.ts similarity index 95% rename from server/lib/video-urls.ts rename to server/server/lib/video-urls.ts index 0597488ad..bf399847e 100644 --- a/server/lib/video-urls.ts +++ b/server/server/lib/video-urls.ts @@ -1,6 +1,6 @@ -import { STATIC_PATHS, WEBSERVER } from '@server/initializers/constants' -import { MStreamingPlaylist, MVideo, MVideoFile, MVideoUUID } from '@server/types/models' +import { STATIC_PATHS, WEBSERVER } from '@server/initializers/constants.js' +import { MStreamingPlaylist, MVideo, MVideoFile, MVideoUUID } from '@server/types/models/index.js' // ################## Redundancy ################## diff --git a/server/lib/video.ts b/server/server/lib/video.ts similarity index 84% rename from server/lib/video.ts rename to server/server/lib/video.ts index 362c861a5..46346c3ed 100644 --- a/server/lib/video.ts +++ b/server/server/lib/video.ts @@ -1,17 +1,25 @@ import { UploadFiles } from 'express' import memoizee from 'memoizee' -import { Transaction } from 'sequelize/types' -import { CONFIG } from '@server/initializers/config' -import { MEMOIZE_LENGTH, MEMOIZE_TTL } from '@server/initializers/constants' -import { TagModel } from '@server/models/video/tag' -import { VideoModel } from '@server/models/video/video' -import { VideoJobInfoModel } from '@server/models/video/video-job-info' -import { FilteredModelAttributes } from '@server/types' -import { MThumbnail, MVideoFullLight, MVideoTag, MVideoThumbnail, MVideoUUID } from '@server/types/models' -import { ManageVideoTorrentPayload, ThumbnailType, VideoCreate, VideoPrivacy, VideoState } from '@shared/models' -import { CreateJobArgument, JobQueue } from './job-queue/job-queue' -import { updateLocalVideoMiniatureFromExisting } from './thumbnail' -import { moveFilesIfPrivacyChanged } from './video-privacy' +import { Transaction } from 'sequelize' +import { + ManageVideoTorrentPayload, + ThumbnailType, + ThumbnailType_Type, + VideoCreate, + VideoPrivacy, + VideoPrivacyType, + VideoStateType +} from '@peertube/peertube-models' +import { CONFIG } from '@server/initializers/config.js' +import { MEMOIZE_LENGTH, MEMOIZE_TTL } from '@server/initializers/constants.js' +import { TagModel } from '@server/models/video/tag.js' +import { VideoJobInfoModel } from '@server/models/video/video-job-info.js' +import { VideoModel } from '@server/models/video/video.js' +import { FilteredModelAttributes } from '@server/types/index.js' +import { MThumbnail, MVideoFullLight, MVideoTag, MVideoThumbnail, MVideoUUID } from '@server/types/models/index.js' +import { CreateJobArgument, JobQueue } from './job-queue/job-queue.js' +import { updateLocalVideoMiniatureFromExisting } from './thumbnail.js' +import { moveFilesIfPrivacyChanged } from './video-privacy.js' function buildLocalVideoFromReq (videoInfo: VideoCreate, channelId: number): FilteredModelAttributes { return { @@ -37,7 +45,7 @@ function buildLocalVideoFromReq (videoInfo: VideoCreate, channelId: number): Fil async function buildVideoThumbnailsFromReq (options: { video: MVideoThumbnail files: UploadFiles - fallback: (type: ThumbnailType) => Promise + fallback: (type: ThumbnailType_Type) => Promise automaticallyGenerated?: boolean }) { const { video, files, fallback, automaticallyGenerated } = options @@ -89,7 +97,7 @@ async function setVideoTags (options: { async function buildMoveToObjectStorageJob (options: { video: MVideoUUID - previousVideoState: VideoState + previousVideoState: VideoStateType isNewVideo?: boolean // Default true }) { const { video, previousVideoState, isNewVideo = true } = options @@ -131,7 +139,7 @@ async function addVideoJobsAfterUpdate (options: { isNewVideo: boolean nameChanged: boolean - oldPrivacy: VideoPrivacy + oldPrivacy: VideoPrivacyType }) { const { video, nameChanged, oldPrivacy, isNewVideo } = options const jobs: CreateJobArgument[] = [] @@ -162,7 +170,11 @@ async function addVideoJobsAfterUpdate (options: { } }) - const wasConfidentialVideo = new Set([ VideoPrivacy.PRIVATE, VideoPrivacy.UNLISTED, VideoPrivacy.INTERNAL ]).has(oldPrivacy) + const wasConfidentialVideo = new Set([ + VideoPrivacy.PRIVATE, + VideoPrivacy.UNLISTED, + VideoPrivacy.INTERNAL + ]).has(oldPrivacy) if (wasConfidentialVideo) { jobs.push({ diff --git a/server/server/lib/views/shared/index.ts b/server/server/lib/views/shared/index.ts new file mode 100644 index 000000000..e311fb22f --- /dev/null +++ b/server/server/lib/views/shared/index.ts @@ -0,0 +1,3 @@ +export * from './video-viewer-counters.js' +export * from './video-viewer-stats.js' +export * from './video-views.js' diff --git a/server/lib/views/shared/video-viewer-counters.ts b/server/server/lib/views/shared/video-viewer-counters.ts similarity index 93% rename from server/lib/views/shared/video-viewer-counters.ts rename to server/server/lib/views/shared/video-viewer-counters.ts index f5b83130e..605e45645 100644 --- a/server/lib/views/shared/video-viewer-counters.ts +++ b/server/server/lib/views/shared/video-viewer-counters.ts @@ -1,12 +1,11 @@ -import { isTestOrDevInstance } from '@server/helpers/core-utils' -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { VIEW_LIFETIME } from '@server/initializers/constants' -import { sendView } from '@server/lib/activitypub/send/send-view' -import { PeerTubeSocket } from '@server/lib/peertube-socket' -import { getServerActor } from '@server/models/application/application' -import { VideoModel } from '@server/models/video/video' -import { MVideo, MVideoImmutable } from '@server/types/models' -import { buildUUID, sha256 } from '@shared/extra-utils' +import { buildUUID, isTestOrDevInstance, sha256 } from '@peertube/peertube-node-utils' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { VIEW_LIFETIME } from '@server/initializers/constants.js' +import { sendView } from '@server/lib/activitypub/send/send-view.js' +import { PeerTubeSocket } from '@server/lib/peertube-socket.js' +import { getServerActor } from '@server/models/application/application.js' +import { VideoModel } from '@server/models/video/video.js' +import { MVideo, MVideoImmutable } from '@server/types/models/index.js' const lTags = loggerTagsFactory('views') diff --git a/server/lib/views/shared/video-viewer-stats.ts b/server/server/lib/views/shared/video-viewer-stats.ts similarity index 91% rename from server/lib/views/shared/video-viewer-stats.ts rename to server/server/lib/views/shared/video-viewer-stats.ts index ebd963e59..35ef5a7ea 100644 --- a/server/lib/views/shared/video-viewer-stats.ts +++ b/server/server/lib/views/shared/video-viewer-stats.ts @@ -1,17 +1,17 @@ -import { Transaction } from 'sequelize/types' -import { isTestOrDevInstance } from '@server/helpers/core-utils' -import { GeoIP } from '@server/helpers/geo-ip' -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { MAX_LOCAL_VIEWER_WATCH_SECTIONS, VIEW_LIFETIME } from '@server/initializers/constants' -import { sequelizeTypescript } from '@server/initializers/database' -import { sendCreateWatchAction } from '@server/lib/activitypub/send' -import { getLocalVideoViewerActivityPubUrl } from '@server/lib/activitypub/url' -import { Redis } from '@server/lib/redis' -import { VideoModel } from '@server/models/video/video' -import { LocalVideoViewerModel } from '@server/models/view/local-video-viewer' -import { LocalVideoViewerWatchSectionModel } from '@server/models/view/local-video-viewer-watch-section' -import { MVideo, MVideoImmutable } from '@server/types/models' -import { VideoViewEvent } from '@shared/models' +import { Transaction } from 'sequelize' +import { VideoViewEvent } from '@peertube/peertube-models' +import { isTestOrDevInstance } from '@peertube/peertube-node-utils' +import { GeoIP } from '@server/helpers/geo-ip.js' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { MAX_LOCAL_VIEWER_WATCH_SECTIONS, VIEW_LIFETIME } from '@server/initializers/constants.js' +import { sequelizeTypescript } from '@server/initializers/database.js' +import { sendCreateWatchAction } from '@server/lib/activitypub/send/index.js' +import { getLocalVideoViewerActivityPubUrl } from '@server/lib/activitypub/url.js' +import { Redis } from '@server/lib/redis.js' +import { VideoModel } from '@server/models/video/video.js' +import { LocalVideoViewerWatchSectionModel } from '@server/models/view/local-video-viewer-watch-section.js' +import { LocalVideoViewerModel } from '@server/models/view/local-video-viewer.js' +import { MVideo, MVideoImmutable } from '@server/types/models/index.js' const lTags = loggerTagsFactory('views') diff --git a/server/lib/views/shared/video-views.ts b/server/server/lib/views/shared/video-views.ts similarity index 87% rename from server/lib/views/shared/video-views.ts rename to server/server/lib/views/shared/video-views.ts index e563287e1..ee56e30bc 100644 --- a/server/lib/views/shared/video-views.ts +++ b/server/server/lib/views/shared/video-views.ts @@ -1,10 +1,10 @@ -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { sendView } from '@server/lib/activitypub/send/send-view' -import { getCachedVideoDuration } from '@server/lib/video' -import { getServerActor } from '@server/models/application/application' -import { MVideo, MVideoImmutable } from '@server/types/models' -import { buildUUID } from '@shared/extra-utils' -import { Redis } from '../../redis' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { sendView } from '@server/lib/activitypub/send/send-view.js' +import { getCachedVideoDuration } from '@server/lib/video.js' +import { getServerActor } from '@server/models/application/application.js' +import { MVideo, MVideoImmutable } from '@server/types/models/index.js' +import { buildUUID } from '@peertube/peertube-node-utils' +import { Redis } from '../../redis.js' const lTags = loggerTagsFactory('views') diff --git a/server/lib/views/video-views-manager.ts b/server/server/lib/views/video-views-manager.ts similarity index 94% rename from server/lib/views/video-views-manager.ts rename to server/server/lib/views/video-views-manager.ts index c088dad5e..9fc76d55e 100644 --- a/server/lib/views/video-views-manager.ts +++ b/server/server/lib/views/video-views-manager.ts @@ -1,7 +1,7 @@ -import { logger, loggerTagsFactory } from '@server/helpers/logger' -import { MVideo, MVideoImmutable } from '@server/types/models' -import { VideoViewEvent } from '@shared/models' -import { VideoScope, VideoViewerCounters, VideoViewerStats, VideoViews, ViewerScope } from './shared' +import { logger, loggerTagsFactory } from '@server/helpers/logger.js' +import { MVideo, MVideoImmutable } from '@server/types/models/index.js' +import { VideoViewEvent } from '@peertube/peertube-models' +import { VideoScope, VideoViewerCounters, VideoViewerStats, VideoViews, ViewerScope } from './shared/index.js' /** * If processing a local view: diff --git a/server/lib/worker/parent-process.ts b/server/server/lib/worker/parent-process.ts similarity index 82% rename from server/lib/worker/parent-process.ts rename to server/server/lib/worker/parent-process.ts index 48b6c682b..2b56b4526 100644 --- a/server/lib/worker/parent-process.ts +++ b/server/server/lib/worker/parent-process.ts @@ -1,16 +1,16 @@ import { join } from 'path' import Piscina from 'piscina' -import { processImage } from '@server/helpers/image-utils' -import { JOB_CONCURRENCY, WORKER_THREADS } from '@server/initializers/constants' -import { httpBroadcast } from './workers/http-broadcast' -import { downloadImage } from './workers/image-downloader' +import { JOB_CONCURRENCY, WORKER_THREADS } from '@server/initializers/constants.js' +import httpBroadcast from './workers/http-broadcast.js' +import downloadImage from './workers/image-downloader.js' +import processImage from './workers/image-processor.js' let downloadImageWorker: Piscina function downloadImageFromWorker (options: Parameters[0]): Promise> { if (!downloadImageWorker) { downloadImageWorker = new Piscina({ - filename: join(__dirname, 'workers', 'image-downloader.js'), + filename: new URL(join('workers', 'image-downloader.js'), import.meta.url).href, concurrentTasksPerWorker: WORKER_THREADS.DOWNLOAD_IMAGE.CONCURRENCY, maxThreads: WORKER_THREADS.DOWNLOAD_IMAGE.MAX_THREADS }) @@ -26,7 +26,7 @@ let processImageWorker: Piscina function processImageFromWorker (options: Parameters[0]): Promise> { if (!processImageWorker) { processImageWorker = new Piscina({ - filename: join(__dirname, 'workers', 'image-processor.js'), + filename: new URL(join('workers', 'image-processor.js'), import.meta.url).href, concurrentTasksPerWorker: WORKER_THREADS.PROCESS_IMAGE.CONCURRENCY, maxThreads: WORKER_THREADS.PROCESS_IMAGE.MAX_THREADS }) @@ -42,7 +42,7 @@ let parallelHTTPBroadcastWorker: Piscina function parallelHTTPBroadcastFromWorker (options: Parameters[0]): Promise> { if (!parallelHTTPBroadcastWorker) { parallelHTTPBroadcastWorker = new Piscina({ - filename: join(__dirname, 'workers', 'http-broadcast.js'), + filename: new URL(join('workers', 'http-broadcast.js'), import.meta.url).href, // Keep it sync with job concurrency so the worker will accept all the requests sent by the parallelized jobs concurrentTasksPerWorker: JOB_CONCURRENCY['activitypub-http-broadcast-parallel'], maxThreads: 1 @@ -59,7 +59,7 @@ let sequentialHTTPBroadcastWorker: Piscina function sequentialHTTPBroadcastFromWorker (options: Parameters[0]): Promise> { if (!sequentialHTTPBroadcastWorker) { sequentialHTTPBroadcastWorker = new Piscina({ - filename: join(__dirname, 'workers', 'http-broadcast.js'), + filename: new URL(join('workers', 'http-broadcast.js'), import.meta.url).href, // Keep it sync with job concurrency so the worker will accept all the requests sent by the parallelized jobs concurrentTasksPerWorker: JOB_CONCURRENCY['activitypub-http-broadcast'], maxThreads: 1 diff --git a/server/lib/worker/workers/http-broadcast.ts b/server/server/lib/worker/workers/http-broadcast.ts similarity index 76% rename from server/lib/worker/workers/http-broadcast.ts rename to server/server/lib/worker/workers/http-broadcast.ts index 8c9c6b8ca..29895a00a 100644 --- a/server/lib/worker/workers/http-broadcast.ts +++ b/server/server/lib/worker/workers/http-broadcast.ts @@ -1,7 +1,7 @@ -import { map } from 'bluebird' -import { logger } from '@server/helpers/logger' -import { doRequest, PeerTubeRequestOptions } from '@server/helpers/requests' -import { BROADCAST_CONCURRENCY } from '@server/initializers/constants' +import Bluebird from 'bluebird' +import { logger } from '@server/helpers/logger.js' +import { doRequest, PeerTubeRequestOptions } from '@server/helpers/requests.js' +import { BROADCAST_CONCURRENCY } from '@server/initializers/constants.js' async function httpBroadcast (payload: { uris: string[] @@ -12,7 +12,7 @@ async function httpBroadcast (payload: { const badUrls: string[] = [] const goodUrls: string[] = [] - await map(uris, async uri => { + await Bluebird.map(uris, async uri => { try { await doRequest(uri, requestOptions) goodUrls.push(uri) @@ -25,8 +25,4 @@ async function httpBroadcast (payload: { return { goodUrls, badUrls } } -module.exports = httpBroadcast - -export { - httpBroadcast -} +export default httpBroadcast diff --git a/server/lib/worker/workers/image-downloader.ts b/server/server/lib/worker/workers/image-downloader.ts similarity index 74% rename from server/lib/worker/workers/image-downloader.ts rename to server/server/lib/worker/workers/image-downloader.ts index 209594589..c75acf0cd 100644 --- a/server/lib/worker/workers/image-downloader.ts +++ b/server/server/lib/worker/workers/image-downloader.ts @@ -1,8 +1,8 @@ -import { remove } from 'fs-extra' +import { remove } from 'fs-extra/esm' import { join } from 'path' -import { processImage } from '@server/helpers/image-utils' -import { doRequestAndSaveToFile } from '@server/helpers/requests' -import { CONFIG } from '@server/initializers/config' +import { processImage } from '@server/helpers/image-utils.js' +import { doRequestAndSaveToFile } from '@server/helpers/requests.js' +import { CONFIG } from '@server/initializers/config.js' async function downloadImage (options: { url: string @@ -28,8 +28,4 @@ async function downloadImage (options: { return destPath } -module.exports = downloadImage - -export { - downloadImage -} +export default downloadImage diff --git a/server/server/lib/worker/workers/image-processor.ts b/server/server/lib/worker/workers/image-processor.ts new file mode 100644 index 000000000..6aa8dcc29 --- /dev/null +++ b/server/server/lib/worker/workers/image-processor.ts @@ -0,0 +1,3 @@ +import { processImage } from '@server/helpers/image-utils.js' + +export default processImage diff --git a/server/middlewares/activitypub.ts b/server/server/middlewares/activitypub.ts similarity index 93% rename from server/middlewares/activitypub.ts rename to server/server/middlewares/activitypub.ts index 261b9f690..0d333061e 100644 --- a/server/middlewares/activitypub.ts +++ b/server/server/middlewares/activitypub.ts @@ -1,12 +1,12 @@ import { NextFunction, Request, Response } from 'express' -import { isActorDeleteActivityValid } from '@server/helpers/custom-validators/activitypub/actor' -import { getAPId } from '@server/lib/activitypub/activity' -import { wrapWithSpanAndContext } from '@server/lib/opentelemetry/tracing' -import { ActivityDelete, ActivityPubSignature, HttpStatusCode } from '@shared/models' -import { logger } from '../helpers/logger' -import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../helpers/peertube-crypto' -import { ACCEPT_HEADERS, ACTIVITY_PUB, HTTP_SIGNATURE } from '../initializers/constants' -import { getOrCreateAPActor, loadActorUrlOrGetFromWebfinger } from '../lib/activitypub/actors' +import { isActorDeleteActivityValid } from '@server/helpers/custom-validators/activitypub/actor.js' +import { getAPId } from '@server/lib/activitypub/activity.js' +import { wrapWithSpanAndContext } from '@server/lib/opentelemetry/tracing.js' +import { ActivityDelete, ActivityPubSignature, HttpStatusCode } from '@peertube/peertube-models' +import { logger } from '../helpers/logger.js' +import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../helpers/peertube-crypto.js' +import { ACCEPT_HEADERS, ACTIVITY_PUB, HTTP_SIGNATURE } from '../initializers/constants.js' +import { getOrCreateAPActor, loadActorUrlOrGetFromWebfinger } from '../lib/activitypub/actors/index.js' async function checkSignature (req: Request, res: Response, next: NextFunction) { try { diff --git a/server/middlewares/async.ts b/server/server/middlewares/async.ts similarity index 98% rename from server/middlewares/async.ts rename to server/server/middlewares/async.ts index 7e131257d..b6997e31b 100644 --- a/server/middlewares/async.ts +++ b/server/server/middlewares/async.ts @@ -1,8 +1,8 @@ import Bluebird from 'bluebird' import { NextFunction, Request, RequestHandler, Response } from 'express' import { ValidationChain } from 'express-validator' -import { ExpressPromiseHandler } from '@server/types/express-handler' -import { retryTransactionWrapper } from '../helpers/database-utils' +import { ExpressPromiseHandler } from '@server/types/express-handler.js' +import { retryTransactionWrapper } from '../helpers/database-utils.js' // Syntactic sugar to avoid try/catch in express controllers/middlewares diff --git a/server/middlewares/auth.ts b/server/server/middlewares/auth.ts similarity index 88% rename from server/middlewares/auth.ts rename to server/server/middlewares/auth.ts index 39a7b2998..6eddd80bd 100644 --- a/server/middlewares/auth.ts +++ b/server/server/middlewares/auth.ts @@ -1,11 +1,10 @@ import express from 'express' import { Socket } from 'socket.io' -import { getAccessToken } from '@server/lib/auth/oauth-model' -import { RunnerModel } from '@server/models/runner/runner' -import { HttpStatusCode } from '../../shared/models/http/http-error-codes' -import { logger } from '../helpers/logger' -import { handleOAuthAuthenticate } from '../lib/auth/oauth' -import { ServerErrorCode } from '@shared/models' +import { HttpStatusCode, HttpStatusCodeType, ServerErrorCodeType } from '@peertube/peertube-models' +import { getAccessToken } from '@server/lib/auth/oauth-model.js' +import { RunnerModel } from '@server/models/runner/runner.js' +import { logger } from '../helpers/logger.js' +import { handleOAuthAuthenticate } from '../lib/auth/oauth.js' function authenticate (req: express.Request, res: express.Response, next: express.NextFunction) { handleOAuthAuthenticate(req, res) @@ -53,8 +52,8 @@ function authenticatePromise (options: { req: express.Request res: express.Response errorMessage?: string - errorStatus?: HttpStatusCode - errorType?: ServerErrorCode + errorStatus?: HttpStatusCodeType + errorType?: ServerErrorCodeType }) { const { req, res, errorMessage = 'Not authenticated', errorStatus = HttpStatusCode.UNAUTHORIZED_401, errorType } = options return new Promise(resolve => { diff --git a/server/middlewares/cache/cache.ts b/server/server/middlewares/cache/cache.ts similarity index 86% rename from server/middlewares/cache/cache.ts rename to server/server/middlewares/cache/cache.ts index 6041c76c3..6cf37e322 100644 --- a/server/middlewares/cache/cache.ts +++ b/server/server/middlewares/cache/cache.ts @@ -1,5 +1,5 @@ -import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' -import { ApiCache, APICacheOptions } from './shared' +import { HttpStatusCode } from '@peertube/peertube-models' +import { ApiCache, APICacheOptions } from './shared/index.js' const defaultOptions: APICacheOptions = { excludeStatus: [ diff --git a/server/server/middlewares/cache/index.ts b/server/server/middlewares/cache/index.ts new file mode 100644 index 000000000..96c489a16 --- /dev/null +++ b/server/server/middlewares/cache/index.ts @@ -0,0 +1 @@ +export * from './cache.js' diff --git a/server/middlewares/cache/shared/api-cache.ts b/server/server/middlewares/cache/shared/api-cache.ts similarity index 94% rename from server/middlewares/cache/shared/api-cache.ts rename to server/server/middlewares/cache/shared/api-cache.ts index b50b7dce4..514fc2f99 100644 --- a/server/middlewares/cache/shared/api-cache.ts +++ b/server/server/middlewares/cache/shared/api-cache.ts @@ -3,15 +3,16 @@ import express from 'express' import { OutgoingHttpHeaders } from 'http' -import { isTestInstance, parseDurationToMs } from '@server/helpers/core-utils' -import { logger } from '@server/helpers/logger' -import { Redis } from '@server/lib/redis' -import { asyncMiddleware } from '@server/middlewares' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCodeType } from '@peertube/peertube-models' +import { isTestInstance } from '@peertube/peertube-node-utils' +import { parseDurationToMs } from '@server/helpers/core-utils.js' +import { logger } from '@server/helpers/logger.js' +import { Redis } from '@server/lib/redis.js' +import { asyncMiddleware } from '@server/middlewares/index.js' export interface APICacheOptions { headerBlacklist?: string[] - excludeStatus?: HttpStatusCode[] + excludeStatus?: HttpStatusCodeType[] } interface CacheObject { @@ -97,7 +98,7 @@ export class ApiCache { private shouldCacheResponse (response: express.Response) { if (!response) return false - if (this.options.excludeStatus.includes(response.statusCode)) return false + if (this.options.excludeStatus.includes(response.statusCode as HttpStatusCodeType)) return false return true } diff --git a/server/server/middlewares/cache/shared/index.ts b/server/server/middlewares/cache/shared/index.ts new file mode 100644 index 000000000..0e0c44f93 --- /dev/null +++ b/server/server/middlewares/cache/shared/index.ts @@ -0,0 +1 @@ +export * from './api-cache.js' diff --git a/server/middlewares/csp.ts b/server/server/middlewares/csp.ts similarity index 96% rename from server/middlewares/csp.ts rename to server/server/middlewares/csp.ts index e2a75a17e..cc218c670 100644 --- a/server/middlewares/csp.ts +++ b/server/server/middlewares/csp.ts @@ -1,5 +1,5 @@ import { contentSecurityPolicy } from 'helmet' -import { CONFIG } from '../initializers/config' +import { CONFIG } from '../initializers/config.js' const baseDirectives = Object.assign({}, { diff --git a/server/middlewares/dnt.ts b/server/server/middlewares/dnt.ts similarity index 100% rename from server/middlewares/dnt.ts rename to server/server/middlewares/dnt.ts diff --git a/server/middlewares/doc.ts b/server/server/middlewares/doc.ts similarity index 100% rename from server/middlewares/doc.ts rename to server/server/middlewares/doc.ts diff --git a/server/middlewares/error.ts b/server/server/middlewares/error.ts similarity index 92% rename from server/middlewares/error.ts rename to server/server/middlewares/error.ts index 94762e355..706009795 100644 --- a/server/middlewares/error.ts +++ b/server/server/middlewares/error.ts @@ -1,7 +1,7 @@ import express from 'express' import { ProblemDocument, ProblemDocumentExtension } from 'http-problem-details' -import { logger } from '@server/helpers/logger' -import { HttpStatusCode } from '@shared/models' +import { logger } from '@server/helpers/logger.js' +import { HttpStatusCode } from '@peertube/peertube-models' function apiFailMiddleware (req: express.Request, res: express.Response, next: express.NextFunction) { res.fail = options => { diff --git a/server/server/middlewares/index.ts b/server/server/middlewares/index.ts new file mode 100644 index 000000000..96ea240d1 --- /dev/null +++ b/server/server/middlewares/index.ts @@ -0,0 +1,15 @@ +export * from './validators/index.js' +export * from './cache/index.js' +export * from './activitypub.js' +export * from './async.js' +export * from './auth.js' +export * from './pagination.js' +export * from './rate-limiter.js' +export * from './robots.js' +export * from './servers.js' +export * from './sort.js' +export * from './user-right.js' +export * from './dnt.js' +export * from './error.js' +export * from './doc.js' +export * from './csp.js' diff --git a/server/middlewares/pagination.ts b/server/server/middlewares/pagination.ts similarity index 80% rename from server/middlewares/pagination.ts rename to server/server/middlewares/pagination.ts index 17e43f743..acee2f54d 100644 --- a/server/middlewares/pagination.ts +++ b/server/server/middlewares/pagination.ts @@ -1,6 +1,6 @@ import express from 'express' -import { forceNumber } from '@shared/core-utils' -import { PAGINATION } from '../initializers/constants' +import { forceNumber } from '@peertube/peertube-core-utils' +import { PAGINATION } from '../initializers/constants.js' function setDefaultPagination (req: express.Request, res: express.Response, next: express.NextFunction) { if (!req.query.start) req.query.start = 0 diff --git a/server/middlewares/rate-limiter.ts b/server/server/middlewares/rate-limiter.ts similarity index 83% rename from server/middlewares/rate-limiter.ts rename to server/server/middlewares/rate-limiter.ts index 143d43632..3a707709e 100644 --- a/server/middlewares/rate-limiter.ts +++ b/server/server/middlewares/rate-limiter.ts @@ -1,11 +1,11 @@ import express from 'express' import RateLimit, { Options as RateLimitHandlerOptions } from 'express-rate-limit' -import { CONFIG } from '@server/initializers/config' -import { RunnerModel } from '@server/models/runner/runner' -import { UserRole } from '@shared/models' -import { optionalAuthenticate } from './auth' +import { UserRole, UserRoleType } from '@peertube/peertube-models' +import { CONFIG } from '@server/initializers/config.js' +import { RunnerModel } from '@server/models/runner/runner.js' +import { optionalAuthenticate } from './auth.js' -const whitelistRoles = new Set([ UserRole.ADMINISTRATOR, UserRole.MODERATOR ]) +const whitelistRoles = new Set([ UserRole.ADMINISTRATOR, UserRole.MODERATOR ]) export function buildRateLimiter (options: { windowMs: number diff --git a/server/middlewares/robots.ts b/server/server/middlewares/robots.ts similarity index 100% rename from server/middlewares/robots.ts rename to server/server/middlewares/robots.ts diff --git a/server/middlewares/servers.ts b/server/server/middlewares/servers.ts similarity index 83% rename from server/middlewares/servers.ts rename to server/server/middlewares/servers.ts index ebfa03e6c..7971f4d24 100644 --- a/server/middlewares/servers.ts +++ b/server/server/middlewares/servers.ts @@ -1,6 +1,6 @@ import express from 'express' -import { HttpStatusCode } from '../../shared/models/http/http-error-codes' -import { getHostWithPort } from '../helpers/express-utils' +import { HttpStatusCode } from '@peertube/peertube-models' +import { getHostWithPort } from '../helpers/express-utils.js' function setBodyHostsPort (req: express.Request, res: express.Response, next: express.NextFunction) { if (!req.body.hosts) return next() diff --git a/server/middlewares/sort.ts b/server/server/middlewares/sort.ts similarity index 100% rename from server/middlewares/sort.ts rename to server/server/middlewares/sort.ts diff --git a/server/middlewares/user-right.ts b/server/server/middlewares/user-right.ts similarity index 76% rename from server/middlewares/user-right.ts rename to server/server/middlewares/user-right.ts index 7d53e8341..4240fab2a 100644 --- a/server/middlewares/user-right.ts +++ b/server/server/middlewares/user-right.ts @@ -1,8 +1,8 @@ import express from 'express' -import { HttpStatusCode, UserRight } from '@shared/models' -import { logger } from '../helpers/logger' +import { HttpStatusCode, UserRightType } from '@peertube/peertube-models' +import { logger } from '../helpers/logger.js' -function ensureUserHasRight (userRight: UserRight) { +function ensureUserHasRight (userRight: UserRightType) { return function (req: express.Request, res: express.Response, next: express.NextFunction) { const user = res.locals.oauth.token.user if (user.hasRight(userRight) === false) { diff --git a/server/middlewares/validators/abuse.ts b/server/server/middlewares/validators/abuse.ts similarity index 94% rename from server/middlewares/validators/abuse.ts rename to server/server/middlewares/validators/abuse.ts index 70bae1775..48fe06f4c 100644 --- a/server/middlewares/validators/abuse.ts +++ b/server/server/middlewares/validators/abuse.ts @@ -1,5 +1,7 @@ import express from 'express' import { body, param, query } from 'express-validator' +import { forceNumber } from '@peertube/peertube-core-utils' +import { AbuseCreate, HttpStatusCode, UserRight } from '@peertube/peertube-models' import { areAbusePredefinedReasonsValid, isAbuseFilterValid, @@ -11,14 +13,11 @@ import { isAbuseTimestampCoherent, isAbuseTimestampValid, isAbuseVideoIsValid -} from '@server/helpers/custom-validators/abuses' -import { exists, isIdOrUUIDValid, isIdValid, toCompleteUUID, toIntOrNull } from '@server/helpers/custom-validators/misc' -import { logger } from '@server/helpers/logger' -import { AbuseMessageModel } from '@server/models/abuse/abuse-message' -import { AbuseCreate, UserRight } from '@shared/models' -import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' -import { areValidationErrors, doesAbuseExist, doesAccountIdExist, doesCommentIdExist, doesVideoExist } from './shared' -import { forceNumber } from '@shared/core-utils' +} from '@server/helpers/custom-validators/abuses.js' +import { exists, isIdOrUUIDValid, isIdValid, toCompleteUUID, toIntOrNull } from '@server/helpers/custom-validators/misc.js' +import { logger } from '@server/helpers/logger.js' +import { AbuseMessageModel } from '@server/models/abuse/abuse-message.js' +import { areValidationErrors, doesAbuseExist, doesAccountIdExist, doesCommentIdExist, doesVideoExist } from './shared/index.js' const abuseReportValidator = [ body('account.id') diff --git a/server/middlewares/validators/account.ts b/server/server/middlewares/validators/account.ts similarity index 93% rename from server/middlewares/validators/account.ts rename to server/server/middlewares/validators/account.ts index 551f67d61..a8793752e 100644 --- a/server/middlewares/validators/account.ts +++ b/server/server/middlewares/validators/account.ts @@ -1,7 +1,7 @@ import express from 'express' import { param } from 'express-validator' -import { isAccountNameValid } from '../../helpers/custom-validators/accounts' -import { areValidationErrors, doesAccountNameWithHostExist, doesLocalAccountNameExist } from './shared' +import { isAccountNameValid } from '../../helpers/custom-validators/accounts.js' +import { areValidationErrors, doesAccountNameWithHostExist, doesLocalAccountNameExist } from './shared/index.js' const localAccountValidator = [ param('name') diff --git a/server/middlewares/validators/activitypub/activity.ts b/server/server/middlewares/validators/activitypub/activity.ts similarity index 84% rename from server/middlewares/validators/activitypub/activity.ts rename to server/server/middlewares/validators/activitypub/activity.ts index e296b8be7..9d6bf396b 100644 --- a/server/middlewares/validators/activitypub/activity.ts +++ b/server/server/middlewares/validators/activitypub/activity.ts @@ -1,8 +1,8 @@ import express from 'express' -import { getServerActor } from '@server/models/application/application' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' -import { isRootActivityValid } from '../../../helpers/custom-validators/activitypub/activity' -import { logger } from '../../../helpers/logger' +import { HttpStatusCode } from '@peertube/peertube-models' +import { getServerActor } from '@server/models/application/application.js' +import { isRootActivityValid } from '../../../helpers/custom-validators/activitypub/activity.js' +import { logger } from '../../../helpers/logger.js' async function activityPubValidator (req: express.Request, res: express.Response, next: express.NextFunction) { logger.debug('Checking activity pub parameters') diff --git a/server/server/middlewares/validators/activitypub/index.ts b/server/server/middlewares/validators/activitypub/index.ts new file mode 100644 index 000000000..ef02625ba --- /dev/null +++ b/server/server/middlewares/validators/activitypub/index.ts @@ -0,0 +1,3 @@ +export * from './activity.js' +export * from './signature.js' +export * from './pagination.js' diff --git a/server/middlewares/validators/activitypub/pagination.ts b/server/server/middlewares/validators/activitypub/pagination.ts similarity index 83% rename from server/middlewares/validators/activitypub/pagination.ts rename to server/server/middlewares/validators/activitypub/pagination.ts index 1259e4fef..66cbfb870 100644 --- a/server/middlewares/validators/activitypub/pagination.ts +++ b/server/server/middlewares/validators/activitypub/pagination.ts @@ -1,7 +1,7 @@ import express from 'express' import { query } from 'express-validator' -import { PAGINATION } from '@server/initializers/constants' -import { areValidationErrors } from '../shared' +import { PAGINATION } from '@server/initializers/constants.js' +import { areValidationErrors } from '../shared/index.js' const apPaginationValidator = [ query('page') diff --git a/server/middlewares/validators/activitypub/signature.ts b/server/server/middlewares/validators/activitypub/signature.ts similarity index 89% rename from server/middlewares/validators/activitypub/signature.ts rename to server/server/middlewares/validators/activitypub/signature.ts index 998d0c0c4..a318c9463 100644 --- a/server/middlewares/validators/activitypub/signature.ts +++ b/server/server/middlewares/validators/activitypub/signature.ts @@ -4,10 +4,10 @@ import { isSignatureCreatorValid, isSignatureTypeValid, isSignatureValueValid -} from '../../../helpers/custom-validators/activitypub/signature' -import { isDateValid } from '../../../helpers/custom-validators/misc' -import { logger } from '../../../helpers/logger' -import { areValidationErrors } from '../shared' +} from '../../../helpers/custom-validators/activitypub/signature.js' +import { isDateValid } from '../../../helpers/custom-validators/misc.js' +import { logger } from '../../../helpers/logger.js' +import { areValidationErrors } from '../shared/index.js' const signatureValidator = [ body('signature.type') diff --git a/server/middlewares/validators/actor-image.ts b/server/server/middlewares/validators/actor-image.ts similarity index 86% rename from server/middlewares/validators/actor-image.ts rename to server/server/middlewares/validators/actor-image.ts index 9dcf5e871..807d73c52 100644 --- a/server/middlewares/validators/actor-image.ts +++ b/server/server/middlewares/validators/actor-image.ts @@ -1,9 +1,9 @@ import express from 'express' import { body } from 'express-validator' -import { isActorImageFile } from '@server/helpers/custom-validators/actor-images' -import { cleanUpReqFiles } from '../../helpers/express-utils' -import { CONSTRAINTS_FIELDS } from '../../initializers/constants' -import { areValidationErrors } from './shared' +import { isActorImageFile } from '@server/helpers/custom-validators/actor-images.js' +import { cleanUpReqFiles } from '../../helpers/express-utils.js' +import { CONSTRAINTS_FIELDS } from '../../initializers/constants.js' +import { areValidationErrors } from './shared/index.js' const updateActorImageValidatorFactory = (fieldname: string) => ([ body(fieldname).custom((value, { req }) => isActorImageFile(req.files, fieldname)).withMessage( diff --git a/server/middlewares/validators/blocklist.ts b/server/server/middlewares/validators/blocklist.ts similarity index 93% rename from server/middlewares/validators/blocklist.ts rename to server/server/middlewares/validators/blocklist.ts index 8ec6cb01d..19f1bff1d 100644 --- a/server/middlewares/validators/blocklist.ts +++ b/server/server/middlewares/validators/blocklist.ts @@ -1,15 +1,15 @@ import express from 'express' import { body, param, query } from 'express-validator' -import { areValidActorHandles } from '@server/helpers/custom-validators/activitypub/actor' -import { getServerActor } from '@server/models/application/application' -import { arrayify } from '@shared/core-utils' -import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' -import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers' -import { WEBSERVER } from '../../initializers/constants' -import { AccountBlocklistModel } from '../../models/account/account-blocklist' -import { ServerModel } from '../../models/server/server' -import { ServerBlocklistModel } from '../../models/server/server-blocklist' -import { areValidationErrors, doesAccountNameWithHostExist } from './shared' +import { areValidActorHandles } from '@server/helpers/custom-validators/activitypub/actor.js' +import { getServerActor } from '@server/models/application/application.js' +import { arrayify } from '@peertube/peertube-core-utils' +import { HttpStatusCode } from '@peertube/peertube-models' +import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers.js' +import { WEBSERVER } from '../../initializers/constants.js' +import { AccountBlocklistModel } from '../../models/account/account-blocklist.js' +import { ServerBlocklistModel } from '../../models/server/server-blocklist.js' +import { ServerModel } from '../../models/server/server.js' +import { areValidationErrors, doesAccountNameWithHostExist } from './shared/index.js' const blockAccountValidator = [ body('accountName') diff --git a/server/middlewares/validators/bulk.ts b/server/server/middlewares/validators/bulk.ts similarity index 85% rename from server/middlewares/validators/bulk.ts rename to server/server/middlewares/validators/bulk.ts index a1cea8032..3c25757c4 100644 --- a/server/middlewares/validators/bulk.ts +++ b/server/server/middlewares/validators/bulk.ts @@ -1,9 +1,8 @@ import express from 'express' import { body } from 'express-validator' -import { isBulkRemoveCommentsOfScopeValid } from '@server/helpers/custom-validators/bulk' -import { HttpStatusCode, UserRight } from '@shared/models' -import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model' -import { areValidationErrors, doesAccountNameWithHostExist } from './shared' +import { BulkRemoveCommentsOfBody, HttpStatusCode, UserRight } from '@peertube/peertube-models' +import { isBulkRemoveCommentsOfScopeValid } from '@server/helpers/custom-validators/bulk.js' +import { areValidationErrors, doesAccountNameWithHostExist } from './shared/index.js' const bulkRemoveCommentsOfValidator = [ body('accountName') diff --git a/server/middlewares/validators/config.ts b/server/server/middlewares/validators/config.ts similarity index 96% rename from server/middlewares/validators/config.ts rename to server/server/middlewares/validators/config.ts index 7790025e4..e495bb959 100644 --- a/server/middlewares/validators/config.ts +++ b/server/server/middlewares/validators/config.ts @@ -1,13 +1,12 @@ import express from 'express' import { body } from 'express-validator' -import { isIntOrNull } from '@server/helpers/custom-validators/misc' -import { CONFIG, isEmailEnabled } from '@server/initializers/config' -import { HttpStatusCode } from '@shared/models/http/http-error-codes' -import { CustomConfig } from '../../../shared/models/server/custom-config.model' -import { isThemeNameValid } from '../../helpers/custom-validators/plugins' -import { isUserNSFWPolicyValid, isUserVideoQuotaDailyValid, isUserVideoQuotaValid } from '../../helpers/custom-validators/users' -import { isThemeRegistered } from '../../lib/plugins/theme-utils' -import { areValidationErrors } from './shared' +import { CustomConfig, HttpStatusCode } from '@peertube/peertube-models' +import { isIntOrNull } from '@server/helpers/custom-validators/misc.js' +import { CONFIG, isEmailEnabled } from '@server/initializers/config.js' +import { isThemeNameValid } from '../../helpers/custom-validators/plugins.js' +import { isUserNSFWPolicyValid, isUserVideoQuotaDailyValid, isUserVideoQuotaValid } from '../../helpers/custom-validators/users.js' +import { isThemeRegistered } from '../../lib/plugins/theme-utils.js' +import { areValidationErrors } from './shared/index.js' const customConfigUpdateValidator = [ body('instance.name').exists(), diff --git a/server/middlewares/validators/express.ts b/server/server/middlewares/validators/express.ts similarity index 100% rename from server/middlewares/validators/express.ts rename to server/server/middlewares/validators/express.ts diff --git a/server/middlewares/validators/feeds.ts b/server/server/middlewares/validators/feeds.ts similarity index 96% rename from server/middlewares/validators/feeds.ts rename to server/server/middlewares/validators/feeds.ts index 72804a259..ec99b6920 100644 --- a/server/middlewares/validators/feeds.ts +++ b/server/server/middlewares/validators/feeds.ts @@ -1,9 +1,9 @@ import express from 'express' import { param, query } from 'express-validator' -import { HttpStatusCode } from '@shared/models' -import { isValidRSSFeed } from '../../helpers/custom-validators/feeds' -import { exists, isIdOrUUIDValid, isIdValid, toCompleteUUID } from '../../helpers/custom-validators/misc' -import { buildPodcastGroupsCache } from '../cache' +import { HttpStatusCode } from '@peertube/peertube-models' +import { isValidRSSFeed } from '../../helpers/custom-validators/feeds.js' +import { exists, isIdOrUUIDValid, isIdValid, toCompleteUUID } from '../../helpers/custom-validators/misc.js' +import { buildPodcastGroupsCache } from '../cache/index.js' import { areValidationErrors, checkCanSeeVideo, @@ -13,7 +13,7 @@ import { doesVideoChannelIdExist, doesVideoChannelNameWithHostExist, doesVideoExist -} from './shared' +} from './shared/index.js' const feedsFormatValidator = [ param('format') diff --git a/server/middlewares/validators/follows.ts b/server/server/middlewares/validators/follows.ts similarity index 87% rename from server/middlewares/validators/follows.ts rename to server/server/middlewares/validators/follows.ts index be98a4c04..a124dcf27 100644 --- a/server/middlewares/validators/follows.ts +++ b/server/server/middlewares/validators/follows.ts @@ -1,20 +1,19 @@ import express from 'express' import { body, param, query } from 'express-validator' -import { isProdInstance } from '@server/helpers/core-utils' -import { isEachUniqueHandleValid, isFollowStateValid, isRemoteHandleValid } from '@server/helpers/custom-validators/follows' -import { loadActorUrlOrGetFromWebfinger } from '@server/lib/activitypub/actors' -import { getRemoteNameAndHost } from '@server/lib/activitypub/follow' -import { getServerActor } from '@server/models/application/application' -import { MActorFollowActorsDefault } from '@server/types/models' -import { ServerFollowCreate } from '@shared/models' -import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' -import { isActorTypeValid, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' -import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers' -import { logger } from '../../helpers/logger' -import { WEBSERVER } from '../../initializers/constants' -import { ActorModel } from '../../models/actor/actor' -import { ActorFollowModel } from '../../models/actor/actor-follow' -import { areValidationErrors } from './shared' +import { HttpStatusCode, ServerFollowCreate } from '@peertube/peertube-models' +import { isProdInstance } from '@peertube/peertube-node-utils' +import { isEachUniqueHandleValid, isFollowStateValid, isRemoteHandleValid } from '@server/helpers/custom-validators/follows.js' +import { loadActorUrlOrGetFromWebfinger } from '@server/lib/activitypub/actors/index.js' +import { getRemoteNameAndHost } from '@server/lib/activitypub/follow.js' +import { getServerActor } from '@server/models/application/application.js' +import { MActorFollowActorsDefault } from '@server/types/models/index.js' +import { isActorTypeValid, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor.js' +import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers.js' +import { logger } from '../../helpers/logger.js' +import { WEBSERVER } from '../../initializers/constants.js' +import { ActorFollowModel } from '../../models/actor/actor-follow.js' +import { ActorModel } from '../../models/actor/actor.js' +import { areValidationErrors } from './shared/index.js' const listFollowsValidator = [ query('state') diff --git a/server/server/middlewares/validators/index.ts b/server/server/middlewares/validators/index.ts new file mode 100644 index 000000000..5c6beb40e --- /dev/null +++ b/server/server/middlewares/validators/index.ts @@ -0,0 +1,32 @@ +export * from './abuse.js' +export * from './account.js' +export * from './activitypub/index.js' +export * from './actor-image.js' +export * from './blocklist.js' +export * from './bulk.js' +export * from './config.js' +export * from './express.js' +export * from './feeds.js' +export * from './follows.js' +export * from './jobs.js' +export * from './logs.js' +export * from './metrics.js' +export * from './object-storage-proxy.js' +export * from './oembed.js' +export * from './pagination.js' +export * from './plugins.js' +export * from './redundancy.js' +export * from './search.js' +export * from './server.js' +export * from './sort.js' +export * from './static.js' +export * from './themes.js' +export * from './user-email-verification.js' +export * from './user-history.js' +export * from './user-notifications.js' +export * from './user-registrations.js' +export * from './user-subscriptions.js' +export * from './users.js' +export * from './videos/index.js' +export * from './webfinger.js' +export * from './runners/index.js' diff --git a/server/middlewares/validators/jobs.ts b/server/server/middlewares/validators/jobs.ts similarity index 81% rename from server/middlewares/validators/jobs.ts rename to server/server/middlewares/validators/jobs.ts index e5008adc3..070cef32e 100644 --- a/server/middlewares/validators/jobs.ts +++ b/server/server/middlewares/validators/jobs.ts @@ -1,8 +1,8 @@ import express from 'express' import { param, query } from 'express-validator' -import { isValidJobState, isValidJobType } from '../../helpers/custom-validators/jobs' -import { loggerTagsFactory } from '../../helpers/logger' -import { areValidationErrors } from './shared' +import { isValidJobState, isValidJobType } from '../../helpers/custom-validators/jobs.js' +import { loggerTagsFactory } from '../../helpers/logger.js' +import { areValidationErrors } from './shared/index.js' const lTags = loggerTagsFactory('validators', 'jobs') diff --git a/server/middlewares/validators/logs.ts b/server/server/middlewares/validators/logs.ts similarity index 88% rename from server/middlewares/validators/logs.ts rename to server/server/middlewares/validators/logs.ts index 2d828bb42..e93d8a618 100644 --- a/server/middlewares/validators/logs.ts +++ b/server/server/middlewares/validators/logs.ts @@ -1,10 +1,10 @@ import express from 'express' import { body, query } from 'express-validator' -import { isUrlValid } from '@server/helpers/custom-validators/activitypub/misc' -import { isStringArray } from '@server/helpers/custom-validators/search' -import { CONFIG } from '@server/initializers/config' -import { arrayify } from '@shared/core-utils' -import { HttpStatusCode } from '@shared/models' +import { isUrlValid } from '@server/helpers/custom-validators/activitypub/misc.js' +import { isStringArray } from '@server/helpers/custom-validators/search.js' +import { CONFIG } from '@server/initializers/config.js' +import { arrayify } from '@peertube/peertube-core-utils' +import { HttpStatusCode } from '@peertube/peertube-models' import { isValidClientLogLevel, isValidClientLogMessage, @@ -12,9 +12,9 @@ import { isValidClientLogStackTrace, isValidClientLogUserAgent, isValidLogLevel -} from '../../helpers/custom-validators/logs' -import { isDateValid } from '../../helpers/custom-validators/misc' -import { areValidationErrors } from './shared' +} from '../../helpers/custom-validators/logs.js' +import { isDateValid } from '../../helpers/custom-validators/misc.js' +import { areValidationErrors } from './shared/index.js' const createClientLogValidator = [ body('message') diff --git a/server/middlewares/validators/metrics.ts b/server/server/middlewares/validators/metrics.ts similarity index 84% rename from server/middlewares/validators/metrics.ts rename to server/server/middlewares/validators/metrics.ts index 986b30a19..6e1e11952 100644 --- a/server/middlewares/validators/metrics.ts +++ b/server/server/middlewares/validators/metrics.ts @@ -1,10 +1,10 @@ import express from 'express' import { body } from 'express-validator' -import { isValidPlayerMode } from '@server/helpers/custom-validators/metrics' -import { isIdOrUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc' -import { CONFIG } from '@server/initializers/config' -import { HttpStatusCode, PlaybackMetricCreate } from '@shared/models' -import { areValidationErrors, doesVideoExist } from './shared' +import { isValidPlayerMode } from '@server/helpers/custom-validators/metrics.js' +import { isIdOrUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc.js' +import { CONFIG } from '@server/initializers/config.js' +import { HttpStatusCode, PlaybackMetricCreate } from '@peertube/peertube-models' +import { areValidationErrors, doesVideoExist } from './shared/index.js' const addPlaybackMetricValidator = [ body('resolution') diff --git a/server/middlewares/validators/object-storage-proxy.ts b/server/server/middlewares/validators/object-storage-proxy.ts similarity index 80% rename from server/middlewares/validators/object-storage-proxy.ts rename to server/server/middlewares/validators/object-storage-proxy.ts index bbd77f262..755e15a2f 100644 --- a/server/middlewares/validators/object-storage-proxy.ts +++ b/server/server/middlewares/validators/object-storage-proxy.ts @@ -1,6 +1,6 @@ import express from 'express' -import { CONFIG } from '@server/initializers/config' -import { HttpStatusCode } from '@shared/models' +import { CONFIG } from '@server/initializers/config.js' +import { HttpStatusCode } from '@peertube/peertube-models' const ensurePrivateObjectStorageProxyIsEnabled = [ (req: express.Request, res: express.Response, next: express.NextFunction) => { diff --git a/server/middlewares/validators/oembed.ts b/server/server/middlewares/validators/oembed.ts similarity index 90% rename from server/middlewares/validators/oembed.ts rename to server/server/middlewares/validators/oembed.ts index ef9a227a0..32217f693 100644 --- a/server/middlewares/validators/oembed.ts +++ b/server/server/middlewares/validators/oembed.ts @@ -1,14 +1,13 @@ import express from 'express' import { query } from 'express-validator' import { join } from 'path' -import { loadVideo } from '@server/lib/model-loaders' -import { VideoPlaylistModel } from '@server/models/video/video-playlist' -import { VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' -import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' -import { isTestOrDevInstance } from '../../helpers/core-utils' -import { isIdOrUUIDValid, isUUIDValid, toCompleteUUID } from '../../helpers/custom-validators/misc' -import { WEBSERVER } from '../../initializers/constants' -import { areValidationErrors } from './shared' +import { HttpStatusCode, VideoPlaylistPrivacy, VideoPrivacy } from '@peertube/peertube-models' +import { isTestOrDevInstance } from '@peertube/peertube-node-utils' +import { loadVideo } from '@server/lib/model-loaders/index.js' +import { VideoPlaylistModel } from '@server/models/video/video-playlist.js' +import { isIdOrUUIDValid, isUUIDValid, toCompleteUUID } from '../../helpers/custom-validators/misc.js' +import { WEBSERVER } from '../../initializers/constants.js' +import { areValidationErrors } from './shared/index.js' const playlistPaths = [ join('videos', 'watch', 'playlist'), diff --git a/server/middlewares/validators/pagination.ts b/server/server/middlewares/validators/pagination.ts similarity index 86% rename from server/middlewares/validators/pagination.ts rename to server/server/middlewares/validators/pagination.ts index 79ddbbf18..de5729b2a 100644 --- a/server/middlewares/validators/pagination.ts +++ b/server/server/middlewares/validators/pagination.ts @@ -1,7 +1,7 @@ import express from 'express' import { query } from 'express-validator' -import { PAGINATION } from '@server/initializers/constants' -import { areValidationErrors } from './shared' +import { PAGINATION } from '@server/initializers/constants.js' +import { areValidationErrors } from './shared/index.js' const paginationValidator = paginationValidatorBuilder() diff --git a/server/middlewares/validators/plugins.ts b/server/server/middlewares/validators/plugins.ts similarity index 89% rename from server/middlewares/validators/plugins.ts rename to server/server/middlewares/validators/plugins.ts index 64bef2648..0d2b7605a 100644 --- a/server/middlewares/validators/plugins.ts +++ b/server/server/middlewares/validators/plugins.ts @@ -1,21 +1,19 @@ import express from 'express' import { body, param, query, ValidationChain } from 'express-validator' -import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' -import { PluginType } from '../../../shared/models/plugins/plugin.type' -import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/server/api/install-plugin.model' -import { exists, isBooleanValid, isSafePath, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc' +import { HttpStatusCode, InstallOrUpdatePlugin, PluginType_Type } from '@peertube/peertube-models' +import { exists, isBooleanValid, isSafePath, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc.js' import { isNpmPluginNameValid, isPluginNameValid, isPluginStableOrUnstableVersionValid, isPluginTypeValid -} from '../../helpers/custom-validators/plugins' -import { CONFIG } from '../../initializers/config' -import { PluginManager } from '../../lib/plugins/plugin-manager' -import { PluginModel } from '../../models/server/plugin' -import { areValidationErrors } from './shared' +} from '../../helpers/custom-validators/plugins.js' +import { CONFIG } from '../../initializers/config.js' +import { PluginManager } from '../../lib/plugins/plugin-manager.js' +import { PluginModel } from '../../models/server/plugin.js' +import { areValidationErrors } from './shared/index.js' -const getPluginValidator = (pluginType: PluginType, withVersion = true) => { +const getPluginValidator = (pluginType: PluginType_Type, withVersion = true) => { const validators: (ValidationChain | express.Handler)[] = [ param('pluginName') .custom(isPluginNameValid) diff --git a/server/middlewares/validators/redundancy.ts b/server/server/middlewares/validators/redundancy.ts similarity index 94% rename from server/middlewares/validators/redundancy.ts rename to server/server/middlewares/validators/redundancy.ts index c80f9b728..d46a645f5 100644 --- a/server/middlewares/validators/redundancy.ts +++ b/server/server/middlewares/validators/redundancy.ts @@ -1,8 +1,8 @@ import express from 'express' import { body, param, query } from 'express-validator' -import { isVideoRedundancyTarget } from '@server/helpers/custom-validators/video-redundancies' -import { forceNumber } from '@shared/core-utils' -import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' +import { forceNumber } from '@peertube/peertube-core-utils' +import { HttpStatusCode } from '@peertube/peertube-models' +import { isVideoRedundancyTarget } from '@server/helpers/custom-validators/video-redundancies.js' import { exists, isBooleanValid, @@ -11,11 +11,11 @@ import { toBooleanOrNull, toCompleteUUID, toIntOrNull -} from '../../helpers/custom-validators/misc' -import { isHostValid } from '../../helpers/custom-validators/servers' -import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' -import { ServerModel } from '../../models/server/server' -import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from './shared' +} from '../../helpers/custom-validators/misc.js' +import { isHostValid } from '../../helpers/custom-validators/servers.js' +import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy.js' +import { ServerModel } from '../../models/server/server.js' +import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from './shared/index.js' const videoFileRedundancyGetValidator = [ isValidVideoIdParam('videoId'), diff --git a/server/server/middlewares/validators/runners/index.ts b/server/server/middlewares/validators/runners/index.ts new file mode 100644 index 000000000..f8cfedec3 --- /dev/null +++ b/server/server/middlewares/validators/runners/index.ts @@ -0,0 +1,3 @@ +export * from './jobs.js' +export * from './registration-token.js' +export * from './runners.js' diff --git a/server/middlewares/validators/runners/job-files.ts b/server/server/middlewares/validators/runners/job-files.ts similarity index 94% rename from server/middlewares/validators/runners/job-files.ts rename to server/server/middlewares/validators/runners/job-files.ts index 57c27fcfe..8bfd2cce7 100644 --- a/server/middlewares/validators/runners/job-files.ts +++ b/server/server/middlewares/validators/runners/job-files.ts @@ -1,9 +1,9 @@ import express from 'express' import { param } from 'express-validator' import { basename } from 'path' -import { isSafeFilename } from '@server/helpers/custom-validators/misc' -import { hasVideoStudioTaskFile, HttpStatusCode, RunnerJobStudioTranscodingPayload } from '@shared/models' -import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared' +import { isSafeFilename } from '@server/helpers/custom-validators/misc.js' +import { hasVideoStudioTaskFile, HttpStatusCode, RunnerJobStudioTranscodingPayload } from '@peertube/peertube-models' +import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared/index.js' const tags = [ 'runner' ] diff --git a/server/middlewares/validators/runners/jobs.ts b/server/server/middlewares/validators/runners/jobs.ts similarity index 92% rename from server/middlewares/validators/runners/jobs.ts rename to server/server/middlewares/validators/runners/jobs.ts index 62f9340a5..9110fce39 100644 --- a/server/middlewares/validators/runners/jobs.ts +++ b/server/server/middlewares/validators/runners/jobs.ts @@ -1,6 +1,14 @@ -import express from 'express' -import { body, param, query } from 'express-validator' -import { exists, isUUIDValid } from '@server/helpers/custom-validators/misc' +import { arrayify } from '@peertube/peertube-core-utils' +import { + HttpStatusCode, + RunnerJobLiveRTMPHLSTranscodingPrivatePayload, + RunnerJobState, + RunnerJobStateType, + RunnerJobSuccessBody, + RunnerJobUpdateBody, + ServerErrorCode +} from '@peertube/peertube-models' +import { exists, isUUIDValid } from '@server/helpers/custom-validators/misc.js' import { isRunnerJobAbortReasonValid, isRunnerJobArrayOfStateValid, @@ -9,22 +17,15 @@ import { isRunnerJobSuccessPayloadValid, isRunnerJobTokenValid, isRunnerJobUpdatePayloadValid -} from '@server/helpers/custom-validators/runners/jobs' -import { isRunnerTokenValid } from '@server/helpers/custom-validators/runners/runners' -import { cleanUpReqFiles } from '@server/helpers/express-utils' -import { LiveManager } from '@server/lib/live' -import { runnerJobCanBeCancelled } from '@server/lib/runners' -import { RunnerJobModel } from '@server/models/runner/runner-job' -import { arrayify } from '@shared/core-utils' -import { - HttpStatusCode, - RunnerJobLiveRTMPHLSTranscodingPrivatePayload, - RunnerJobState, - RunnerJobSuccessBody, - RunnerJobUpdateBody, - ServerErrorCode -} from '@shared/models' -import { areValidationErrors } from '../shared' +} from '@server/helpers/custom-validators/runners/jobs.js' +import { isRunnerTokenValid } from '@server/helpers/custom-validators/runners/runners.js' +import { cleanUpReqFiles } from '@server/helpers/express-utils.js' +import { LiveManager } from '@server/lib/live/index.js' +import { runnerJobCanBeCancelled } from '@server/lib/runners/index.js' +import { RunnerJobModel } from '@server/models/runner/runner-job.js' +import express from 'express' +import { body, param, query } from 'express-validator' +import { areValidationErrors } from '../shared/index.js' const tags = [ 'runner' ] @@ -171,7 +172,7 @@ export const runnerJobGetValidator = [ } ] -export function jobOfRunnerGetValidatorFactory (allowedStates: RunnerJobState[]) { +export function jobOfRunnerGetValidatorFactory (allowedStates: RunnerJobStateType[]) { return [ param('jobUUID').custom(isUUIDValid), diff --git a/server/middlewares/validators/runners/registration-token.ts b/server/server/middlewares/validators/runners/registration-token.ts similarity index 81% rename from server/middlewares/validators/runners/registration-token.ts rename to server/server/middlewares/validators/runners/registration-token.ts index cc31d4a7e..046b2c988 100644 --- a/server/middlewares/validators/runners/registration-token.ts +++ b/server/server/middlewares/validators/runners/registration-token.ts @@ -1,10 +1,10 @@ import express from 'express' import { param } from 'express-validator' -import { isIdValid } from '@server/helpers/custom-validators/misc' -import { RunnerRegistrationTokenModel } from '@server/models/runner/runner-registration-token' -import { forceNumber } from '@shared/core-utils' -import { HttpStatusCode } from '@shared/models' -import { areValidationErrors } from '../shared/utils' +import { isIdValid } from '@server/helpers/custom-validators/misc.js' +import { RunnerRegistrationTokenModel } from '@server/models/runner/runner-registration-token.js' +import { forceNumber } from '@peertube/peertube-core-utils' +import { HttpStatusCode } from '@peertube/peertube-models' +import { areValidationErrors } from '../shared/utils.js' const tags = [ 'runner' ] diff --git a/server/middlewares/validators/runners/runners.ts b/server/server/middlewares/validators/runners/runners.ts similarity index 89% rename from server/middlewares/validators/runners/runners.ts rename to server/server/middlewares/validators/runners/runners.ts index 4d4d79b4c..80525c609 100644 --- a/server/middlewares/validators/runners/runners.ts +++ b/server/server/middlewares/validators/runners/runners.ts @@ -1,17 +1,17 @@ import express from 'express' import { body, param } from 'express-validator' -import { isIdValid } from '@server/helpers/custom-validators/misc' +import { isIdValid } from '@server/helpers/custom-validators/misc.js' import { isRunnerDescriptionValid, isRunnerNameValid, isRunnerRegistrationTokenValid, isRunnerTokenValid -} from '@server/helpers/custom-validators/runners/runners' -import { RunnerModel } from '@server/models/runner/runner' -import { RunnerRegistrationTokenModel } from '@server/models/runner/runner-registration-token' -import { forceNumber } from '@shared/core-utils' -import { HttpStatusCode, RegisterRunnerBody, ServerErrorCode } from '@shared/models' -import { areValidationErrors } from '../shared/utils' +} from '@server/helpers/custom-validators/runners/runners.js' +import { RunnerModel } from '@server/models/runner/runner.js' +import { RunnerRegistrationTokenModel } from '@server/models/runner/runner-registration-token.js' +import { forceNumber } from '@peertube/peertube-core-utils' +import { HttpStatusCode, RegisterRunnerBody, ServerErrorCode } from '@peertube/peertube-models' +import { areValidationErrors } from '../shared/utils.js' const tags = [ 'runner' ] diff --git a/server/middlewares/validators/search.ts b/server/server/middlewares/validators/search.ts similarity index 94% rename from server/middlewares/validators/search.ts rename to server/server/middlewares/validators/search.ts index a63fd0893..9bfcfd79e 100644 --- a/server/middlewares/validators/search.ts +++ b/server/server/middlewares/validators/search.ts @@ -1,9 +1,9 @@ import express from 'express' import { query } from 'express-validator' -import { isSearchTargetValid } from '@server/helpers/custom-validators/search' -import { isHostValid } from '@server/helpers/custom-validators/servers' -import { areUUIDsValid, isDateValid, isNotEmptyStringArray, toCompleteUUIDs } from '../../helpers/custom-validators/misc' -import { areValidationErrors } from './shared' +import { isSearchTargetValid } from '@server/helpers/custom-validators/search.js' +import { isHostValid } from '@server/helpers/custom-validators/servers.js' +import { areUUIDsValid, isDateValid, isNotEmptyStringArray, toCompleteUUIDs } from '../../helpers/custom-validators/misc.js' +import { areValidationErrors } from './shared/index.js' const videosSearchValidator = [ query('search') diff --git a/server/middlewares/validators/server.ts b/server/server/middlewares/validators/server.ts similarity index 85% rename from server/middlewares/validators/server.ts rename to server/server/middlewares/validators/server.ts index 7d37ae229..b8d7a8aa4 100644 --- a/server/middlewares/validators/server.ts +++ b/server/server/middlewares/validators/server.ts @@ -1,13 +1,13 @@ import express from 'express' import { body } from 'express-validator' -import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' -import { isHostValid, isValidContactBody } from '../../helpers/custom-validators/servers' -import { isUserDisplayNameValid } from '../../helpers/custom-validators/users' -import { logger } from '../../helpers/logger' -import { CONFIG, isEmailEnabled } from '../../initializers/config' -import { Redis } from '../../lib/redis' -import { ServerModel } from '../../models/server/server' -import { areValidationErrors } from './shared' +import { HttpStatusCode } from '@peertube/peertube-models' +import { isHostValid, isValidContactBody } from '../../helpers/custom-validators/servers.js' +import { isUserDisplayNameValid } from '../../helpers/custom-validators/users.js' +import { logger } from '../../helpers/logger.js' +import { CONFIG, isEmailEnabled } from '../../initializers/config.js' +import { Redis } from '../../lib/redis.js' +import { ServerModel } from '../../models/server/server.js' +import { areValidationErrors } from './shared/index.js' const serverGetValidator = [ body('host').custom(isHostValid).withMessage('Should have a valid host'), diff --git a/server/middlewares/validators/shared/abuses.ts b/server/server/middlewares/validators/shared/abuses.ts similarity index 72% rename from server/middlewares/validators/shared/abuses.ts rename to server/server/middlewares/validators/shared/abuses.ts index 2c988f9ec..dfe18fb4f 100644 --- a/server/middlewares/validators/shared/abuses.ts +++ b/server/server/middlewares/validators/shared/abuses.ts @@ -1,7 +1,7 @@ import { Response } from 'express' -import { AbuseModel } from '@server/models/abuse/abuse' -import { HttpStatusCode } from '@shared/models' -import { forceNumber } from '@shared/core-utils' +import { AbuseModel } from '@server/models/abuse/abuse.js' +import { HttpStatusCode } from '@peertube/peertube-models' +import { forceNumber } from '@peertube/peertube-core-utils' async function doesAbuseExist (abuseId: number | string, res: Response) { const abuse = await AbuseModel.loadByIdWithReporter(forceNumber(abuseId)) diff --git a/server/middlewares/validators/shared/accounts.ts b/server/server/middlewares/validators/shared/accounts.ts similarity index 84% rename from server/middlewares/validators/shared/accounts.ts rename to server/server/middlewares/validators/shared/accounts.ts index 72b0e235e..27c56a09e 100644 --- a/server/middlewares/validators/shared/accounts.ts +++ b/server/server/middlewares/validators/shared/accounts.ts @@ -1,9 +1,9 @@ import { Response } from 'express' -import { AccountModel } from '@server/models/account/account' -import { UserModel } from '@server/models/user/user' -import { MAccountDefault } from '@server/types/models' -import { forceNumber } from '@shared/core-utils' -import { HttpStatusCode } from '@shared/models' +import { AccountModel } from '@server/models/account/account.js' +import { UserModel } from '@server/models/user/user.js' +import { MAccountDefault } from '@server/types/models/index.js' +import { forceNumber } from '@peertube/peertube-core-utils' +import { HttpStatusCode } from '@peertube/peertube-models' function doesAccountIdExist (id: number | string, res: Response, sendNotFound = true) { const promise = AccountModel.load(forceNumber(id)) diff --git a/server/server/middlewares/validators/shared/index.ts b/server/server/middlewares/validators/shared/index.ts new file mode 100644 index 000000000..d60ac49ca --- /dev/null +++ b/server/server/middlewares/validators/shared/index.ts @@ -0,0 +1,14 @@ +export * from './abuses.js' +export * from './accounts.js' +export * from './users.js' +export * from './utils.js' +export * from './video-blacklists.js' +export * from './video-captions.js' +export * from './video-channels.js' +export * from './video-channel-syncs.js' +export * from './video-comments.js' +export * from './video-imports.js' +export * from './video-ownerships.js' +export * from './video-playlists.js' +export * from './video-passwords.js' +export * from './videos.js' diff --git a/server/middlewares/validators/shared/user-registrations.ts b/server/server/middlewares/validators/shared/user-registrations.ts similarity index 88% rename from server/middlewares/validators/shared/user-registrations.ts rename to server/server/middlewares/validators/shared/user-registrations.ts index dbc7dda06..ede9d6b91 100644 --- a/server/middlewares/validators/shared/user-registrations.ts +++ b/server/server/middlewares/validators/shared/user-registrations.ts @@ -1,8 +1,8 @@ import express from 'express' -import { UserRegistrationModel } from '@server/models/user/user-registration' -import { MRegistration } from '@server/types/models' -import { forceNumber, pick } from '@shared/core-utils' -import { HttpStatusCode } from '@shared/models' +import { UserRegistrationModel } from '@server/models/user/user-registration.js' +import { MRegistration } from '@server/types/models/index.js' +import { forceNumber, pick } from '@peertube/peertube-core-utils' +import { HttpStatusCode } from '@peertube/peertube-models' function checkRegistrationIdExist (idArg: number | string, res: express.Response) { const id = forceNumber(idArg) diff --git a/server/middlewares/validators/shared/users.ts b/server/server/middlewares/validators/shared/users.ts similarity index 84% rename from server/middlewares/validators/shared/users.ts rename to server/server/middlewares/validators/shared/users.ts index 030adc9f7..025f2a335 100644 --- a/server/middlewares/validators/shared/users.ts +++ b/server/server/middlewares/validators/shared/users.ts @@ -1,9 +1,9 @@ import express from 'express' -import { ActorModel } from '@server/models/actor/actor' -import { UserModel } from '@server/models/user/user' -import { MUserDefault } from '@server/types/models' -import { forceNumber } from '@shared/core-utils' -import { HttpStatusCode } from '@shared/models' +import { ActorModel } from '@server/models/actor/actor.js' +import { UserModel } from '@server/models/user/user.js' +import { MUserDefault } from '@server/types/models/index.js' +import { forceNumber } from '@peertube/peertube-core-utils' +import { HttpStatusCode } from '@peertube/peertube-models' function checkUserIdExist (idArg: number | string, res: express.Response, withStats = false) { const id = forceNumber(idArg) diff --git a/server/middlewares/validators/shared/utils.ts b/server/server/middlewares/validators/shared/utils.ts similarity index 95% rename from server/middlewares/validators/shared/utils.ts rename to server/server/middlewares/validators/shared/utils.ts index f39128fdd..c36525a6d 100644 --- a/server/middlewares/validators/shared/utils.ts +++ b/server/server/middlewares/validators/shared/utils.ts @@ -1,7 +1,7 @@ import express from 'express' import { param, validationResult } from 'express-validator' -import { isIdOrUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc' -import { logger } from '../../../helpers/logger' +import { isIdOrUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc.js' +import { logger } from '../../../helpers/logger.js' function areValidationErrors ( req: express.Request, diff --git a/server/middlewares/validators/shared/video-blacklists.ts b/server/server/middlewares/validators/shared/video-blacklists.ts similarity index 89% rename from server/middlewares/validators/shared/video-blacklists.ts rename to server/server/middlewares/validators/shared/video-blacklists.ts index f85b39b23..fa81305de 100644 --- a/server/middlewares/validators/shared/video-blacklists.ts +++ b/server/server/middlewares/validators/shared/video-blacklists.ts @@ -1,6 +1,6 @@ import { Response } from 'express' -import { VideoBlacklistModel } from '@server/models/video/video-blacklist' -import { HttpStatusCode } from '@shared/models' +import { VideoBlacklistModel } from '@server/models/video/video-blacklist.js' +import { HttpStatusCode } from '@peertube/peertube-models' async function doesVideoBlacklistExist (videoId: number, res: Response) { const videoBlacklist = await VideoBlacklistModel.loadByVideoId(videoId) diff --git a/server/middlewares/validators/shared/video-captions.ts b/server/server/middlewares/validators/shared/video-captions.ts similarity index 82% rename from server/middlewares/validators/shared/video-captions.ts rename to server/server/middlewares/validators/shared/video-captions.ts index 831b366ea..bf2c27a7f 100644 --- a/server/middlewares/validators/shared/video-captions.ts +++ b/server/server/middlewares/validators/shared/video-captions.ts @@ -1,7 +1,7 @@ import { Response } from 'express' -import { VideoCaptionModel } from '@server/models/video/video-caption' -import { MVideoId } from '@server/types/models' -import { HttpStatusCode } from '@shared/models' +import { VideoCaptionModel } from '@server/models/video/video-caption.js' +import { MVideoId } from '@server/types/models/index.js' +import { HttpStatusCode } from '@peertube/peertube-models' async function doesVideoCaptionExist (video: MVideoId, language: string, res: Response) { const videoCaption = await VideoCaptionModel.loadByVideoIdAndLanguage(video.id, language) diff --git a/server/middlewares/validators/shared/video-channel-syncs.ts b/server/server/middlewares/validators/shared/video-channel-syncs.ts similarity index 87% rename from server/middlewares/validators/shared/video-channel-syncs.ts rename to server/server/middlewares/validators/shared/video-channel-syncs.ts index a6e51eb97..5d6872833 100644 --- a/server/middlewares/validators/shared/video-channel-syncs.ts +++ b/server/server/middlewares/validators/shared/video-channel-syncs.ts @@ -1,6 +1,6 @@ import express from 'express' -import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync' -import { HttpStatusCode } from '@shared/models' +import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync.js' +import { HttpStatusCode } from '@peertube/peertube-models' async function doesVideoChannelSyncIdExist (id: number, res: express.Response) { const sync = await VideoChannelSyncModel.loadWithChannel(+id) diff --git a/server/middlewares/validators/shared/video-channels.ts b/server/server/middlewares/validators/shared/video-channels.ts similarity index 93% rename from server/middlewares/validators/shared/video-channels.ts rename to server/server/middlewares/validators/shared/video-channels.ts index bed9f5dbe..eee379c19 100644 --- a/server/middlewares/validators/shared/video-channels.ts +++ b/server/server/middlewares/validators/shared/video-channels.ts @@ -1,7 +1,7 @@ import express from 'express' -import { VideoChannelModel } from '@server/models/video/video-channel' -import { MChannelBannerAccountDefault } from '@server/types/models' -import { HttpStatusCode } from '@shared/models' +import { VideoChannelModel } from '@server/models/video/video-channel.js' +import { MChannelBannerAccountDefault } from '@server/types/models/index.js' +import { HttpStatusCode } from '@peertube/peertube-models' async function doesVideoChannelIdExist (id: number, res: express.Response) { const videoChannel = await VideoChannelModel.loadAndPopulateAccount(+id) diff --git a/server/middlewares/validators/shared/video-comments.ts b/server/server/middlewares/validators/shared/video-comments.ts similarity index 90% rename from server/middlewares/validators/shared/video-comments.ts rename to server/server/middlewares/validators/shared/video-comments.ts index 0961b3ec9..e11696dbf 100644 --- a/server/middlewares/validators/shared/video-comments.ts +++ b/server/server/middlewares/validators/shared/video-comments.ts @@ -1,8 +1,8 @@ import express from 'express' -import { VideoCommentModel } from '@server/models/video/video-comment' -import { MVideoId } from '@server/types/models' -import { forceNumber } from '@shared/core-utils' -import { HttpStatusCode, ServerErrorCode } from '@shared/models' +import { VideoCommentModel } from '@server/models/video/video-comment.js' +import { MVideoId } from '@server/types/models/index.js' +import { forceNumber } from '@peertube/peertube-core-utils' +import { HttpStatusCode, ServerErrorCode } from '@peertube/peertube-models' async function doesVideoCommentThreadExist (idArg: number | string, video: MVideoId, res: express.Response) { const id = forceNumber(idArg) diff --git a/server/middlewares/validators/shared/video-imports.ts b/server/server/middlewares/validators/shared/video-imports.ts similarity index 87% rename from server/middlewares/validators/shared/video-imports.ts rename to server/server/middlewares/validators/shared/video-imports.ts index 69fda4b32..9b7d8e7f0 100644 --- a/server/middlewares/validators/shared/video-imports.ts +++ b/server/server/middlewares/validators/shared/video-imports.ts @@ -1,6 +1,6 @@ import express from 'express' -import { VideoImportModel } from '@server/models/video/video-import' -import { HttpStatusCode } from '@shared/models' +import { VideoImportModel } from '@server/models/video/video-import.js' +import { HttpStatusCode } from '@peertube/peertube-models' async function doesVideoImportExist (id: number, res: express.Response) { const videoImport = await VideoImportModel.loadAndPopulateVideo(id) diff --git a/server/middlewares/validators/shared/video-ownerships.ts b/server/server/middlewares/validators/shared/video-ownerships.ts similarity index 79% rename from server/middlewares/validators/shared/video-ownerships.ts rename to server/server/middlewares/validators/shared/video-ownerships.ts index 33ac9c8b6..9f3d7b2c2 100644 --- a/server/middlewares/validators/shared/video-ownerships.ts +++ b/server/server/middlewares/validators/shared/video-ownerships.ts @@ -1,7 +1,7 @@ import express from 'express' -import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership' -import { forceNumber } from '@shared/core-utils' -import { HttpStatusCode } from '@shared/models' +import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership.js' +import { forceNumber } from '@peertube/peertube-core-utils' +import { HttpStatusCode } from '@peertube/peertube-models' async function doesChangeVideoOwnershipExist (idArg: number | string, res: express.Response) { const id = forceNumber(idArg) diff --git a/server/middlewares/validators/shared/video-passwords.ts b/server/server/middlewares/validators/shared/video-passwords.ts similarity index 90% rename from server/middlewares/validators/shared/video-passwords.ts rename to server/server/middlewares/validators/shared/video-passwords.ts index efcc95dc4..dc82be572 100644 --- a/server/middlewares/validators/shared/video-passwords.ts +++ b/server/server/middlewares/validators/shared/video-passwords.ts @@ -1,9 +1,9 @@ import express from 'express' -import { HttpStatusCode, UserRight, VideoPrivacy } from '@shared/models' -import { forceNumber } from '@shared/core-utils' -import { VideoPasswordModel } from '@server/models/video/video-password' +import { HttpStatusCode, UserRight, VideoPrivacy } from '@peertube/peertube-models' +import { forceNumber } from '@peertube/peertube-core-utils' +import { VideoPasswordModel } from '@server/models/video/video-password.js' import { header } from 'express-validator' -import { getVideoWithAttributes } from '@server/helpers/video' +import { getVideoWithAttributes } from '@server/helpers/video.js' function isValidVideoPasswordHeader () { return header('x-peertube-video-password') diff --git a/server/middlewares/validators/shared/video-playlists.ts b/server/server/middlewares/validators/shared/video-playlists.ts similarity index 89% rename from server/middlewares/validators/shared/video-playlists.ts rename to server/server/middlewares/validators/shared/video-playlists.ts index 4342fe552..caa0bfaf4 100644 --- a/server/middlewares/validators/shared/video-playlists.ts +++ b/server/server/middlewares/validators/shared/video-playlists.ts @@ -1,7 +1,7 @@ import express from 'express' -import { VideoPlaylistModel } from '@server/models/video/video-playlist' -import { MVideoPlaylist } from '@server/types/models' -import { HttpStatusCode } from '@shared/models' +import { VideoPlaylistModel } from '@server/models/video/video-playlist.js' +import { MVideoPlaylist } from '@server/types/models/index.js' +import { HttpStatusCode } from '@peertube/peertube-models' export type VideoPlaylistFetchType = 'summary' | 'all' async function doesVideoPlaylistExist (id: number | string, res: express.Response, fetchType: VideoPlaylistFetchType = 'summary') { diff --git a/server/middlewares/validators/shared/videos.ts b/server/server/middlewares/validators/shared/videos.ts similarity index 92% rename from server/middlewares/validators/shared/videos.ts rename to server/server/middlewares/validators/shared/videos.ts index 9a7497007..0e7dfebcb 100644 --- a/server/middlewares/validators/shared/videos.ts +++ b/server/server/middlewares/validators/shared/videos.ts @@ -1,11 +1,14 @@ import { Request, Response } from 'express' -import { loadVideo, VideoLoadType } from '@server/lib/model-loaders' -import { isAbleToUploadVideo } from '@server/lib/user' -import { VideoTokensManager } from '@server/lib/video-tokens-manager' -import { authenticatePromise } from '@server/middlewares/auth' -import { VideoModel } from '@server/models/video/video' -import { VideoChannelModel } from '@server/models/video/video-channel' -import { VideoFileModel } from '@server/models/video/video-file' +import { HttpStatusCode, ServerErrorCode, UserRight, UserRightType, VideoPrivacy } from '@peertube/peertube-models' +import { exists } from '@server/helpers/custom-validators/misc.js' +import { loadVideo, VideoLoadType } from '@server/lib/model-loaders/index.js' +import { isAbleToUploadVideo } from '@server/lib/user.js' +import { VideoTokensManager } from '@server/lib/video-tokens-manager.js' +import { authenticatePromise } from '@server/middlewares/auth.js' +import { VideoChannelModel } from '@server/models/video/video-channel.js' +import { VideoFileModel } from '@server/models/video/video-file.js' +import { VideoPasswordModel } from '@server/models/video/video-password.js' +import { VideoModel } from '@server/models/video/video.js' import { MUser, MUserAccountId, @@ -18,10 +21,7 @@ import { MVideoImmutable, MVideoThumbnail, MVideoWithRights -} from '@server/types/models' -import { HttpStatusCode, ServerErrorCode, UserRight, VideoPrivacy } from '@shared/models' -import { VideoPasswordModel } from '@server/models/video/video-password' -import { exists } from '@server/helpers/custom-validators/misc' +} from '@server/types/models/index.js' async function doesVideoExist (id: number | string, res: Response, fetchType: VideoLoadType = 'all') { const userId = res.locals.oauth ? res.locals.oauth.token.User.id : undefined @@ -215,7 +215,7 @@ async function checkCanSeePasswordProtectedVideo (options: { return false } -function canUserAccessVideo (user: MUser, video: MVideoWithRights | MVideoAccountLight, right: UserRight) { +function canUserAccessVideo (user: MUser, video: MVideoWithRights | MVideoAccountLight, right: UserRightType) { const isOwnedByUser = video.VideoChannel.Account.userId === user.id return isOwnedByUser || user.hasRight(right) @@ -257,7 +257,7 @@ async function checkCanAccessVideoStaticFiles (options: { // --------------------------------------------------------------------------- -function checkUserCanManageVideo (user: MUser, video: MVideoAccountLight, right: UserRight, res: Response, onlyOwned = true) { +function checkUserCanManageVideo (user: MUser, video: MVideoAccountLight, right: UserRightType, res: Response, onlyOwned = true) { // Retrieve the user who did the request if (onlyOwned && video.isOwned() === false) { res.fail({ diff --git a/server/middlewares/validators/sort.ts b/server/server/middlewares/validators/sort.ts similarity index 96% rename from server/middlewares/validators/sort.ts rename to server/server/middlewares/validators/sort.ts index 07d6cba82..3f3b2eb4e 100644 --- a/server/middlewares/validators/sort.ts +++ b/server/server/middlewares/validators/sort.ts @@ -1,7 +1,7 @@ import express from 'express' import { query } from 'express-validator' -import { SORTABLE_COLUMNS } from '../../initializers/constants' -import { areValidationErrors } from './shared' +import { SORTABLE_COLUMNS } from '../../initializers/constants.js' +import { areValidationErrors } from './shared/index.js' export const adminUsersSortValidator = checkSortFactory(SORTABLE_COLUMNS.ADMIN_USERS) export const accountsSortValidator = checkSortFactory(SORTABLE_COLUMNS.ACCOUNTS) diff --git a/server/middlewares/validators/static.ts b/server/server/middlewares/validators/static.ts similarity index 92% rename from server/middlewares/validators/static.ts rename to server/server/middlewares/validators/static.ts index 86cc0a8d7..afd1441ab 100644 --- a/server/middlewares/validators/static.ts +++ b/server/server/middlewares/validators/static.ts @@ -2,14 +2,14 @@ import express from 'express' import { query } from 'express-validator' import { LRUCache } from 'lru-cache' import { basename, dirname } from 'path' -import { exists, isSafePeerTubeFilenameWithoutExtension, isUUIDValid, toBooleanOrNull } from '@server/helpers/custom-validators/misc' -import { logger } from '@server/helpers/logger' -import { LRU_CACHE } from '@server/initializers/constants' -import { VideoModel } from '@server/models/video/video' -import { VideoFileModel } from '@server/models/video/video-file' -import { MStreamingPlaylist, MVideoFile, MVideoThumbnail } from '@server/types/models' -import { HttpStatusCode } from '@shared/models' -import { areValidationErrors, checkCanAccessVideoStaticFiles, isValidVideoPasswordHeader } from './shared' +import { exists, isSafePeerTubeFilenameWithoutExtension, isUUIDValid, toBooleanOrNull } from '@server/helpers/custom-validators/misc.js' +import { logger } from '@server/helpers/logger.js' +import { LRU_CACHE } from '@server/initializers/constants.js' +import { VideoModel } from '@server/models/video/video.js' +import { VideoFileModel } from '@server/models/video/video-file.js' +import { MStreamingPlaylist, MVideoFile, MVideoThumbnail } from '@server/types/models/index.js' +import { HttpStatusCode } from '@peertube/peertube-models' +import { areValidationErrors, checkCanAccessVideoStaticFiles, isValidVideoPasswordHeader } from './shared/index.js' type LRUValue = { allowed: boolean diff --git a/server/middlewares/validators/themes.ts b/server/server/middlewares/validators/themes.ts similarity index 84% rename from server/middlewares/validators/themes.ts rename to server/server/middlewares/validators/themes.ts index 080b3e096..ec7ce3b4f 100644 --- a/server/middlewares/validators/themes.ts +++ b/server/server/middlewares/validators/themes.ts @@ -1,10 +1,10 @@ import express from 'express' import { param } from 'express-validator' -import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' -import { isSafePath } from '../../helpers/custom-validators/misc' -import { isPluginNameValid, isPluginStableOrUnstableVersionValid } from '../../helpers/custom-validators/plugins' -import { PluginManager } from '../../lib/plugins/plugin-manager' -import { areValidationErrors } from './shared' +import { HttpStatusCode } from '@peertube/peertube-models' +import { isSafePath } from '../../helpers/custom-validators/misc.js' +import { isPluginNameValid, isPluginStableOrUnstableVersionValid } from '../../helpers/custom-validators/plugins.js' +import { PluginManager } from '../../lib/plugins/plugin-manager.js' +import { areValidationErrors } from './shared/index.js' const serveThemeCSSValidator = [ param('themeName') diff --git a/server/middlewares/validators/two-factor.ts b/server/server/middlewares/validators/two-factor.ts similarity index 93% rename from server/middlewares/validators/two-factor.ts rename to server/server/middlewares/validators/two-factor.ts index 106b579b5..950f72528 100644 --- a/server/middlewares/validators/two-factor.ts +++ b/server/server/middlewares/validators/two-factor.ts @@ -1,8 +1,8 @@ import express from 'express' import { body, param } from 'express-validator' -import { HttpStatusCode, UserRight } from '@shared/models' -import { exists, isIdValid } from '../../helpers/custom-validators/misc' -import { areValidationErrors, checkUserIdExist } from './shared' +import { HttpStatusCode, UserRight } from '@peertube/peertube-models' +import { exists, isIdValid } from '../../helpers/custom-validators/misc.js' +import { areValidationErrors, checkUserIdExist } from './shared/index.js' const requestOrConfirmTwoFactorValidator = [ param('id').custom(isIdValid), diff --git a/server/middlewares/validators/user-email-verification.ts b/server/server/middlewares/validators/user-email-verification.ts similarity index 93% rename from server/middlewares/validators/user-email-verification.ts rename to server/server/middlewares/validators/user-email-verification.ts index 74702a8f5..50151f642 100644 --- a/server/middlewares/validators/user-email-verification.ts +++ b/server/server/middlewares/validators/user-email-verification.ts @@ -1,11 +1,11 @@ import express from 'express' import { body, param } from 'express-validator' -import { toBooleanOrNull } from '@server/helpers/custom-validators/misc' -import { HttpStatusCode } from '@shared/models' -import { logger } from '../../helpers/logger' -import { Redis } from '../../lib/redis' -import { areValidationErrors, checkUserEmailExist, checkUserIdExist } from './shared' -import { checkRegistrationEmailExist, checkRegistrationIdExist } from './shared/user-registrations' +import { toBooleanOrNull } from '@server/helpers/custom-validators/misc.js' +import { HttpStatusCode } from '@peertube/peertube-models' +import { logger } from '../../helpers/logger.js' +import { Redis } from '../../lib/redis.js' +import { areValidationErrors, checkUserEmailExist, checkUserIdExist } from './shared/index.js' +import { checkRegistrationEmailExist, checkRegistrationIdExist } from './shared/user-registrations.js' const usersAskSendVerifyEmailValidator = [ body('email').isEmail().not().isEmpty().withMessage('Should have a valid email'), diff --git a/server/middlewares/validators/user-history.ts b/server/server/middlewares/validators/user-history.ts similarity index 93% rename from server/middlewares/validators/user-history.ts rename to server/server/middlewares/validators/user-history.ts index f2dae3134..8415dab2a 100644 --- a/server/middlewares/validators/user-history.ts +++ b/server/server/middlewares/validators/user-history.ts @@ -1,7 +1,7 @@ import express from 'express' import { body, param, query } from 'express-validator' -import { exists, isDateValid, isIdValid } from '../../helpers/custom-validators/misc' -import { areValidationErrors } from './shared' +import { exists, isDateValid, isIdValid } from '../../helpers/custom-validators/misc.js' +import { areValidationErrors } from './shared/index.js' const userHistoryListValidator = [ query('search') diff --git a/server/middlewares/validators/user-notifications.ts b/server/server/middlewares/validators/user-notifications.ts similarity index 94% rename from server/middlewares/validators/user-notifications.ts rename to server/server/middlewares/validators/user-notifications.ts index 8d70dcdd2..16bbc6693 100644 --- a/server/middlewares/validators/user-notifications.ts +++ b/server/server/middlewares/validators/user-notifications.ts @@ -1,8 +1,8 @@ import express from 'express' import { body, query } from 'express-validator' -import { isNotEmptyIntArray, toBooleanOrNull } from '../../helpers/custom-validators/misc' -import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications' -import { areValidationErrors } from './shared' +import { isNotEmptyIntArray, toBooleanOrNull } from '../../helpers/custom-validators/misc.js' +import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications.js' +import { areValidationErrors } from './shared/index.js' const listUserNotificationsValidator = [ query('unread') diff --git a/server/middlewares/validators/user-registrations.ts b/server/server/middlewares/validators/user-registrations.ts similarity index 92% rename from server/middlewares/validators/user-registrations.ts rename to server/server/middlewares/validators/user-registrations.ts index 47397391b..392fe52a6 100644 --- a/server/middlewares/validators/user-registrations.ts +++ b/server/server/middlewares/validators/user-registrations.ts @@ -1,16 +1,16 @@ import express from 'express' import { body, param, query, ValidationChain } from 'express-validator' -import { exists, isBooleanValid, isIdValid, toBooleanOrNull } from '@server/helpers/custom-validators/misc' -import { isRegistrationModerationResponseValid, isRegistrationReasonValid } from '@server/helpers/custom-validators/user-registration' -import { CONFIG } from '@server/initializers/config' -import { Hooks } from '@server/lib/plugins/hooks' -import { HttpStatusCode, UserRegister, UserRegistrationRequest, UserRegistrationState } from '@shared/models' -import { isUserDisplayNameValid, isUserPasswordValid, isUserUsernameValid } from '../../helpers/custom-validators/users' -import { isVideoChannelDisplayNameValid, isVideoChannelUsernameValid } from '../../helpers/custom-validators/video-channels' -import { isSignupAllowed, isSignupAllowedForCurrentIP, SignupMode } from '../../lib/signup' -import { ActorModel } from '../../models/actor/actor' -import { areValidationErrors, checkUserNameOrEmailDoNotAlreadyExist } from './shared' -import { checkRegistrationHandlesDoNotAlreadyExist, checkRegistrationIdExist } from './shared/user-registrations' +import { exists, isBooleanValid, isIdValid, toBooleanOrNull } from '@server/helpers/custom-validators/misc.js' +import { isRegistrationModerationResponseValid, isRegistrationReasonValid } from '@server/helpers/custom-validators/user-registration.js' +import { CONFIG } from '@server/initializers/config.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { HttpStatusCode, UserRegister, UserRegistrationRequest, UserRegistrationState } from '@peertube/peertube-models' +import { isUserDisplayNameValid, isUserPasswordValid, isUserUsernameValid } from '../../helpers/custom-validators/users.js' +import { isVideoChannelDisplayNameValid, isVideoChannelUsernameValid } from '../../helpers/custom-validators/video-channels.js' +import { isSignupAllowed, isSignupAllowedForCurrentIP, SignupMode } from '../../lib/signup.js' +import { ActorModel } from '../../models/actor/actor.js' +import { areValidationErrors, checkUserNameOrEmailDoNotAlreadyExist } from './shared/index.js' +import { checkRegistrationHandlesDoNotAlreadyExist, checkRegistrationIdExist } from './shared/user-registrations.js' const usersDirectRegistrationValidator = usersCommonRegistrationValidatorFactory() diff --git a/server/middlewares/validators/user-subscriptions.ts b/server/server/middlewares/validators/user-subscriptions.ts similarity index 89% rename from server/middlewares/validators/user-subscriptions.ts rename to server/server/middlewares/validators/user-subscriptions.ts index 68d83add5..78bea840f 100644 --- a/server/middlewares/validators/user-subscriptions.ts +++ b/server/server/middlewares/validators/user-subscriptions.ts @@ -1,12 +1,11 @@ import express from 'express' import { body, param, query } from 'express-validator' -import { arrayify } from '@shared/core-utils' -import { FollowState } from '@shared/models' -import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' -import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' -import { WEBSERVER } from '../../initializers/constants' -import { ActorFollowModel } from '../../models/actor/actor-follow' -import { areValidationErrors } from './shared' +import { arrayify } from '@peertube/peertube-core-utils' +import { FollowState, HttpStatusCode } from '@peertube/peertube-models' +import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor.js' +import { WEBSERVER } from '../../initializers/constants.js' +import { ActorFollowModel } from '../../models/actor/actor-follow.js' +import { areValidationErrors } from './shared/index.js' const userSubscriptionListValidator = [ query('search') diff --git a/server/middlewares/validators/users.ts b/server/server/middlewares/validators/users.ts similarity index 96% rename from server/middlewares/validators/users.ts rename to server/server/middlewares/validators/users.ts index 3d311b15b..010ae496d 100644 --- a/server/middlewares/validators/users.ts +++ b/server/server/middlewares/validators/users.ts @@ -1,9 +1,9 @@ import express from 'express' import { body, param, query } from 'express-validator' -import { forceNumber } from '@shared/core-utils' -import { HttpStatusCode, UserRight, UserRole } from '@shared/models' -import { exists, isBooleanValid, isIdValid, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc' -import { isThemeNameValid } from '../../helpers/custom-validators/plugins' +import { forceNumber } from '@peertube/peertube-core-utils' +import { HttpStatusCode, UserRight, UserRole } from '@peertube/peertube-models' +import { exists, isBooleanValid, isIdValid, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc.js' +import { isThemeNameValid } from '../../helpers/custom-validators/plugins.js' import { isUserAdminFlagsValid, isUserAutoPlayNextVideoValid, @@ -23,12 +23,12 @@ import { isUserVideoQuotaDailyValid, isUserVideoQuotaValid, isUserVideosHistoryEnabledValid -} from '../../helpers/custom-validators/users' -import { isVideoChannelUsernameValid } from '../../helpers/custom-validators/video-channels' -import { logger } from '../../helpers/logger' -import { isThemeRegistered } from '../../lib/plugins/theme-utils' -import { Redis } from '../../lib/redis' -import { ActorModel } from '../../models/actor/actor' +} from '../../helpers/custom-validators/users.js' +import { isVideoChannelUsernameValid } from '../../helpers/custom-validators/video-channels.js' +import { logger } from '../../helpers/logger.js' +import { isThemeRegistered } from '../../lib/plugins/theme-utils.js' +import { Redis } from '../../lib/redis.js' +import { ActorModel } from '../../models/actor/actor.js' import { areValidationErrors, checkUserEmailExist, @@ -37,7 +37,7 @@ import { doesVideoChannelIdExist, doesVideoExist, isValidVideoIdParam -} from './shared' +} from './shared/index.js' const usersListValidator = [ query('blocked') diff --git a/server/server/middlewares/validators/videos/index.ts b/server/server/middlewares/validators/videos/index.ts new file mode 100644 index 000000000..05c6659ae --- /dev/null +++ b/server/server/middlewares/validators/videos/index.ts @@ -0,0 +1,19 @@ +export * from './video-blacklist.js' +export * from './video-captions.js' +export * from './video-channel-sync.js' +export * from './video-channels.js' +export * from './video-comments.js' +export * from './video-files.js' +export * from './video-imports.js' +export * from './video-live.js' +export * from './video-ownership-changes.js' +export * from './video-passwords.js' +export * from './video-rates.js' +export * from './video-shares.js' +export * from './video-source.js' +export * from './video-stats.js' +export * from './video-studio.js' +export * from './video-token.js' +export * from './video-transcoding.js' +export * from './video-view.js' +export * from './videos.js' diff --git a/server/server/middlewares/validators/videos/shared/index.ts b/server/server/middlewares/validators/videos/shared/index.ts new file mode 100644 index 000000000..cb1a25a74 --- /dev/null +++ b/server/server/middlewares/validators/videos/shared/index.ts @@ -0,0 +1,2 @@ +export * from './upload.js' +export * from './video-validators.js' diff --git a/server/middlewares/validators/videos/shared/upload.ts b/server/server/middlewares/validators/videos/shared/upload.ts similarity index 86% rename from server/middlewares/validators/videos/shared/upload.ts rename to server/server/middlewares/validators/videos/shared/upload.ts index ea0dddc3c..6798acc43 100644 --- a/server/middlewares/validators/videos/shared/upload.ts +++ b/server/server/middlewares/validators/videos/shared/upload.ts @@ -1,7 +1,7 @@ import express from 'express' -import { logger } from '@server/helpers/logger' -import { getVideoStreamDuration } from '@shared/ffmpeg' -import { HttpStatusCode } from '@shared/models' +import { logger } from '@server/helpers/logger.js' +import { getVideoStreamDuration } from '@peertube/peertube-ffmpeg' +import { HttpStatusCode } from '@peertube/peertube-models' export async function addDurationToVideoFileIfNeeded (options: { res: express.Response diff --git a/server/middlewares/validators/videos/shared/video-validators.ts b/server/server/middlewares/validators/videos/shared/video-validators.ts similarity index 84% rename from server/middlewares/validators/videos/shared/video-validators.ts rename to server/server/middlewares/validators/videos/shared/video-validators.ts index 95e4fef11..27d86a35e 100644 --- a/server/middlewares/validators/videos/shared/video-validators.ts +++ b/server/server/middlewares/validators/videos/shared/video-validators.ts @@ -1,12 +1,12 @@ import express from 'express' -import { isVideoFileMimeTypeValid, isVideoFileSizeValid } from '@server/helpers/custom-validators/videos' -import { logger } from '@server/helpers/logger' -import { CONSTRAINTS_FIELDS } from '@server/initializers/constants' -import { isLocalVideoFileAccepted } from '@server/lib/moderation' -import { Hooks } from '@server/lib/plugins/hooks' -import { MUserAccountId, MVideo } from '@server/types/models' -import { HttpStatusCode, ServerErrorCode, ServerFilterHookName, VideoState } from '@shared/models' -import { checkUserQuota } from '../../shared' +import { HttpStatusCode, ServerErrorCode, ServerFilterHookName, VideoState, VideoStateType } from '@peertube/peertube-models' +import { isVideoFileMimeTypeValid, isVideoFileSizeValid } from '@server/helpers/custom-validators/videos.js' +import { logger } from '@server/helpers/logger.js' +import { CONSTRAINTS_FIELDS } from '@server/initializers/constants.js' +import { isLocalVideoFileAccepted } from '@server/lib/moderation.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { MUserAccountId, MVideo } from '@server/types/models/index.js' +import { checkUserQuota } from '../../shared/index.js' export async function commonVideoFileChecks (options: { res: express.Response @@ -86,7 +86,12 @@ export function checkVideoFileCanBeEdited (video: MVideo, res: express.Response) return false } - const validStates = new Set([ VideoState.PUBLISHED, VideoState.TO_MOVE_TO_EXTERNAL_STORAGE_FAILED, VideoState.TRANSCODING_FAILED ]) + const validStates = new Set([ + VideoState.PUBLISHED, + VideoState.TO_MOVE_TO_EXTERNAL_STORAGE_FAILED, + VideoState.TRANSCODING_FAILED + ]) + if (!validStates.has(video.state)) { res.fail({ status: HttpStatusCode.BAD_REQUEST_400, diff --git a/server/middlewares/validators/videos/video-blacklist.ts b/server/server/middlewares/validators/videos/video-blacklist.ts similarity index 92% rename from server/middlewares/validators/videos/video-blacklist.ts rename to server/server/middlewares/validators/videos/video-blacklist.ts index 6b9aea07c..8790a02a6 100644 --- a/server/middlewares/validators/videos/video-blacklist.ts +++ b/server/server/middlewares/validators/videos/video-blacklist.ts @@ -1,9 +1,9 @@ import express from 'express' import { body, query } from 'express-validator' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' -import { isBooleanValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc' -import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../../helpers/custom-validators/video-blacklist' -import { areValidationErrors, doesVideoBlacklistExist, doesVideoExist, isValidVideoIdParam } from '../shared' +import { HttpStatusCode } from '@peertube/peertube-models' +import { isBooleanValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc.js' +import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../../helpers/custom-validators/video-blacklist.js' +import { areValidationErrors, doesVideoBlacklistExist, doesVideoExist, isValidVideoIdParam } from '../shared/index.js' const videosBlacklistRemoveValidator = [ isValidVideoIdParam('videoId'), diff --git a/server/middlewares/validators/videos/video-captions.ts b/server/server/middlewares/validators/videos/video-captions.ts similarity index 92% rename from server/middlewares/validators/videos/video-captions.ts rename to server/server/middlewares/validators/videos/video-captions.ts index 077a58d2e..d89b48f5f 100644 --- a/server/middlewares/validators/videos/video-captions.ts +++ b/server/server/middlewares/validators/videos/video-captions.ts @@ -1,9 +1,9 @@ import express from 'express' import { body, param } from 'express-validator' -import { UserRight } from '@shared/models' -import { isVideoCaptionFile, isVideoCaptionLanguageValid } from '../../../helpers/custom-validators/video-captions' -import { cleanUpReqFiles } from '../../../helpers/express-utils' -import { CONSTRAINTS_FIELDS, MIMETYPES } from '../../../initializers/constants' +import { UserRight } from '@peertube/peertube-models' +import { isVideoCaptionFile, isVideoCaptionLanguageValid } from '../../../helpers/custom-validators/video-captions.js' +import { cleanUpReqFiles } from '../../../helpers/express-utils.js' +import { CONSTRAINTS_FIELDS, MIMETYPES } from '../../../initializers/constants.js' import { areValidationErrors, checkCanSeeVideo, @@ -12,7 +12,7 @@ import { doesVideoExist, isValidVideoIdParam, isValidVideoPasswordHeader -} from '../shared' +} from '../shared/index.js' const addVideoCaptionValidator = [ isValidVideoIdParam('videoId'), diff --git a/server/middlewares/validators/videos/video-channel-sync.ts b/server/server/middlewares/validators/videos/video-channel-sync.ts similarity index 90% rename from server/middlewares/validators/videos/video-channel-sync.ts rename to server/server/middlewares/validators/videos/video-channel-sync.ts index 7e5b12471..1daf40625 100644 --- a/server/middlewares/validators/videos/video-channel-sync.ts +++ b/server/server/middlewares/validators/videos/video-channel-sync.ts @@ -1,11 +1,11 @@ import * as express from 'express' import { body, param } from 'express-validator' -import { isUrlValid } from '@server/helpers/custom-validators/activitypub/misc' -import { CONFIG } from '@server/initializers/config' -import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync' -import { HttpStatusCode, VideoChannelSyncCreate } from '@shared/models' -import { areValidationErrors, doesVideoChannelIdExist } from '../shared' -import { doesVideoChannelSyncIdExist } from '../shared/video-channel-syncs' +import { isUrlValid } from '@server/helpers/custom-validators/activitypub/misc.js' +import { CONFIG } from '@server/initializers/config.js' +import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync.js' +import { HttpStatusCode, VideoChannelSyncCreate } from '@peertube/peertube-models' +import { areValidationErrors, doesVideoChannelIdExist } from '../shared/index.js' +import { doesVideoChannelSyncIdExist } from '../shared/video-channel-syncs.js' export const ensureSyncIsEnabled = (req: express.Request, res: express.Response, next: express.NextFunction) => { if (!CONFIG.IMPORT.VIDEO_CHANNEL_SYNCHRONIZATION.ENABLED) { diff --git a/server/middlewares/validators/videos/video-channels.ts b/server/server/middlewares/validators/videos/video-channels.ts similarity index 92% rename from server/middlewares/validators/videos/video-channels.ts rename to server/server/middlewares/validators/videos/video-channels.ts index ca6b57003..f67bc2574 100644 --- a/server/middlewares/validators/videos/video-channels.ts +++ b/server/server/middlewares/validators/videos/video-channels.ts @@ -1,21 +1,20 @@ import express from 'express' import { body, param, query } from 'express-validator' -import { isUrlValid } from '@server/helpers/custom-validators/activitypub/misc' -import { CONFIG } from '@server/initializers/config' -import { MChannelAccountDefault } from '@server/types/models' -import { VideosImportInChannelCreate } from '@shared/models' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' -import { isBooleanValid, isIdValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc' +import { HttpStatusCode, VideosImportInChannelCreate } from '@peertube/peertube-models' +import { isUrlValid } from '@server/helpers/custom-validators/activitypub/misc.js' +import { CONFIG } from '@server/initializers/config.js' +import { MChannelAccountDefault } from '@server/types/models/index.js' +import { isBooleanValid, isIdValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc.js' import { isVideoChannelDescriptionValid, isVideoChannelDisplayNameValid, isVideoChannelSupportValid, isVideoChannelUsernameValid -} from '../../../helpers/custom-validators/video-channels' -import { ActorModel } from '../../../models/actor/actor' -import { VideoChannelModel } from '../../../models/video/video-channel' -import { areValidationErrors, checkUserQuota, doesVideoChannelNameWithHostExist } from '../shared' -import { doesVideoChannelSyncIdExist } from '../shared/video-channel-syncs' +} from '../../../helpers/custom-validators/video-channels.js' +import { ActorModel } from '../../../models/actor/actor.js' +import { VideoChannelModel } from '../../../models/video/video-channel.js' +import { areValidationErrors, checkUserQuota, doesVideoChannelNameWithHostExist } from '../shared/index.js' +import { doesVideoChannelSyncIdExist } from '../shared/video-channel-syncs.js' export const videoChannelsAddValidator = [ body('name') diff --git a/server/middlewares/validators/videos/video-comments.ts b/server/server/middlewares/validators/videos/video-comments.ts similarity index 94% rename from server/middlewares/validators/videos/video-comments.ts rename to server/server/middlewares/validators/videos/video-comments.ts index 70689b02e..284d87e85 100644 --- a/server/middlewares/validators/videos/video-comments.ts +++ b/server/server/middlewares/validators/videos/video-comments.ts @@ -1,13 +1,13 @@ import express from 'express' import { body, param, query } from 'express-validator' -import { MUserAccountUrl } from '@server/types/models' -import { HttpStatusCode, UserRight } from '@shared/models' -import { exists, isBooleanValid, isIdValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc' -import { isValidVideoCommentText } from '../../../helpers/custom-validators/video-comments' -import { logger } from '../../../helpers/logger' -import { AcceptResult, isLocalVideoCommentReplyAccepted, isLocalVideoThreadAccepted } from '../../../lib/moderation' -import { Hooks } from '../../../lib/plugins/hooks' -import { MCommentOwnerVideoReply, MVideo, MVideoFullLight } from '../../../types/models/video' +import { MUserAccountUrl } from '@server/types/models/index.js' +import { HttpStatusCode, UserRight } from '@peertube/peertube-models' +import { exists, isBooleanValid, isIdValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc.js' +import { isValidVideoCommentText } from '../../../helpers/custom-validators/video-comments.js' +import { logger } from '../../../helpers/logger.js' +import { AcceptResult, isLocalVideoCommentReplyAccepted, isLocalVideoThreadAccepted } from '../../../lib/moderation.js' +import { Hooks } from '../../../lib/plugins/hooks.js' +import { MCommentOwnerVideoReply, MVideo, MVideoFullLight } from '../../../types/models/video/index.js' import { areValidationErrors, checkCanSeeVideo, @@ -16,7 +16,7 @@ import { doesVideoExist, isValidVideoIdParam, isValidVideoPasswordHeader -} from '../shared' +} from '../shared/index.js' const listVideoCommentsValidator = [ query('isLocal') diff --git a/server/middlewares/validators/videos/video-files.ts b/server/server/middlewares/validators/videos/video-files.ts similarity index 96% rename from server/middlewares/validators/videos/video-files.ts rename to server/server/middlewares/validators/videos/video-files.ts index 6c0ecda42..0a14fa134 100644 --- a/server/middlewares/validators/videos/video-files.ts +++ b/server/server/middlewares/validators/videos/video-files.ts @@ -1,9 +1,9 @@ import express from 'express' import { param } from 'express-validator' -import { isIdValid } from '@server/helpers/custom-validators/misc' -import { MVideo } from '@server/types/models' -import { HttpStatusCode } from '@shared/models' -import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared' +import { isIdValid } from '@server/helpers/custom-validators/misc.js' +import { MVideo } from '@server/types/models/index.js' +import { HttpStatusCode } from '@peertube/peertube-models' +import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared/index.js' const videoFilesDeleteWebVideoValidator = [ isValidVideoIdParam('id'), diff --git a/server/middlewares/validators/videos/video-imports.ts b/server/server/middlewares/validators/videos/video-imports.ts similarity index 88% rename from server/middlewares/validators/videos/video-imports.ts rename to server/server/middlewares/validators/videos/video-imports.ts index a1cb65b70..c9fceadae 100644 --- a/server/middlewares/validators/videos/video-imports.ts +++ b/server/server/middlewares/validators/videos/video-imports.ts @@ -1,25 +1,20 @@ import express from 'express' import { body, param, query } from 'express-validator' -import { isResolvingToUnicastOnly } from '@server/helpers/dns' -import { isPreImportVideoAccepted } from '@server/lib/moderation' -import { Hooks } from '@server/lib/plugins/hooks' -import { MUserAccountId, MVideoImport } from '@server/types/models' -import { forceNumber } from '@shared/core-utils' -import { HttpStatusCode, UserRight, VideoImportState } from '@shared/models' -import { VideoImportCreate } from '@shared/models/videos/import/video-import-create.model' -import { isIdValid, toIntOrNull } from '../../../helpers/custom-validators/misc' -import { isVideoImportTargetUrlValid, isVideoImportTorrentFile } from '../../../helpers/custom-validators/video-imports' -import { - isValidPasswordProtectedPrivacy, - isVideoMagnetUriValid, - isVideoNameValid -} from '../../../helpers/custom-validators/videos' -import { cleanUpReqFiles } from '../../../helpers/express-utils' -import { logger } from '../../../helpers/logger' -import { CONFIG } from '../../../initializers/config' -import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' -import { areValidationErrors, doesVideoChannelOfAccountExist, doesVideoImportExist } from '../shared' -import { getCommonVideoEditAttributes } from './videos' +import { forceNumber } from '@peertube/peertube-core-utils' +import { HttpStatusCode, UserRight, VideoImportCreate, VideoImportState } from '@peertube/peertube-models' +import { isResolvingToUnicastOnly } from '@server/helpers/dns.js' +import { isPreImportVideoAccepted } from '@server/lib/moderation.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { MUserAccountId, MVideoImport } from '@server/types/models/index.js' +import { isIdValid, toIntOrNull } from '../../../helpers/custom-validators/misc.js' +import { isVideoImportTargetUrlValid, isVideoImportTorrentFile } from '../../../helpers/custom-validators/video-imports.js' +import { isValidPasswordProtectedPrivacy, isVideoMagnetUriValid, isVideoNameValid } from '../../../helpers/custom-validators/videos.js' +import { cleanUpReqFiles } from '../../../helpers/express-utils.js' +import { logger } from '../../../helpers/logger.js' +import { CONFIG } from '../../../initializers/config.js' +import { CONSTRAINTS_FIELDS } from '../../../initializers/constants.js' +import { areValidationErrors, doesVideoChannelOfAccountExist, doesVideoImportExist } from '../shared/index.js' +import { getCommonVideoEditAttributes } from './videos.js' const videoImportAddValidator = getCommonVideoEditAttributes().concat([ body('channelId') diff --git a/server/middlewares/validators/videos/video-live.ts b/server/server/middlewares/validators/videos/video-live.ts similarity index 94% rename from server/middlewares/validators/videos/video-live.ts rename to server/server/middlewares/validators/videos/video-live.ts index ec69a3011..097da079d 100644 --- a/server/middlewares/validators/videos/video-live.ts +++ b/server/server/middlewares/validators/videos/video-live.ts @@ -1,12 +1,12 @@ import express from 'express' import { body } from 'express-validator' -import { isLiveLatencyModeValid } from '@server/helpers/custom-validators/video-lives' -import { CONSTRAINTS_FIELDS } from '@server/initializers/constants' -import { isLocalLiveVideoAccepted } from '@server/lib/moderation' -import { Hooks } from '@server/lib/plugins/hooks' -import { VideoModel } from '@server/models/video/video' -import { VideoLiveModel } from '@server/models/video/video-live' -import { VideoLiveSessionModel } from '@server/models/video/video-live-session' +import { isLiveLatencyModeValid } from '@server/helpers/custom-validators/video-lives.js' +import { CONSTRAINTS_FIELDS } from '@server/initializers/constants.js' +import { isLocalLiveVideoAccepted } from '@server/lib/moderation.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { VideoModel } from '@server/models/video/video.js' +import { VideoLiveModel } from '@server/models/video/video-live.js' +import { VideoLiveSessionModel } from '@server/models/video/video-live-session.js' import { HttpStatusCode, LiveVideoCreate, @@ -15,20 +15,20 @@ import { ServerErrorCode, UserRight, VideoState -} from '@shared/models' -import { exists, isBooleanValid, isIdValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc' -import { isValidPasswordProtectedPrivacy, isVideoNameValid, isVideoReplayPrivacyValid } from '../../../helpers/custom-validators/videos' -import { cleanUpReqFiles } from '../../../helpers/express-utils' -import { logger } from '../../../helpers/logger' -import { CONFIG } from '../../../initializers/config' +} from '@peertube/peertube-models' +import { exists, isBooleanValid, isIdValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc.js' +import { isValidPasswordProtectedPrivacy, isVideoNameValid, isVideoReplayPrivacyValid } from '../../../helpers/custom-validators/videos.js' +import { cleanUpReqFiles } from '../../../helpers/express-utils.js' +import { logger } from '../../../helpers/logger.js' +import { CONFIG } from '../../../initializers/config.js' import { areValidationErrors, checkUserCanManageVideo, doesVideoChannelOfAccountExist, doesVideoExist, isValidVideoIdParam -} from '../shared' -import { getCommonVideoEditAttributes } from './videos' +} from '../shared/index.js' +import { getCommonVideoEditAttributes } from './videos.js' const videoLiveGetValidator = [ isValidVideoIdParam('videoId'), diff --git a/server/middlewares/validators/videos/video-ownership-changes.ts b/server/server/middlewares/validators/videos/video-ownership-changes.ts similarity index 91% rename from server/middlewares/validators/videos/video-ownership-changes.ts rename to server/server/middlewares/validators/videos/video-ownership-changes.ts index 3eca78c25..0cdb077b3 100644 --- a/server/middlewares/validators/videos/video-ownership-changes.ts +++ b/server/server/middlewares/validators/videos/video-ownership-changes.ts @@ -1,10 +1,10 @@ import express from 'express' import { param } from 'express-validator' -import { isIdValid } from '@server/helpers/custom-validators/misc' -import { checkUserCanTerminateOwnershipChange } from '@server/helpers/custom-validators/video-ownership' -import { AccountModel } from '@server/models/account/account' -import { MVideoWithAllFiles } from '@server/types/models' -import { HttpStatusCode, UserRight, VideoChangeOwnershipAccept, VideoChangeOwnershipStatus, VideoState } from '@shared/models' +import { isIdValid } from '@server/helpers/custom-validators/misc.js' +import { checkUserCanTerminateOwnershipChange } from '@server/helpers/custom-validators/video-ownership.js' +import { AccountModel } from '@server/models/account/account.js' +import { MVideoWithAllFiles } from '@server/types/models/index.js' +import { HttpStatusCode, UserRight, VideoChangeOwnershipAccept, VideoChangeOwnershipStatus, VideoState } from '@peertube/peertube-models' import { areValidationErrors, checkUserCanManageVideo, @@ -13,7 +13,7 @@ import { doesVideoChannelOfAccountExist, doesVideoExist, isValidVideoIdParam -} from '../shared' +} from '../shared/index.js' const videosChangeOwnershipValidator = [ isValidVideoIdParam('videoId'), diff --git a/server/middlewares/validators/videos/video-passwords.ts b/server/server/middlewares/validators/videos/video-passwords.ts similarity index 95% rename from server/middlewares/validators/videos/video-passwords.ts rename to server/server/middlewares/validators/videos/video-passwords.ts index 200e496f6..58ca224f4 100644 --- a/server/middlewares/validators/videos/video-passwords.ts +++ b/server/server/middlewares/validators/videos/video-passwords.ts @@ -7,11 +7,11 @@ import { doesVideoPasswordExist, isVideoPasswordDeletable, checkUserCanManageVideo -} from '../shared' +} from '../shared/index.js' import { body, param } from 'express-validator' -import { isIdValid } from '@server/helpers/custom-validators/misc' -import { isValidPasswordProtectedPrivacy } from '@server/helpers/custom-validators/videos' -import { UserRight } from '@shared/models' +import { isIdValid } from '@server/helpers/custom-validators/misc.js' +import { isValidPasswordProtectedPrivacy } from '@server/helpers/custom-validators/videos.js' +import { UserRight } from '@peertube/peertube-models' const listVideoPasswordValidator = [ isValidVideoIdParam('videoId'), diff --git a/server/middlewares/validators/videos/video-playlists.ts b/server/server/middlewares/validators/videos/video-playlists.ts similarity index 94% rename from server/middlewares/validators/videos/video-playlists.ts rename to server/server/middlewares/validators/videos/video-playlists.ts index 95a5ba63a..1e4998101 100644 --- a/server/middlewares/validators/videos/video-playlists.ts +++ b/server/server/middlewares/validators/videos/video-playlists.ts @@ -1,16 +1,17 @@ import express from 'express' import { body, param, query, ValidationChain } from 'express-validator' -import { ExpressPromiseHandler } from '@server/types/express-handler' -import { MUserAccountId } from '@server/types/models' -import { forceNumber } from '@shared/core-utils' +import { forceNumber } from '@peertube/peertube-core-utils' import { HttpStatusCode, UserRight, + UserRightType, VideoPlaylistCreate, VideoPlaylistPrivacy, VideoPlaylistType, VideoPlaylistUpdate -} from '@shared/models' +} from '@peertube/peertube-models' +import { ExpressPromiseHandler } from '@server/types/express-handler.js' +import { MUserAccountId } from '@server/types/models/index.js' import { isArrayOf, isIdOrUUIDValid, @@ -20,20 +21,20 @@ import { toIntArray, toIntOrNull, toValueOrNull -} from '../../../helpers/custom-validators/misc' +} from '../../../helpers/custom-validators/misc.js' import { isVideoPlaylistDescriptionValid, isVideoPlaylistNameValid, isVideoPlaylistPrivacyValid, isVideoPlaylistTimestampValid, isVideoPlaylistTypeValid -} from '../../../helpers/custom-validators/video-playlists' -import { isVideoImageValid } from '../../../helpers/custom-validators/videos' -import { cleanUpReqFiles } from '../../../helpers/express-utils' -import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' -import { VideoPlaylistElementModel } from '../../../models/video/video-playlist-element' -import { MVideoPlaylist } from '../../../types/models/video/video-playlist' -import { authenticatePromise } from '../../auth' +} from '../../../helpers/custom-validators/video-playlists.js' +import { isVideoImageValid } from '../../../helpers/custom-validators/videos.js' +import { cleanUpReqFiles } from '../../../helpers/express-utils.js' +import { CONSTRAINTS_FIELDS } from '../../../initializers/constants.js' +import { VideoPlaylistElementModel } from '../../../models/video/video-playlist-element.js' +import { MVideoPlaylist } from '../../../types/models/video/video-playlist.js' +import { authenticatePromise } from '../../auth.js' import { areValidationErrors, doesVideoChannelIdExist, @@ -41,7 +42,7 @@ import { doesVideoPlaylistExist, isValidPlaylistIdParam, VideoPlaylistFetchType -} from '../shared' +} from '../shared/index.js' const videoPlaylistsAddValidator = getCommonPlaylistEditAttributes().concat([ body('displayName') @@ -391,7 +392,12 @@ function getCommonPlaylistEditAttributes () { ] as (ValidationChain | ExpressPromiseHandler)[] } -function checkUserCanManageVideoPlaylist (user: MUserAccountId, videoPlaylist: MVideoPlaylist, right: UserRight, res: express.Response) { +function checkUserCanManageVideoPlaylist ( + user: MUserAccountId, + videoPlaylist: MVideoPlaylist, + right: UserRightType, + res: express.Response +) { if (videoPlaylist.isOwned() === false) { res.fail({ status: HttpStatusCode.FORBIDDEN_403, diff --git a/server/middlewares/validators/videos/video-rates.ts b/server/server/middlewares/validators/videos/video-rates.ts similarity index 90% rename from server/middlewares/validators/videos/video-rates.ts rename to server/server/middlewares/validators/videos/video-rates.ts index c837b047b..f7b784fe3 100644 --- a/server/middlewares/validators/videos/video-rates.ts +++ b/server/server/middlewares/validators/videos/video-rates.ts @@ -1,13 +1,12 @@ import express from 'express' import { body, param, query } from 'express-validator' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' -import { VideoRateType } from '../../../../shared/models/videos' -import { isAccountNameValid } from '../../../helpers/custom-validators/accounts' -import { isIdValid } from '../../../helpers/custom-validators/misc' -import { isRatingValid } from '../../../helpers/custom-validators/video-rates' -import { isVideoRatingTypeValid } from '../../../helpers/custom-validators/videos' -import { AccountVideoRateModel } from '../../../models/account/account-video-rate' -import { areValidationErrors, checkCanSeeVideo, doesVideoExist, isValidVideoIdParam, isValidVideoPasswordHeader } from '../shared' +import { HttpStatusCode, VideoRateType } from '@peertube/peertube-models' +import { isAccountNameValid } from '../../../helpers/custom-validators/accounts.js' +import { isIdValid } from '../../../helpers/custom-validators/misc.js' +import { isRatingValid } from '../../../helpers/custom-validators/video-rates.js' +import { isVideoRatingTypeValid } from '../../../helpers/custom-validators/videos.js' +import { AccountVideoRateModel } from '../../../models/account/account-video-rate.js' +import { areValidationErrors, checkCanSeeVideo, doesVideoExist, isValidVideoIdParam, isValidVideoPasswordHeader } from '../shared/index.js' const videoUpdateRateValidator = [ isValidVideoIdParam('id'), diff --git a/server/middlewares/validators/videos/video-shares.ts b/server/server/middlewares/validators/videos/video-shares.ts similarity index 89% rename from server/middlewares/validators/videos/video-shares.ts rename to server/server/middlewares/validators/videos/video-shares.ts index c234de6ed..1ecf0fd04 100644 --- a/server/middlewares/validators/videos/video-shares.ts +++ b/server/server/middlewares/validators/videos/video-shares.ts @@ -1,9 +1,9 @@ import express from 'express' import { param } from 'express-validator' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' -import { isIdValid } from '../../../helpers/custom-validators/misc' -import { VideoShareModel } from '../../../models/video/video-share' -import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared' +import { HttpStatusCode } from '@peertube/peertube-models' +import { isIdValid } from '../../../helpers/custom-validators/misc.js' +import { VideoShareModel } from '../../../models/video/video-share.js' +import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared/index.js' const videosShareValidator = [ isValidVideoIdParam('id'), diff --git a/server/middlewares/validators/videos/video-source.ts b/server/server/middlewares/validators/videos/video-source.ts similarity index 87% rename from server/middlewares/validators/videos/video-source.ts rename to server/server/middlewares/validators/videos/video-source.ts index bbccb58b0..3d4f77e21 100644 --- a/server/middlewares/validators/videos/video-source.ts +++ b/server/server/middlewares/validators/videos/video-source.ts @@ -1,16 +1,16 @@ import express from 'express' import { body, header } from 'express-validator' -import { getResumableUploadPath } from '@server/helpers/upload' -import { getVideoWithAttributes } from '@server/helpers/video' -import { CONFIG } from '@server/initializers/config' -import { uploadx } from '@server/lib/uploadx' -import { VideoSourceModel } from '@server/models/video/video-source' -import { MVideoFullLight } from '@server/types/models' -import { HttpStatusCode, UserRight } from '@shared/models' +import { getResumableUploadPath } from '@server/helpers/upload.js' +import { getVideoWithAttributes } from '@server/helpers/video.js' +import { CONFIG } from '@server/initializers/config.js' +import { uploadx } from '@server/lib/uploadx.js' +import { VideoSourceModel } from '@server/models/video/video-source.js' +import { MVideoFullLight } from '@server/types/models/index.js' +import { HttpStatusCode, UserRight } from '@peertube/peertube-models' import { Metadata as UploadXMetadata } from '@uploadx/core' -import { logger } from '../../../helpers/logger' -import { areValidationErrors, checkUserCanManageVideo, doesVideoExist, isValidVideoIdParam } from '../shared' -import { addDurationToVideoFileIfNeeded, checkVideoFileCanBeEdited, commonVideoFileChecks, isVideoFileAccepted } from './shared' +import { logger } from '../../../helpers/logger.js' +import { areValidationErrors, checkUserCanManageVideo, doesVideoExist, isValidVideoIdParam } from '../shared/index.js' +import { addDurationToVideoFileIfNeeded, checkVideoFileCanBeEdited, commonVideoFileChecks, isVideoFileAccepted } from './shared/index.js' export const videoSourceGetLatestValidator = [ isValidVideoIdParam('id'), diff --git a/server/middlewares/validators/videos/video-stats.ts b/server/server/middlewares/validators/videos/video-stats.ts similarity index 94% rename from server/middlewares/validators/videos/video-stats.ts rename to server/server/middlewares/validators/videos/video-stats.ts index a79526d39..c490c8f82 100644 --- a/server/middlewares/validators/videos/video-stats.ts +++ b/server/server/middlewares/validators/videos/video-stats.ts @@ -1,10 +1,10 @@ import express from 'express' import { param, query } from 'express-validator' -import { isDateValid } from '@server/helpers/custom-validators/misc' -import { isValidStatTimeserieMetric } from '@server/helpers/custom-validators/video-stats' -import { STATS_TIMESERIE } from '@server/initializers/constants' -import { HttpStatusCode, UserRight, VideoStatsTimeserieQuery } from '@shared/models' -import { areValidationErrors, checkUserCanManageVideo, doesVideoExist, isValidVideoIdParam } from '../shared' +import { isDateValid } from '@server/helpers/custom-validators/misc.js' +import { isValidStatTimeserieMetric } from '@server/helpers/custom-validators/video-stats.js' +import { STATS_TIMESERIE } from '@server/initializers/constants.js' +import { HttpStatusCode, UserRight, VideoStatsTimeserieQuery } from '@peertube/peertube-models' +import { areValidationErrors, checkUserCanManageVideo, doesVideoExist, isValidVideoIdParam } from '../shared/index.js' const videoOverallStatsValidator = [ isValidVideoIdParam('videoId'), diff --git a/server/middlewares/validators/videos/video-studio.ts b/server/server/middlewares/validators/videos/video-studio.ts similarity index 88% rename from server/middlewares/validators/videos/video-studio.ts rename to server/server/middlewares/validators/videos/video-studio.ts index a375af60a..6f6f2dc54 100644 --- a/server/middlewares/validators/videos/video-studio.ts +++ b/server/server/middlewares/validators/videos/video-studio.ts @@ -1,19 +1,19 @@ import express from 'express' import { body, param } from 'express-validator' -import { isIdOrUUIDValid } from '@server/helpers/custom-validators/misc' +import { isIdOrUUIDValid } from '@server/helpers/custom-validators/misc.js' import { isStudioCutTaskValid, isStudioTaskAddIntroOutroValid, isStudioTaskAddWatermarkValid, isValidStudioTasksArray -} from '@server/helpers/custom-validators/video-studio' -import { cleanUpReqFiles } from '@server/helpers/express-utils' -import { CONFIG } from '@server/initializers/config' -import { approximateIntroOutroAdditionalSize, getTaskFileFromReq } from '@server/lib/video-studio' -import { isAudioFile } from '@shared/ffmpeg' -import { HttpStatusCode, UserRight, VideoStudioCreateEdition, VideoStudioTask } from '@shared/models' -import { areValidationErrors, checkUserCanManageVideo, checkUserQuota, doesVideoExist } from '../shared' -import { checkVideoFileCanBeEdited } from './shared' +} from '@server/helpers/custom-validators/video-studio.js' +import { cleanUpReqFiles } from '@server/helpers/express-utils.js' +import { CONFIG } from '@server/initializers/config.js' +import { approximateIntroOutroAdditionalSize, getTaskFileFromReq } from '@server/lib/video-studio.js' +import { isAudioFile } from '@peertube/peertube-ffmpeg' +import { HttpStatusCode, UserRight, VideoStudioCreateEdition, VideoStudioTask } from '@peertube/peertube-models' +import { areValidationErrors, checkUserCanManageVideo, checkUserQuota, doesVideoExist } from '../shared/index.js' +import { checkVideoFileCanBeEdited } from './shared/index.js' const videoStudioAddEditionValidator = [ param('videoId') diff --git a/server/middlewares/validators/videos/video-token.ts b/server/server/middlewares/validators/videos/video-token.ts similarity index 75% rename from server/middlewares/validators/videos/video-token.ts rename to server/server/middlewares/validators/videos/video-token.ts index d4253e21d..748913755 100644 --- a/server/middlewares/validators/videos/video-token.ts +++ b/server/server/middlewares/validators/videos/video-token.ts @@ -1,7 +1,6 @@ import express from 'express' -import { VideoPrivacy } from '../../../../shared/models/videos' -import { HttpStatusCode } from '@shared/models' -import { exists } from '@server/helpers/custom-validators/misc' +import { HttpStatusCode, VideoPrivacy } from '@peertube/peertube-models' +import { exists } from '@server/helpers/custom-validators/misc.js' const videoFileTokenValidator = [ (req: express.Request, res: express.Response, next: express.NextFunction) => { diff --git a/server/middlewares/validators/videos/video-transcoding.ts b/server/server/middlewares/validators/videos/video-transcoding.ts similarity index 90% rename from server/middlewares/validators/videos/video-transcoding.ts rename to server/server/middlewares/validators/videos/video-transcoding.ts index 2f99ff42c..28f057979 100644 --- a/server/middlewares/validators/videos/video-transcoding.ts +++ b/server/server/middlewares/validators/videos/video-transcoding.ts @@ -1,11 +1,11 @@ import express from 'express' import { body } from 'express-validator' -import { isBooleanValid, toBooleanOrNull } from '@server/helpers/custom-validators/misc' -import { isValidCreateTranscodingType } from '@server/helpers/custom-validators/video-transcoding' -import { CONFIG } from '@server/initializers/config' -import { VideoJobInfoModel } from '@server/models/video/video-job-info' -import { HttpStatusCode, ServerErrorCode, VideoTranscodingCreate } from '@shared/models' -import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared' +import { isBooleanValid, toBooleanOrNull } from '@server/helpers/custom-validators/misc.js' +import { isValidCreateTranscodingType } from '@server/helpers/custom-validators/video-transcoding.js' +import { CONFIG } from '@server/initializers/config.js' +import { VideoJobInfoModel } from '@server/models/video/video-job-info.js' +import { HttpStatusCode, ServerErrorCode, VideoTranscodingCreate } from '@peertube/peertube-models' +import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared/index.js' const createTranscodingValidator = [ isValidVideoIdParam('videoId'), diff --git a/server/middlewares/validators/videos/video-view.ts b/server/server/middlewares/validators/videos/video-view.ts similarity index 88% rename from server/middlewares/validators/videos/video-view.ts rename to server/server/middlewares/validators/videos/video-view.ts index a2f61f4ba..14ee1da46 100644 --- a/server/middlewares/validators/videos/video-view.ts +++ b/server/server/middlewares/validators/videos/video-view.ts @@ -1,11 +1,11 @@ import express from 'express' import { body, param } from 'express-validator' -import { isVideoTimeValid } from '@server/helpers/custom-validators/video-view' -import { getCachedVideoDuration } from '@server/lib/video' -import { LocalVideoViewerModel } from '@server/models/view/local-video-viewer' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' -import { isIdValid, isIntOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc' -import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared' +import { HttpStatusCode } from '@peertube/peertube-models' +import { isVideoTimeValid } from '@server/helpers/custom-validators/video-view.js' +import { getCachedVideoDuration } from '@server/lib/video.js' +import { LocalVideoViewerModel } from '@server/models/view/local-video-viewer.js' +import { isIdValid, isIntOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc.js' +import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared/index.js' const getVideoLocalViewerValidator = [ param('localViewerId') diff --git a/server/middlewares/validators/videos/videos.ts b/server/server/middlewares/validators/videos/videos.ts similarity index 95% rename from server/middlewares/validators/videos/videos.ts rename to server/server/middlewares/validators/videos/videos.ts index 5a49779ed..a1f6e72c8 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/server/middlewares/validators/videos/videos.ts @@ -1,14 +1,14 @@ import express from 'express' import { body, header, param, query, ValidationChain } from 'express-validator' -import { isTestInstance } from '@server/helpers/core-utils' -import { getResumableUploadPath } from '@server/helpers/upload' -import { Redis } from '@server/lib/redis' -import { uploadx } from '@server/lib/uploadx' -import { getServerActor } from '@server/models/application/application' -import { ExpressPromiseHandler } from '@server/types/express-handler' -import { MUserAccountId, MVideoFullLight } from '@server/types/models' -import { arrayify } from '@shared/core-utils' -import { HttpStatusCode, ServerErrorCode, UserRight, VideoState } from '@shared/models' +import { arrayify } from '@peertube/peertube-core-utils' +import { HttpStatusCode, ServerErrorCode, UserRight, VideoState } from '@peertube/peertube-models' +import { isTestInstance } from '@peertube/peertube-node-utils' +import { getResumableUploadPath } from '@server/helpers/upload.js' +import { Redis } from '@server/lib/redis.js' +import { uploadx } from '@server/lib/uploadx.js' +import { getServerActor } from '@server/models/application/application.js' +import { ExpressPromiseHandler } from '@server/types/express-handler.js' +import { MUserAccountId, MVideoFullLight } from '@server/types/models/index.js' import { exists, isBooleanValid, @@ -18,8 +18,8 @@ import { toBooleanOrNull, toIntOrNull, toValueOrNull -} from '../../../helpers/custom-validators/misc' -import { isBooleanBothQueryValid, isNumberArray, isStringArray } from '../../../helpers/custom-validators/search' +} from '../../../helpers/custom-validators/misc.js' +import { isBooleanBothQueryValid, isNumberArray, isStringArray } from '../../../helpers/custom-validators/search.js' import { areVideoTagsValid, isScheduleVideoUpdatePrivacyValid, @@ -34,13 +34,13 @@ import { isVideoOriginallyPublishedAtValid, isVideoPrivacyValid, isVideoSupportValid -} from '../../../helpers/custom-validators/videos' -import { cleanUpReqFiles } from '../../../helpers/express-utils' -import { logger } from '../../../helpers/logger' -import { getVideoWithAttributes } from '../../../helpers/video' -import { CONFIG } from '../../../initializers/config' -import { CONSTRAINTS_FIELDS, OVERVIEWS } from '../../../initializers/constants' -import { VideoModel } from '../../../models/video/video' +} from '../../../helpers/custom-validators/videos.js' +import { cleanUpReqFiles } from '../../../helpers/express-utils.js' +import { logger } from '../../../helpers/logger.js' +import { getVideoWithAttributes } from '../../../helpers/video.js' +import { CONFIG } from '../../../initializers/config.js' +import { CONSTRAINTS_FIELDS, OVERVIEWS } from '../../../initializers/constants.js' +import { VideoModel } from '../../../models/video/video.js' import { areValidationErrors, checkCanAccessVideoStaticFiles, @@ -51,8 +51,8 @@ import { doesVideoFileOfVideoExist, isValidVideoIdParam, isValidVideoPasswordHeader -} from '../shared' -import { addDurationToVideoFileIfNeeded, commonVideoFileChecks, isVideoFileAccepted } from './shared' +} from '../shared/index.js' +import { addDurationToVideoFileIfNeeded, commonVideoFileChecks, isVideoFileAccepted } from './shared/index.js' const videosAddLegacyValidator = getCommonVideoEditAttributes().concat([ body('videofile') diff --git a/server/middlewares/validators/webfinger.ts b/server/server/middlewares/validators/webfinger.ts similarity index 77% rename from server/middlewares/validators/webfinger.ts rename to server/server/middlewares/validators/webfinger.ts index dcfba99fa..63855bbf3 100644 --- a/server/middlewares/validators/webfinger.ts +++ b/server/server/middlewares/validators/webfinger.ts @@ -1,10 +1,10 @@ import express from 'express' import { query } from 'express-validator' -import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' -import { isWebfingerLocalResourceValid } from '../../helpers/custom-validators/webfinger' -import { getHostWithPort } from '../../helpers/express-utils' -import { ActorModel } from '../../models/actor/actor' -import { areValidationErrors } from './shared' +import { HttpStatusCode } from '@peertube/peertube-models' +import { isWebfingerLocalResourceValid } from '../../helpers/custom-validators/webfinger.js' +import { getHostWithPort } from '../../helpers/express-utils.js' +import { ActorModel } from '../../models/actor/actor.js' +import { areValidationErrors } from './shared/index.js' const webfingerValidator = [ query('resource') diff --git a/server/models/abuse/abuse-message.ts b/server/server/models/abuse/abuse-message.ts similarity index 87% rename from server/models/abuse/abuse-message.ts rename to server/server/models/abuse/abuse-message.ts index 14a5bffa2..9ba080e77 100644 --- a/server/models/abuse/abuse-message.ts +++ b/server/server/models/abuse/abuse-message.ts @@ -1,12 +1,12 @@ import { FindOptions } from 'sequelize' import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' -import { isAbuseMessageValid } from '@server/helpers/custom-validators/abuses' -import { MAbuseMessage, MAbuseMessageFormattable } from '@server/types/models' -import { AbuseMessage } from '@shared/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { AccountModel, ScopeNames as AccountScopeNames } from '../account/account' -import { getSort, throwIfNotValid } from '../shared' -import { AbuseModel } from './abuse' +import { isAbuseMessageValid } from '@server/helpers/custom-validators/abuses.js' +import { MAbuseMessage, MAbuseMessageFormattable } from '@server/types/models/index.js' +import { AbuseMessage } from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { AccountModel, ScopeNames as AccountScopeNames } from '../account/account.js' +import { getSort, throwIfNotValid } from '../shared/index.js' +import { AbuseModel } from './abuse.js' @Table({ tableName: 'abuseMessage', @@ -47,7 +47,7 @@ export class AbuseMessageModel extends Model @ForeignKey(() => AbuseModel) @Column @@ -60,7 +60,7 @@ export class AbuseMessageModel extends Model static listForApi (abuseId: number) { const getQuery = (forCount: boolean) => { diff --git a/server/models/abuse/abuse.ts b/server/server/models/abuse/abuse.ts similarity index 90% rename from server/models/abuse/abuse.ts rename to server/server/models/abuse/abuse.ts index 4ce40bf2f..8a8e292e4 100644 --- a/server/models/abuse/abuse.ts +++ b/server/server/models/abuse/abuse.ts @@ -1,5 +1,21 @@ -import { invert } from 'lodash' -import { literal, Op, QueryTypes } from 'sequelize' +import { abusePredefinedReasonsMap } from '@peertube/peertube-core-utils' +import { + AbuseFilter, + AbuseObject, + AbusePredefinedReasonsString, + AbusePredefinedReasonsType, + AbuseVideoIs, + AdminAbuse, + AdminVideoAbuse, + AdminVideoCommentAbuse, + UserAbuse, + UserVideoAbuse, + type AbuseStateType +} from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { isAbuseModerationCommentValid, isAbuseReasonValid, isAbuseStateValid } from '@server/helpers/custom-validators/abuses.js' +import invert from 'lodash-es/invert.js' +import { Op, QueryTypes, literal } from 'sequelize' import { AllowNull, BelongsTo, @@ -15,34 +31,25 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { isAbuseModerationCommentValid, isAbuseReasonValid, isAbuseStateValid } from '@server/helpers/custom-validators/abuses' -import { abusePredefinedReasonsMap } from '@shared/core-utils' +import { ABUSE_STATES, CONSTRAINTS_FIELDS } from '../../initializers/constants.js' import { - AbuseFilter, - AbuseObject, - AbusePredefinedReasons, - AbusePredefinedReasonsString, - AbuseState, - AbuseVideoIs, - AdminAbuse, - AdminVideoAbuse, - AdminVideoCommentAbuse, - UserAbuse, - UserVideoAbuse -} from '@shared/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { ABUSE_STATES, CONSTRAINTS_FIELDS } from '../../initializers/constants' -import { MAbuseAdminFormattable, MAbuseAP, MAbuseFull, MAbuseReporter, MAbuseUserFormattable, MUserAccountId } from '../../types/models' -import { AccountModel, ScopeNames as AccountScopeNames, SummaryOptions as AccountSummaryOptions } from '../account/account' -import { getSort, throwIfNotValid } from '../shared' -import { ThumbnailModel } from '../video/thumbnail' -import { ScopeNames as VideoScopeNames, VideoModel } from '../video/video' -import { VideoBlacklistModel } from '../video/video-blacklist' -import { ScopeNames as VideoChannelScopeNames, SummaryOptions as ChannelSummaryOptions, VideoChannelModel } from '../video/video-channel' -import { ScopeNames as CommentScopeNames, VideoCommentModel } from '../video/video-comment' -import { buildAbuseListQuery, BuildAbusesQueryOptions } from './sql/abuse-query-builder' -import { VideoAbuseModel } from './video-abuse' -import { VideoCommentAbuseModel } from './video-comment-abuse' + MAbuseAP, + MAbuseAdminFormattable, + MAbuseFull, + MAbuseReporter, + MAbuseUserFormattable, + MUserAccountId +} from '../../types/models/index.js' +import { AccountModel, ScopeNames as AccountScopeNames, SummaryOptions as AccountSummaryOptions } from '../account/account.js' +import { getSort, throwIfNotValid } from '../shared/index.js' +import { ThumbnailModel } from '../video/thumbnail.js' +import { VideoBlacklistModel } from '../video/video-blacklist.js' +import { SummaryOptions as ChannelSummaryOptions, VideoChannelModel, ScopeNames as VideoChannelScopeNames } from '../video/video-channel.js' +import { ScopeNames as CommentScopeNames, VideoCommentModel } from '../video/video-comment.js' +import { VideoModel, ScopeNames as VideoScopeNames } from '../video/video.js' +import { BuildAbusesQueryOptions, buildAbuseListQuery } from './sql/abuse-query-builder.js' +import { VideoAbuseModel } from './video-abuse.js' +import { VideoCommentAbuseModel } from './video-comment-abuse.js' export enum ScopeNames { FOR_API = 'FOR_API' @@ -200,7 +207,7 @@ export class AbuseModel extends Model>> { @Default(null) @Is('AbuseState', value => throwIfNotValid(value, isAbuseStateValid, 'state')) @Column - state: AbuseState + state: AbuseStateType @AllowNull(true) @Default(null) @@ -211,7 +218,7 @@ export class AbuseModel extends Model>> { @AllowNull(true) @Default(null) @Column(DataType.ARRAY(DataType.INTEGER)) - predefinedReasons: AbusePredefinedReasons[] + predefinedReasons: AbusePredefinedReasonsType[] @CreatedAt createdAt: Date @@ -231,7 +238,7 @@ export class AbuseModel extends Model>> { as: 'ReporterAccount', onDelete: 'set null' }) - ReporterAccount: AccountModel + ReporterAccount: Awaited @ForeignKey(() => AccountModel) @Column @@ -245,7 +252,7 @@ export class AbuseModel extends Model>> { as: 'FlaggedAccount', onDelete: 'set null' }) - FlaggedAccount: AccountModel + FlaggedAccount: Awaited @HasOne(() => VideoCommentAbuseModel, { foreignKey: { @@ -254,7 +261,7 @@ export class AbuseModel extends Model>> { }, onDelete: 'cascade' }) - VideoCommentAbuse: VideoCommentAbuseModel + VideoCommentAbuse: Awaited @HasOne(() => VideoAbuseModel, { foreignKey: { @@ -263,7 +270,7 @@ export class AbuseModel extends Model>> { }, onDelete: 'cascade' }) - VideoAbuse: VideoAbuseModel + VideoAbuse: Awaited static loadByIdWithReporter (id: number): Promise { const query = { @@ -339,7 +346,7 @@ export class AbuseModel extends Model>> { id?: number predefinedReason?: AbusePredefinedReasonsString - state?: AbuseState + state?: AbuseStateType videoIs?: AbuseVideoIs search?: string @@ -404,7 +411,7 @@ export class AbuseModel extends Model>> { id?: number search?: string - state?: AbuseState + state?: AbuseStateType }) { const { start, @@ -614,7 +621,7 @@ export class AbuseModel extends Model>> { return ABUSE_STATES[id] || 'Unknown' } - private static getPredefinedReasonsStrings (predefinedReasons: AbusePredefinedReasons[]): AbusePredefinedReasonsString[] { + private static getPredefinedReasonsStrings (predefinedReasons: AbusePredefinedReasonsType[]): AbusePredefinedReasonsString[] { const invertedPredefinedReasons = invert(abusePredefinedReasonsMap) return (predefinedReasons || []) diff --git a/server/models/abuse/sql/abuse-query-builder.ts b/server/server/models/abuse/sql/abuse-query-builder.ts similarity index 94% rename from server/models/abuse/sql/abuse-query-builder.ts rename to server/server/models/abuse/sql/abuse-query-builder.ts index 282d4541a..aeed91676 100644 --- a/server/models/abuse/sql/abuse-query-builder.ts +++ b/server/server/models/abuse/sql/abuse-query-builder.ts @@ -1,8 +1,8 @@ -import { exists } from '@server/helpers/custom-validators/misc' -import { forceNumber } from '@shared/core-utils' -import { AbuseFilter, AbuseState, AbuseVideoIs } from '@shared/models' -import { buildBlockedAccountSQL, buildSortDirectionAndField } from '../../shared' +import { forceNumber } from '@peertube/peertube-core-utils' +import { AbuseFilter, AbuseStateType, AbuseVideoIs } from '@peertube/peertube-models' +import { exists } from '@server/helpers/custom-validators/misc.js' +import { buildBlockedAccountSQL, buildSortDirectionAndField } from '../../shared/index.js' export type BuildAbusesQueryOptions = { start: number @@ -24,7 +24,7 @@ export type BuildAbusesQueryOptions = { predefinedReasonId?: number filter?: AbuseFilter - state?: AbuseState + state?: AbuseStateType // accountIds serverAccountId?: number diff --git a/server/models/abuse/video-abuse.ts b/server/server/models/abuse/video-abuse.ts similarity index 78% rename from server/models/abuse/video-abuse.ts rename to server/server/models/abuse/video-abuse.ts index 773a9ebba..1f2f85f1c 100644 --- a/server/models/abuse/video-abuse.ts +++ b/server/server/models/abuse/video-abuse.ts @@ -1,8 +1,8 @@ +import { type VideoDetails } from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript' -import { AttributesOnly } from '@shared/typescript-utils' -import { VideoDetails } from '@shared/models' -import { VideoModel } from '../video/video' -import { AbuseModel } from './abuse' +import { VideoModel } from '../video/video.js' +import { AbuseModel } from './abuse.js' @Table({ tableName: 'videoAbuse', @@ -48,7 +48,7 @@ export class VideoAbuseModel extends Model @ForeignKey(() => VideoModel) @Column @@ -60,5 +60,5 @@ export class VideoAbuseModel extends Model } diff --git a/server/models/abuse/video-comment-abuse.ts b/server/server/models/abuse/video-comment-abuse.ts similarity index 76% rename from server/models/abuse/video-comment-abuse.ts rename to server/server/models/abuse/video-comment-abuse.ts index 337aaaa58..6c5078aa8 100644 --- a/server/models/abuse/video-comment-abuse.ts +++ b/server/server/models/abuse/video-comment-abuse.ts @@ -1,7 +1,7 @@ import { BelongsTo, Column, CreatedAt, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript' -import { AttributesOnly } from '@shared/typescript-utils' -import { VideoCommentModel } from '../video/video-comment' -import { AbuseModel } from './abuse' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { VideoCommentModel } from '../video/video-comment.js' +import { AbuseModel } from './abuse.js' @Table({ tableName: 'commentAbuse', @@ -32,7 +32,7 @@ export class VideoCommentAbuseModel extends Model @ForeignKey(() => VideoCommentModel) @Column @@ -44,5 +44,5 @@ export class VideoCommentAbuseModel extends Model } diff --git a/server/models/account/account-blocklist.ts b/server/server/models/account/account-blocklist.ts similarity index 93% rename from server/models/account/account-blocklist.ts rename to server/server/models/account/account-blocklist.ts index f6212ff6e..fa7fa8021 100644 --- a/server/models/account/account-blocklist.ts +++ b/server/server/models/account/account-blocklist.ts @@ -1,13 +1,13 @@ import { FindOptions, Op, QueryTypes } from 'sequelize' import { BelongsTo, Column, CreatedAt, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript' -import { handlesToNameAndHost } from '@server/helpers/actors' -import { MAccountBlocklist, MAccountBlocklistFormattable } from '@server/types/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { AccountBlock } from '../../../shared/models' -import { ActorModel } from '../actor/actor' -import { ServerModel } from '../server/server' -import { createSafeIn, getSort, searchAttribute } from '../shared' -import { AccountModel } from './account' +import { AccountBlock } from '@peertube/peertube-models' +import { handlesToNameAndHost } from '@server/helpers/actors.js' +import { MAccountBlocklist, MAccountBlocklistFormattable } from '@server/types/models/index.js' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { ActorModel } from '../actor/actor.js' +import { ServerModel } from '../server/server.js' +import { createSafeIn, getSort, searchAttribute } from '../shared/index.js' +import { AccountModel } from './account.js' @Table({ tableName: 'accountBlocklist', @@ -41,7 +41,7 @@ export class AccountBlocklistModel extends Model @ForeignKey(() => AccountModel) @Column @@ -55,7 +55,7 @@ export class AccountBlocklistModel extends Model static isAccountMutedByAccounts (accountIds: number[], targetAccountId: number) { const query = { diff --git a/server/models/account/account-video-rate.ts b/server/server/models/account/account-video-rate.ts similarity index 90% rename from server/models/account/account-video-rate.ts rename to server/server/models/account/account-video-rate.ts index 18ff07d53..0d099ff9f 100644 --- a/server/models/account/account-video-rate.ts +++ b/server/server/models/account/account-video-rate.ts @@ -1,20 +1,20 @@ -import { FindOptions, Op, QueryTypes, Transaction } from 'sequelize' -import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' +import { AccountVideoRate, type VideoRateType } from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' import { MAccountVideoRate, MAccountVideoRateAccountUrl, MAccountVideoRateAccountVideo, MAccountVideoRateFormattable -} from '@server/types/models' -import { AccountVideoRate, VideoRateType } from '@shared/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' -import { CONSTRAINTS_FIELDS, VIDEO_RATE_TYPES } from '../../initializers/constants' -import { ActorModel } from '../actor/actor' -import { getSort, throwIfNotValid } from '../shared' -import { VideoModel } from '../video/video' -import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from '../video/video-channel' -import { AccountModel } from './account' +} from '@server/types/models/index.js' +import { FindOptions, Op, QueryTypes, Transaction } from 'sequelize' +import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' +import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc.js' +import { CONSTRAINTS_FIELDS, VIDEO_RATE_TYPES } from '../../initializers/constants.js' +import { ActorModel } from '../actor/actor.js' +import { getSort, throwIfNotValid } from '../shared/index.js' +import { SummaryOptions, VideoChannelModel, ScopeNames as VideoChannelScopeNames } from '../video/video-channel.js' +import { VideoModel } from '../video/video.js' +import { AccountModel } from './account.js' /* Account rates per video. @@ -68,7 +68,7 @@ export class AccountVideoRateModel extends Model @ForeignKey(() => AccountModel) @Column @@ -80,7 +80,7 @@ export class AccountVideoRateModel extends Model static load (accountId: number, videoId: number, transaction?: Transaction): Promise { const options: FindOptions = { diff --git a/server/models/account/account.ts b/server/server/models/account/account.ts similarity index 88% rename from server/models/account/account.ts rename to server/server/models/account/account.ts index 8593f2f28..7c2660c40 100644 --- a/server/models/account/account.ts +++ b/server/server/models/account/account.ts @@ -16,12 +16,12 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { ModelCache } from '@server/models/shared/model-cache' -import { AttributesOnly } from '@shared/typescript-utils' -import { Account, AccountSummary } from '../../../shared/models/actors' -import { isAccountDescriptionValid } from '../../helpers/custom-validators/accounts' -import { CONSTRAINTS_FIELDS, SERVER_ACTOR_NAME, WEBSERVER } from '../../initializers/constants' -import { sendDeleteActor } from '../../lib/activitypub/send/send-delete' +import { Account, AccountSummary } from '@peertube/peertube-models' +import { ModelCache } from '@server/models/shared/model-cache.js' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { isAccountDescriptionValid } from '../../helpers/custom-validators/accounts.js' +import { CONSTRAINTS_FIELDS, SERVER_ACTOR_NAME, WEBSERVER } from '../../initializers/constants.js' +import { sendDeleteActor } from '../../lib/activitypub/send/send-delete.js' import { MAccount, MAccountActor, @@ -31,20 +31,20 @@ import { MAccountHost, MAccountSummaryFormattable, MChannelHost -} from '../../types/models' -import { ActorModel } from '../actor/actor' -import { ActorFollowModel } from '../actor/actor-follow' -import { ActorImageModel } from '../actor/actor-image' -import { ApplicationModel } from '../application/application' -import { ServerModel } from '../server/server' -import { ServerBlocklistModel } from '../server/server-blocklist' -import { buildSQLAttributes, getSort, throwIfNotValid } from '../shared' -import { UserModel } from '../user/user' -import { VideoModel } from '../video/video' -import { VideoChannelModel } from '../video/video-channel' -import { VideoCommentModel } from '../video/video-comment' -import { VideoPlaylistModel } from '../video/video-playlist' -import { AccountBlocklistModel } from './account-blocklist' +} from '../../types/models/index.js' +import { ActorFollowModel } from '../actor/actor-follow.js' +import { ActorImageModel } from '../actor/actor-image.js' +import { ActorModel } from '../actor/actor.js' +import { ApplicationModel } from '../application/application.js' +import { ServerBlocklistModel } from '../server/server-blocklist.js' +import { ServerModel } from '../server/server.js' +import { buildSQLAttributes, getSort, throwIfNotValid } from '../shared/index.js' +import { UserModel } from '../user/user.js' +import { VideoChannelModel } from '../video/video-channel.js' +import { VideoCommentModel } from '../video/video-comment.js' +import { VideoPlaylistModel } from '../video/video-playlist.js' +import { VideoModel } from '../video/video.js' +import { AccountBlocklistModel } from './account-blocklist.js' export enum ScopeNames { SUMMARY = 'SUMMARY' @@ -174,7 +174,7 @@ export class AccountModel extends Model>> { }, onDelete: 'cascade' }) - Actor: ActorModel + Actor: Awaited @ForeignKey(() => UserModel) @Column @@ -186,7 +186,7 @@ export class AccountModel extends Model>> { }, onDelete: 'cascade' }) - User: UserModel + User: Awaited @ForeignKey(() => ApplicationModel) @Column @@ -198,7 +198,7 @@ export class AccountModel extends Model>> { }, onDelete: 'cascade' }) - Application: ApplicationModel + Application: Awaited @HasMany(() => VideoChannelModel, { foreignKey: { @@ -207,7 +207,7 @@ export class AccountModel extends Model>> { onDelete: 'cascade', hooks: true }) - VideoChannels: VideoChannelModel[] + VideoChannels: Awaited[] @HasMany(() => VideoPlaylistModel, { foreignKey: { @@ -216,7 +216,7 @@ export class AccountModel extends Model>> { onDelete: 'cascade', hooks: true }) - VideoPlaylists: VideoPlaylistModel[] + VideoPlaylists: Awaited[] @HasMany(() => VideoCommentModel, { foreignKey: { @@ -225,7 +225,7 @@ export class AccountModel extends Model>> { onDelete: 'cascade', hooks: true }) - VideoComments: VideoCommentModel[] + VideoComments: Awaited[] @HasMany(() => AccountBlocklistModel, { foreignKey: { @@ -235,7 +235,7 @@ export class AccountModel extends Model>> { as: 'BlockedBy', onDelete: 'CASCADE' }) - BlockedBy: AccountBlocklistModel[] + BlockedBy: Awaited[] @BeforeDestroy static async sendDeleteIfOwned (instance: AccountModel, options) { diff --git a/server/models/account/actor-custom-page.ts b/server/server/models/account/actor-custom-page.ts similarity index 86% rename from server/models/account/actor-custom-page.ts rename to server/server/models/account/actor-custom-page.ts index 893023181..8a9b09706 100644 --- a/server/models/account/actor-custom-page.ts +++ b/server/server/models/account/actor-custom-page.ts @@ -1,7 +1,7 @@ import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript' -import { CustomPage } from '@shared/models' -import { ActorModel } from '../actor/actor' -import { getServerActor } from '../application/application' +import { CustomPage } from '@peertube/peertube-models' +import { ActorModel } from '../actor/actor.js' +import { getServerActor } from '../application/application.js' @Table({ tableName: 'actorCustomPage', @@ -39,7 +39,7 @@ export class ActorCustomPageModel extends Model { }, onDelete: 'cascade' }) - Actor: ActorModel + Actor: Awaited static async updateInstanceHomepage (content: string) { const serverActor = await getServerActor() diff --git a/server/models/actor/actor-follow.ts b/server/server/models/actor/actor-follow.ts similarity index 95% rename from server/models/actor/actor-follow.ts rename to server/server/models/actor/actor-follow.ts index 71ce9fa6f..268edb5b4 100644 --- a/server/models/actor/actor-follow.ts +++ b/server/server/models/actor/actor-follow.ts @@ -1,5 +1,19 @@ -import { difference } from 'lodash' -import { Attributes, FindOptions, Includeable, IncludeOptions, Op, QueryTypes, Transaction, WhereAttributeHash } from 'sequelize' +import { ActorFollow, type FollowState } from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc.js' +import { afterCommitIfTransaction } from '@server/helpers/database-utils.js' +import { getServerActor } from '@server/models/application/application.js' +import { + MActor, + MActorFollowActors, + MActorFollowActorsDefault, + MActorFollowActorsDefaultSubscription, + MActorFollowFollowingHost, + MActorFollowFormattable, + MActorFollowSubscriptions +} from '@server/types/models/index.js' +import difference from 'lodash-es/difference.js' +import { Attributes, FindOptions, IncludeOptions, Includeable, Op, QueryTypes, Transaction, WhereAttributeHash } from 'sequelize' import { AfterCreate, AfterDestroy, @@ -18,31 +32,16 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc' -import { afterCommitIfTransaction } from '@server/helpers/database-utils' -import { getServerActor } from '@server/models/application/application' -import { - MActor, - MActorFollowActors, - MActorFollowActorsDefault, - MActorFollowActorsDefaultSubscription, - MActorFollowFollowingHost, - MActorFollowFormattable, - MActorFollowSubscriptions -} from '@server/types/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { FollowState } from '../../../shared/models/actors' -import { ActorFollow } from '../../../shared/models/actors/follow.model' -import { logger } from '../../helpers/logger' -import { ACTOR_FOLLOW_SCORE, CONSTRAINTS_FIELDS, FOLLOW_STATES, SERVER_ACTOR_NAME, SORTABLE_COLUMNS } from '../../initializers/constants' -import { AccountModel } from '../account/account' -import { ServerModel } from '../server/server' -import { buildSQLAttributes, createSafeIn, getSort, searchAttribute, throwIfNotValid } from '../shared' -import { doesExist } from '../shared/query' -import { VideoChannelModel } from '../video/video-channel' -import { ActorModel, unusedActorAttributesForAPI } from './actor' -import { InstanceListFollowersQueryBuilder, ListFollowersOptions } from './sql/instance-list-followers-query-builder' -import { InstanceListFollowingQueryBuilder, ListFollowingOptions } from './sql/instance-list-following-query-builder' +import { logger } from '../../helpers/logger.js' +import { ACTOR_FOLLOW_SCORE, CONSTRAINTS_FIELDS, FOLLOW_STATES, SERVER_ACTOR_NAME, SORTABLE_COLUMNS } from '../../initializers/constants.js' +import { AccountModel } from '../account/account.js' +import { ServerModel } from '../server/server.js' +import { buildSQLAttributes, createSafeIn, getSort, searchAttribute, throwIfNotValid } from '../shared/index.js' +import { doesExist } from '../shared/query.js' +import { VideoChannelModel } from '../video/video-channel.js' +import { ActorModel, unusedActorAttributesForAPI } from './actor.js' +import { InstanceListFollowersQueryBuilder, ListFollowersOptions } from './sql/instance-list-followers-query-builder.js' +import { InstanceListFollowingQueryBuilder, ListFollowingOptions } from './sql/instance-list-following-query-builder.js' @Table({ tableName: 'actorFollow', @@ -103,7 +102,7 @@ export class ActorFollowModel extends Model @ForeignKey(() => ActorModel) @Column @@ -117,7 +116,7 @@ export class ActorFollowModel extends Model @AfterCreate @AfterUpdate diff --git a/server/models/actor/actor-image.ts b/server/server/models/actor/actor-image.ts similarity index 82% rename from server/models/actor/actor-image.ts rename to server/server/models/actor/actor-image.ts index 51085a16d..727e89f04 100644 --- a/server/models/actor/actor-image.ts +++ b/server/server/models/actor/actor-image.ts @@ -1,4 +1,8 @@ -import { remove } from 'fs-extra' +import { ActivityIconObject, ActorImage, ActorImageType, type ActorImageType_Type } from '@peertube/peertube-models' +import { getLowercaseExtension } from '@peertube/peertube-node-utils' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { MActorImage, MActorImageFormattable } from '@server/types/models/index.js' +import { remove } from 'fs-extra/esm' import { join } from 'path' import { AfterDestroy, @@ -13,17 +17,12 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { MActorImage, MActorImageFormattable } from '@server/types/models' -import { getLowercaseExtension } from '@shared/core-utils' -import { ActivityIconObject, ActorImageType } from '@shared/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { ActorImage } from '../../../shared/models/actors/actor-image.model' -import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' -import { logger } from '../../helpers/logger' -import { CONFIG } from '../../initializers/config' -import { LAZY_STATIC_PATHS, MIMETYPES, WEBSERVER } from '../../initializers/constants' -import { buildSQLAttributes, throwIfNotValid } from '../shared' -import { ActorModel } from './actor' +import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc.js' +import { logger } from '../../helpers/logger.js' +import { CONFIG } from '../../initializers/config.js' +import { LAZY_STATIC_PATHS, MIMETYPES, WEBSERVER } from '../../initializers/constants.js' +import { buildSQLAttributes, throwIfNotValid } from '../shared/index.js' +import { ActorModel } from './actor.js' @Table({ tableName: 'actorImage', @@ -65,7 +64,7 @@ export class ActorImageModel extends Model // Remove awaited: https://github.com/sequelize/sequelize-typescript/issues/825 @AfterDestroy static removeFilesAndSendDelete (instance: ActorImageModel) { diff --git a/server/models/actor/actor.ts b/server/server/models/actor/actor.ts similarity index 90% rename from server/models/actor/actor.ts rename to server/server/models/actor/actor.ts index e2e85f3d6..adb009968 100644 --- a/server/models/actor/actor.ts +++ b/server/server/models/actor/actor.ts @@ -1,3 +1,11 @@ +import { forceNumber } from '@peertube/peertube-core-utils' +import { ActivityIconObject, ActorImageType, ActorImageType_Type, type ActivityPubActorType } from '@peertube/peertube-models' +import { getLowercaseExtension } from '@peertube/peertube-node-utils' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { activityPubContextify } from '@server/helpers/activity-pub-utils.js' +import { getContextFilter } from '@server/lib/activitypub/context.js' +import { getBiggestActorImage } from '@server/lib/actor-image.js' +import { ModelCache } from '@server/models/shared/model-cache.js' import { col, fn, literal, Op, QueryTypes, Transaction, where } from 'sequelize' import { AllowNull, @@ -15,20 +23,15 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { activityPubContextify } from '@server/lib/activitypub/context' -import { getBiggestActorImage } from '@server/lib/actor-image' -import { ModelCache } from '@server/models/shared/model-cache' -import { forceNumber, getLowercaseExtension } from '@shared/core-utils' -import { ActivityIconObject, ActivityPubActorType, ActorImageType } from '@shared/models' -import { AttributesOnly } from '@shared/typescript-utils' +import { Where } from 'sequelize/types/utils' import { isActorFollowersCountValid, isActorFollowingCountValid, isActorPreferredUsernameValid, isActorPrivateKeyValid, isActorPublicKeyValid -} from '../../helpers/custom-validators/activitypub/actor' -import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' +} from '../../helpers/custom-validators/activitypub/actor.js' +import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc.js' import { ACTIVITY_PUB, ACTIVITY_PUB_ACTOR_TYPES, @@ -36,7 +39,7 @@ import { MIMETYPES, SERVER_ACTOR_NAME, WEBSERVER -} from '../../initializers/constants' +} from '../../initializers/constants.js' import { MActor, MActorAccountChannelId, @@ -51,15 +54,15 @@ import { MActorSummaryFormattable, MActorUrl, MActorWithInboxes -} from '../../types/models' -import { AccountModel } from '../account/account' -import { getServerActor } from '../application/application' -import { ServerModel } from '../server/server' -import { buildSQLAttributes, isOutdated, throwIfNotValid } from '../shared' -import { VideoModel } from '../video/video' -import { VideoChannelModel } from '../video/video-channel' -import { ActorFollowModel } from './actor-follow' -import { ActorImageModel } from './actor-image' +} from '../../types/models/index.js' +import { AccountModel } from '../account/account.js' +import { getServerActor } from '../application/application.js' +import { ServerModel } from '../server/server.js' +import { buildSQLAttributes, isOutdated, throwIfNotValid } from '../shared/index.js' +import { VideoChannelModel } from '../video/video-channel.js' +import { VideoModel } from '../video/video.js' +import { ActorFollowModel } from './actor-follow.js' +import { ActorImageModel } from './actor-image.js' enum ScopeNames { FULL = 'FULL' @@ -243,7 +246,7 @@ export class ActorModel extends Model>> { type: ActorImageType.AVATAR } }) - Avatars: ActorImageModel[] + Avatars: Awaited[] @HasMany(() => ActorImageModel, { as: 'Banners', @@ -256,7 +259,7 @@ export class ActorModel extends Model>> { type: ActorImageType.BANNER } }) - Banners: ActorImageModel[] + Banners: Awaited[] @HasMany(() => ActorFollowModel, { foreignKey: { @@ -266,7 +269,7 @@ export class ActorModel extends Model>> { as: 'ActorFollowings', onDelete: 'cascade' }) - ActorFollowing: ActorFollowModel[] + ActorFollowing: Awaited[] @HasMany(() => ActorFollowModel, { foreignKey: { @@ -276,7 +279,7 @@ export class ActorModel extends Model>> { as: 'ActorFollowers', onDelete: 'cascade' }) - ActorFollowers: ActorFollowModel[] + ActorFollowers: Awaited[] @ForeignKey(() => ServerModel) @Column @@ -288,7 +291,7 @@ export class ActorModel extends Model>> { }, onDelete: 'cascade' }) - Server: ServerModel + Server: Awaited @HasOne(() => AccountModel, { foreignKey: { @@ -297,7 +300,7 @@ export class ActorModel extends Model>> { onDelete: 'cascade', hooks: true }) - Account: AccountModel + Account: Awaited @HasOne(() => VideoChannelModel, { foreignKey: { @@ -306,7 +309,7 @@ export class ActorModel extends Model>> { onDelete: 'cascade', hooks: true }) - VideoChannel: VideoChannelModel + VideoChannel: Awaited // --------------------------------------------------------------------------- @@ -329,7 +332,8 @@ export class ActorModel extends Model>> { // --------------------------------------------------------------------------- - static wherePreferredUsername (preferredUsername: string, colName = 'preferredUsername') { + // FIXME: have to specify the result type to not break peertube typings generation + static wherePreferredUsername (preferredUsername: string, colName = 'preferredUsername'): Where { return where(fn('lower', col(colName)), preferredUsername.toLowerCase()) } @@ -605,7 +609,7 @@ export class ActorModel extends Model>> { image } - return activityPubContextify(json, 'Actor') + return activityPubContextify(json, 'Actor', getContextFilter()) } getFollowerSharedInboxUrls (t: Transaction) { @@ -666,7 +670,7 @@ export class ActorModel extends Model>> { return this.Server ? this.Server.redundancyAllowed : false } - hasImage (type: ActorImageType) { + hasImage (type: ActorImageType_Type) { const images = type === ActorImageType.AVATAR ? this.Avatars : this.Banners diff --git a/server/models/actor/sql/instance-list-followers-query-builder.ts b/server/server/models/actor/sql/instance-list-followers-query-builder.ts similarity index 84% rename from server/models/actor/sql/instance-list-followers-query-builder.ts rename to server/server/models/actor/sql/instance-list-followers-query-builder.ts index 34ce29b5d..ce91bca0d 100644 --- a/server/models/actor/sql/instance-list-followers-query-builder.ts +++ b/server/server/models/actor/sql/instance-list-followers-query-builder.ts @@ -1,9 +1,9 @@ import { Sequelize } from 'sequelize' -import { ModelBuilder } from '@server/models/shared' -import { MActorFollowActorsDefault } from '@server/types/models' -import { ActivityPubActorType, FollowState } from '@shared/models' -import { parseRowCountResult } from '../../shared' -import { InstanceListFollowsQueryBuilder } from './shared/instance-list-follows-query-builder' +import { ModelBuilder } from '@server/models/shared/index.js' +import { MActorFollowActorsDefault } from '@server/types/models/index.js' +import { ActivityPubActorType, FollowState } from '@peertube/peertube-models' +import { parseRowCountResult } from '../../shared/index.js' +import { InstanceListFollowsQueryBuilder } from './shared/instance-list-follows-query-builder.js' export interface ListFollowersOptions { actorIds: number[] diff --git a/server/models/actor/sql/instance-list-following-query-builder.ts b/server/server/models/actor/sql/instance-list-following-query-builder.ts similarity index 85% rename from server/models/actor/sql/instance-list-following-query-builder.ts rename to server/server/models/actor/sql/instance-list-following-query-builder.ts index 77b4e3dce..dab70db43 100644 --- a/server/models/actor/sql/instance-list-following-query-builder.ts +++ b/server/server/models/actor/sql/instance-list-following-query-builder.ts @@ -1,9 +1,9 @@ import { Sequelize } from 'sequelize' -import { ModelBuilder } from '@server/models/shared' -import { MActorFollowActorsDefault } from '@server/types/models' -import { ActivityPubActorType, FollowState } from '@shared/models' -import { parseRowCountResult } from '../../shared' -import { InstanceListFollowsQueryBuilder } from './shared/instance-list-follows-query-builder' +import { ModelBuilder } from '@server/models/shared/index.js' +import { MActorFollowActorsDefault } from '@server/types/models/index.js' +import { ActivityPubActorType, FollowState } from '@peertube/peertube-models' +import { parseRowCountResult } from '../../shared/index.js' +import { InstanceListFollowsQueryBuilder } from './shared/instance-list-follows-query-builder.js' export interface ListFollowingOptions { followerId: number diff --git a/server/models/actor/sql/shared/actor-follow-table-attributes.ts b/server/server/models/actor/sql/shared/actor-follow-table-attributes.ts similarity index 71% rename from server/models/actor/sql/shared/actor-follow-table-attributes.ts rename to server/server/models/actor/sql/shared/actor-follow-table-attributes.ts index 4431aa6d1..409c2f0e2 100644 --- a/server/models/actor/sql/shared/actor-follow-table-attributes.ts +++ b/server/server/models/actor/sql/shared/actor-follow-table-attributes.ts @@ -1,8 +1,8 @@ -import { Memoize } from '@server/helpers/memoize' -import { ServerModel } from '@server/models/server/server' -import { ActorModel } from '../../actor' -import { ActorFollowModel } from '../../actor-follow' -import { ActorImageModel } from '../../actor-image' +import { Memoize } from '@server/helpers/memoize.js' +import { ServerModel } from '@server/models/server/server.js' +import { ActorModel } from '../../actor.js' +import { ActorFollowModel } from '../../actor-follow.js' +import { ActorImageModel } from '../../actor-image.js' export class ActorFollowTableAttributes { diff --git a/server/models/actor/sql/shared/instance-list-follows-query-builder.ts b/server/server/models/actor/sql/shared/instance-list-follows-query-builder.ts similarity index 93% rename from server/models/actor/sql/shared/instance-list-follows-query-builder.ts rename to server/server/models/actor/sql/shared/instance-list-follows-query-builder.ts index d9593e48b..e0569e2f8 100644 --- a/server/models/actor/sql/shared/instance-list-follows-query-builder.ts +++ b/server/server/models/actor/sql/shared/instance-list-follows-query-builder.ts @@ -1,8 +1,8 @@ import { Sequelize } from 'sequelize' -import { AbstractRunQuery } from '@server/models/shared' -import { ActorImageType } from '@shared/models' -import { getInstanceFollowsSort } from '../../../shared' -import { ActorFollowTableAttributes } from './actor-follow-table-attributes' +import { AbstractRunQuery } from '@server/models/shared/index.js' +import { ActorImageType } from '@peertube/peertube-models' +import { getInstanceFollowsSort } from '../../../shared/index.js' +import { ActorFollowTableAttributes } from './actor-follow-table-attributes.js' type BaseOptions = { sort: string diff --git a/server/models/application/application.ts b/server/server/models/application/application.ts similarity index 87% rename from server/models/application/application.ts rename to server/server/models/application/application.ts index c51ceb245..1b1ff15b1 100644 --- a/server/models/application/application.ts +++ b/server/server/models/application/application.ts @@ -1,8 +1,8 @@ import memoizee from 'memoizee' import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript' -import { getNodeABIVersion } from '@server/helpers/version' -import { AttributesOnly } from '@shared/typescript-utils' -import { AccountModel } from '../account/account' +import { getNodeABIVersion } from '@server/helpers/version.js' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { AccountModel } from '../account/account.js' export const getServerActor = memoizee(async function () { const application = await ApplicationModel.load() @@ -52,7 +52,7 @@ export class ApplicationModel extends Model static countTotal () { return ApplicationModel.count() diff --git a/server/models/oauth/oauth-client.ts b/server/server/models/oauth/oauth-client.ts similarity index 87% rename from server/models/oauth/oauth-client.ts rename to server/server/models/oauth/oauth-client.ts index 457e84613..3d17f2431 100644 --- a/server/models/oauth/oauth-client.ts +++ b/server/server/models/oauth/oauth-client.ts @@ -1,6 +1,6 @@ import { AllowNull, Column, CreatedAt, DataType, HasMany, Model, Table, UpdatedAt } from 'sequelize-typescript' -import { AttributesOnly } from '@shared/typescript-utils' -import { OAuthTokenModel } from './oauth-token' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { OAuthTokenModel } from './oauth-token.js' @Table({ tableName: 'oAuthClient', @@ -40,7 +40,7 @@ export class OAuthClientModel extends Model OAuthTokenModel, { onDelete: 'cascade' }) - OAuthTokens: OAuthTokenModel[] + OAuthTokens: Awaited[] static countTotal () { return OAuthClientModel.count() diff --git a/server/models/oauth/oauth-token.ts b/server/server/models/oauth/oauth-token.ts similarity index 87% rename from server/models/oauth/oauth-token.ts rename to server/server/models/oauth/oauth-token.ts index f72423190..7101e199a 100644 --- a/server/models/oauth/oauth-token.ts +++ b/server/server/models/oauth/oauth-token.ts @@ -12,21 +12,22 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { TokensCache } from '@server/lib/auth/tokens-cache' -import { MUserAccountId } from '@server/types/models' -import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token' -import { AttributesOnly } from '@shared/typescript-utils' -import { logger } from '../../helpers/logger' -import { AccountModel } from '../account/account' -import { ActorModel } from '../actor/actor' -import { UserModel } from '../user/user' -import { OAuthClientModel } from './oauth-client' +import { TokensCache } from '@server/lib/auth/tokens-cache.js' +import { MUserAccountId } from '@server/types/models/index.js' +import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token.js' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { logger } from '../../helpers/logger.js' +import { AccountModel } from '../account/account.js' +import { ActorModel } from '../actor/actor.js' +import { UserModel } from '../user/user.js' +import { OAuthClientModel } from './oauth-client.js' export type OAuthTokenInfo = { refreshToken: string refreshTokenExpiresAt: Date client: { id: number + grants: string[] } user: MUserAccountId token: MOAuthTokenUser @@ -116,7 +117,7 @@ export class OAuthTokenModel extends Model @ForeignKey(() => OAuthClientModel) @Column @@ -128,7 +129,7 @@ export class OAuthTokenModel extends Model[] @AfterUpdate @AfterDestroy @@ -161,7 +162,8 @@ export class OAuthTokenModel extends Model @ForeignKey(() => VideoStreamingPlaylistModel) @Column @@ -138,7 +138,7 @@ export class VideoRedundancyModel extends Model @ForeignKey(() => ActorModel) @Column @@ -150,7 +150,7 @@ export class VideoRedundancyModel extends Model @BeforeDestroy static async removeFile (instance: VideoRedundancyModel) { diff --git a/server/models/runner/runner-job.ts b/server/server/models/runner/runner-job.ts similarity index 89% rename from server/models/runner/runner-job.ts rename to server/server/models/runner/runner-job.ts index f2ffd6a84..1ebcdae1d 100644 --- a/server/models/runner/runner-job.ts +++ b/server/server/models/runner/runner-job.ts @@ -1,3 +1,16 @@ +import { + RunnerJob, + RunnerJobAdmin, + RunnerJobState, + type RunnerJobPayload, + type RunnerJobPrivatePayload, + type RunnerJobStateType, + type RunnerJobType +} from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { isArray, isUUIDValid } from '@server/helpers/custom-validators/misc.js' +import { CONSTRAINTS_FIELDS, RUNNER_JOB_STATES } from '@server/initializers/constants.js' +import { MRunnerJob, MRunnerJobRunner, MRunnerJobRunnerParent } from '@server/types/models/runners/index.js' import { Op, Transaction } from 'sequelize' import { AllowNull, @@ -13,13 +26,8 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { isArray, isUUIDValid } from '@server/helpers/custom-validators/misc' -import { CONSTRAINTS_FIELDS, RUNNER_JOB_STATES } from '@server/initializers/constants' -import { MRunnerJob, MRunnerJobRunner, MRunnerJobRunnerParent } from '@server/types/models/runners' -import { RunnerJob, RunnerJobAdmin, RunnerJobPayload, RunnerJobPrivatePayload, RunnerJobState, RunnerJobType } from '@shared/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { getSort, searchAttribute } from '../shared' -import { RunnerModel } from './runner' +import { getSort, searchAttribute } from '../shared/index.js' +import { RunnerModel } from './runner.js' enum ScopeNames { WITH_RUNNER = 'WITH_RUNNER', @@ -81,7 +89,7 @@ export class RunnerJobModel extends Model @AllowNull(false) @Column - state: RunnerJobState + state: RunnerJobStateType @AllowNull(false) @Default(0) @@ -131,7 +139,7 @@ export class RunnerJobModel extends Model }, onDelete: 'cascade' }) - DependsOnRunnerJob: RunnerJobModel + DependsOnRunnerJob: Awaited @ForeignKey(() => RunnerModel) @Column @@ -144,7 +152,7 @@ export class RunnerJobModel extends Model }, onDelete: 'SET NULL' }) - Runner: RunnerModel + Runner: Awaited // --------------------------------------------------------------------------- @@ -227,7 +235,7 @@ export class RunnerJobModel extends Model count: number sort: string search?: string - stateOneOf?: RunnerJobState[] + stateOneOf?: RunnerJobStateType[] }) { const { start, count, sort, search, stateOneOf } = options @@ -292,7 +300,8 @@ export class RunnerJobModel extends Model } setToErrorOrCancel ( - state: RunnerJobState.PARENT_ERRORED | RunnerJobState.ERRORED | RunnerJobState.CANCELLED | RunnerJobState.PARENT_CANCELLED + // eslint-disable-next-line max-len + state: typeof RunnerJobState.PARENT_ERRORED | typeof RunnerJobState.ERRORED | typeof RunnerJobState.CANCELLED | typeof RunnerJobState.PARENT_CANCELLED ) { this.state = state this.processingJobToken = null diff --git a/server/models/runner/runner-registration-token.ts b/server/server/models/runner/runner-registration-token.ts similarity index 89% rename from server/models/runner/runner-registration-token.ts rename to server/server/models/runner/runner-registration-token.ts index b2ae6c9eb..1bde519ca 100644 --- a/server/models/runner/runner-registration-token.ts +++ b/server/server/models/runner/runner-registration-token.ts @@ -1,10 +1,10 @@ import { FindOptions, literal } from 'sequelize' import { AllowNull, Column, CreatedAt, HasMany, Model, Table, UpdatedAt } from 'sequelize-typescript' -import { MRunnerRegistrationToken } from '@server/types/models/runners' -import { RunnerRegistrationToken } from '@shared/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { getSort } from '../shared' -import { RunnerModel } from './runner' +import { MRunnerRegistrationToken } from '@server/types/models/runners/index.js' +import { RunnerRegistrationToken } from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { getSort } from '../shared/index.js' +import { RunnerModel } from './runner.js' /** * @@ -39,7 +39,7 @@ export class RunnerRegistrationTokenModel extends Model[] static load (id: number) { return RunnerRegistrationTokenModel.findByPk(id) diff --git a/server/models/runner/runner.ts b/server/server/models/runner/runner.ts similarity index 88% rename from server/models/runner/runner.ts rename to server/server/models/runner/runner.ts index 4d07707d8..5c968b1c2 100644 --- a/server/models/runner/runner.ts +++ b/server/server/models/runner/runner.ts @@ -1,11 +1,11 @@ import { FindOptions } from 'sequelize' import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript' -import { MRunner } from '@server/types/models/runners' -import { Runner } from '@shared/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { getSort } from '../shared' -import { RunnerRegistrationTokenModel } from './runner-registration-token' -import { CONSTRAINTS_FIELDS } from '@server/initializers/constants' +import { MRunner } from '@server/types/models/runners/index.js' +import { Runner } from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { getSort } from '../shared/index.js' +import { RunnerRegistrationTokenModel } from './runner-registration-token.js' +import { CONSTRAINTS_FIELDS } from '@server/initializers/constants.js' @Table({ tableName: 'runner', @@ -62,7 +62,7 @@ export class RunnerModel extends Model>> { }, onDelete: 'cascade' }) - RunnerRegistrationToken: RunnerRegistrationTokenModel + RunnerRegistrationToken: Awaited // --------------------------------------------------------------------------- diff --git a/server/models/server/plugin.ts b/server/server/models/server/plugin.ts similarity index 87% rename from server/models/server/plugin.ts rename to server/server/models/server/plugin.ts index 9948c9f7a..ff8350b6a 100644 --- a/server/models/server/plugin.ts +++ b/server/server/models/server/plugin.ts @@ -1,8 +1,15 @@ +import { + PeerTubePlugin, + PluginType, + RegisterServerSettingOptions, + SettingEntries, + SettingValue, + type PluginType_Type +} from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { MPlugin, MPluginFormattable } from '@server/types/models/index.js' import { FindAndCountOptions, json, QueryTypes } from 'sequelize' import { AllowNull, Column, CreatedAt, DataType, DefaultScope, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' -import { MPlugin, MPluginFormattable } from '@server/types/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { PeerTubePlugin, PluginType, RegisterServerSettingOptions, SettingEntries, SettingValue } from '../../../shared/models' import { isPluginDescriptionValid, isPluginHomepage, @@ -10,8 +17,8 @@ import { isPluginStableOrUnstableVersionValid, isPluginStableVersionValid, isPluginTypeValid -} from '../../helpers/custom-validators/plugins' -import { getSort, throwIfNotValid } from '../shared' +} from '../../helpers/custom-validators/plugins.js' +import { getSort, throwIfNotValid } from '../shared/index.js' @DefaultScope(() => ({ attributes: { @@ -38,7 +45,7 @@ export class PluginModel extends Model>> { @AllowNull(false) @Is('PluginType', value => throwIfNotValid(value, isPluginTypeValid, 'type')) @Column - type: number + type: PluginType_Type @AllowNull(false) @Is('PluginVersion', value => throwIfNotValid(value, isPluginStableOrUnstableVersionValid, 'version')) @@ -111,7 +118,12 @@ export class PluginModel extends Model>> { return PluginModel.findOne(query) } - static getSetting (pluginName: string, pluginType: PluginType, settingName: string, registeredSettings: RegisterServerSettingOptions[]) { + static getSetting ( + pluginName: string, + pluginType: PluginType_Type, + settingName: string, + registeredSettings: RegisterServerSettingOptions[] + ) { const query = { attributes: [ 'settings' ], where: { @@ -135,7 +147,7 @@ export class PluginModel extends Model>> { static getSettings ( pluginName: string, - pluginType: PluginType, + pluginType: PluginType_Type, settingNames: string[], registeredSettings: RegisterServerSettingOptions[] ) { @@ -167,7 +179,7 @@ export class PluginModel extends Model>> { }) } - static setSetting (pluginName: string, pluginType: PluginType, settingName: string, settingValue: SettingValue) { + static setSetting (pluginName: string, pluginType: PluginType_Type, settingName: string, settingValue: SettingValue) { const query = { where: { name: pluginName, @@ -183,7 +195,7 @@ export class PluginModel extends Model>> { .then(() => undefined) } - static getData (pluginName: string, pluginType: PluginType, key: string) { + static getData (pluginName: string, pluginType: PluginType_Type, key: string) { const query = { raw: true, attributes: [ [ json('storage.' + key), 'value' ] as any ], // FIXME: typings @@ -206,7 +218,7 @@ export class PluginModel extends Model>> { }) } - static storeData (pluginName: string, pluginType: PluginType, key: string, data: any) { + static storeData (pluginName: string, pluginType: PluginType_Type, key: string, data: any) { const query = 'UPDATE "plugin" SET "storage" = jsonb_set(coalesce("storage", \'{}\'), :key, :data::jsonb) ' + 'WHERE "name" = :pluginName AND "type" = :pluginType' @@ -222,7 +234,7 @@ export class PluginModel extends Model>> { } static listForApi (options: { - pluginType?: PluginType + pluginType?: PluginType_Type uninstalled?: boolean start: number count: number @@ -266,7 +278,7 @@ export class PluginModel extends Model>> { : PluginType.THEME } - static buildNpmName (name: string, type: PluginType) { + static buildNpmName (name: string, type: PluginType_Type) { if (type === PluginType.THEME) return 'peertube-theme-' + name return 'peertube-plugin-' + name diff --git a/server/models/server/server-blocklist.ts b/server/server/models/server/server-blocklist.ts similarity index 92% rename from server/models/server/server-blocklist.ts rename to server/server/models/server/server-blocklist.ts index 3d755fe4a..7817d122e 100644 --- a/server/models/server/server-blocklist.ts +++ b/server/server/models/server/server-blocklist.ts @@ -1,11 +1,11 @@ import { Op, QueryTypes } from 'sequelize' import { BelongsTo, Column, CreatedAt, ForeignKey, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' -import { MServerBlocklist, MServerBlocklistAccountServer, MServerBlocklistFormattable } from '@server/types/models' -import { ServerBlock } from '@shared/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { AccountModel } from '../account/account' -import { createSafeIn, getSort, searchAttribute } from '../shared' -import { ServerModel } from './server' +import { MServerBlocklist, MServerBlocklistAccountServer, MServerBlocklistFormattable } from '@server/types/models/index.js' +import { ServerBlock } from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { AccountModel } from '../account/account.js' +import { createSafeIn, getSort, searchAttribute } from '../shared/index.js' +import { ServerModel } from './server.js' enum ScopeNames { WITH_ACCOUNT = 'WITH_ACCOUNT', @@ -62,7 +62,7 @@ export class ServerBlocklistModel extends Model @ForeignKey(() => ServerModel) @Column @@ -74,7 +74,7 @@ export class ServerBlocklistModel extends Model static isServerMutedByAccounts (accountIds: number[], targetServerId: number) { const query = { diff --git a/server/models/server/server.ts b/server/server/models/server/server.ts similarity index 85% rename from server/models/server/server.ts rename to server/server/models/server/server.ts index a5e05f460..a50cc25d8 100644 --- a/server/models/server/server.ts +++ b/server/server/models/server/server.ts @@ -1,11 +1,11 @@ import { Transaction } from 'sequelize' import { AllowNull, Column, CreatedAt, Default, HasMany, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' -import { MServer, MServerFormattable } from '@server/types/models/server' -import { AttributesOnly } from '@shared/typescript-utils' -import { isHostValid } from '../../helpers/custom-validators/servers' -import { ActorModel } from '../actor/actor' -import { buildSQLAttributes, throwIfNotValid } from '../shared' -import { ServerBlocklistModel } from './server-blocklist' +import { MServer, MServerFormattable } from '@server/types/models/server/index.js' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { isHostValid } from '../../helpers/custom-validators/servers.js' +import { ActorModel } from '../actor/actor.js' +import { buildSQLAttributes, throwIfNotValid } from '../shared/index.js' +import { ServerBlocklistModel } from './server-blocklist.js' @Table({ tableName: 'server', @@ -42,7 +42,7 @@ export class ServerModel extends Model>> { onDelete: 'CASCADE', hooks: true }) - Actors: ActorModel[] + Actors: Awaited[] @HasMany(() => ServerBlocklistModel, { foreignKey: { @@ -50,7 +50,7 @@ export class ServerModel extends Model>> { }, onDelete: 'CASCADE' }) - BlockedBy: ServerBlocklistModel[] + BlockedBy: Awaited[] // --------------------------------------------------------------------------- diff --git a/server/models/server/tracker.ts b/server/server/models/server/tracker.ts similarity index 82% rename from server/models/server/tracker.ts rename to server/server/models/server/tracker.ts index ee087c4a3..46955768d 100644 --- a/server/models/server/tracker.ts +++ b/server/server/models/server/tracker.ts @@ -1,9 +1,9 @@ import { AllowNull, BelongsToMany, Column, CreatedAt, Model, Table, UpdatedAt } from 'sequelize-typescript' -import { Transaction } from 'sequelize/types' -import { MTracker } from '@server/types/models/server/tracker' -import { AttributesOnly } from '@shared/typescript-utils' -import { VideoModel } from '../video/video' -import { VideoTrackerModel } from './video-tracker' +import { Transaction } from 'sequelize' +import { MTracker } from '@server/types/models/server/tracker.js' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { VideoModel } from '../video/video.js' +import { VideoTrackerModel } from './video-tracker.js' @Table({ tableName: 'tracker', @@ -31,7 +31,7 @@ export class TrackerModel extends Model>> { through: () => VideoTrackerModel, onDelete: 'CASCADE' }) - Videos: VideoModel[] + Videos: Awaited[] static listUrlsByVideoId (videoId: number) { const query = { diff --git a/server/models/server/video-tracker.ts b/server/server/models/server/video-tracker.ts similarity index 76% rename from server/models/server/video-tracker.ts rename to server/server/models/server/video-tracker.ts index f14f3bd7d..a925dc5c1 100644 --- a/server/models/server/video-tracker.ts +++ b/server/server/models/server/video-tracker.ts @@ -1,7 +1,7 @@ import { Column, CreatedAt, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript' -import { AttributesOnly } from '@shared/typescript-utils' -import { VideoModel } from '../video/video' -import { TrackerModel } from './tracker' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { VideoModel } from '../video/video.js' +import { TrackerModel } from './tracker.js' @Table({ tableName: 'videoTracker', diff --git a/server/models/shared/abstract-run-query.ts b/server/server/models/shared/abstract-run-query.ts similarity index 100% rename from server/models/shared/abstract-run-query.ts rename to server/server/models/shared/abstract-run-query.ts diff --git a/server/server/models/shared/index.ts b/server/server/models/shared/index.ts new file mode 100644 index 000000000..53cf65d5f --- /dev/null +++ b/server/server/models/shared/index.ts @@ -0,0 +1,8 @@ +export * from './abstract-run-query.js' +export * from './model-builder.js' +export * from './model-cache.js' +export * from './query.js' +export * from './sequelize-helpers.js' +export * from './sort.js' +export * from './sql.js' +export * from './update.js' diff --git a/server/models/shared/model-builder.ts b/server/server/models/shared/model-builder.ts similarity index 97% rename from server/models/shared/model-builder.ts rename to server/server/models/shared/model-builder.ts index 07f7c4038..c19ce2d56 100644 --- a/server/models/shared/model-builder.ts +++ b/server/server/models/shared/model-builder.ts @@ -1,6 +1,6 @@ -import { isPlainObject } from 'lodash' +import isPlainObject from 'lodash-es/isPlainObject.js' import { Model as SequelizeModel, ModelStatic, Sequelize } from 'sequelize' -import { logger } from '@server/helpers/logger' +import { logger } from '@server/helpers/logger.js' /** * diff --git a/server/models/shared/model-cache.ts b/server/server/models/shared/model-cache.ts similarity index 97% rename from server/models/shared/model-cache.ts rename to server/server/models/shared/model-cache.ts index 3651267e7..273d8e608 100644 --- a/server/models/shared/model-cache.ts +++ b/server/server/models/shared/model-cache.ts @@ -1,5 +1,5 @@ import { Model } from 'sequelize-typescript' -import { logger } from '@server/helpers/logger' +import { logger } from '@server/helpers/logger.js' type ModelCacheType = 'local-account-name' diff --git a/server/models/shared/query.ts b/server/server/models/shared/query.ts similarity index 84% rename from server/models/shared/query.ts rename to server/server/models/shared/query.ts index 934acc21f..0158454e8 100644 --- a/server/models/shared/query.ts +++ b/server/server/models/shared/query.ts @@ -1,6 +1,7 @@ import { BindOrReplacements, Op, QueryTypes, Sequelize } from 'sequelize' +import { Fn } from 'sequelize/types/utils' import validator from 'validator' -import { forceNumber } from '@shared/core-utils' +import { forceNumber } from '@peertube/peertube-core-utils' function doesExist (sequelize: Sequelize, query: string, bind?: BindOrReplacements) { const options = { @@ -13,7 +14,8 @@ function doesExist (sequelize: Sequelize, query: string, bind?: BindOrReplacemen .then(results => results.length === 1) } -function createSimilarityAttribute (col: string, value: string) { +// FIXME: have to specify the result type to not break peertube typings generation +function createSimilarityAttribute (col: string, value: string): Fn { return Sequelize.fn( 'similarity', @@ -24,7 +26,7 @@ function createSimilarityAttribute (col: string, value: string) { } function buildWhereIdOrUUID (id: number | string) { - return validator.isInt('' + id) ? { id } : { uuid: id } + return validator.default.isInt('' + id) ? { id } : { uuid: id } } function parseAggregateResult (result: any) { diff --git a/server/models/shared/sequelize-helpers.ts b/server/server/models/shared/sequelize-helpers.ts similarity index 100% rename from server/models/shared/sequelize-helpers.ts rename to server/server/models/shared/sequelize-helpers.ts diff --git a/server/models/shared/sort.ts b/server/server/models/shared/sort.ts similarity index 100% rename from server/models/shared/sort.ts rename to server/server/models/shared/sort.ts diff --git a/server/models/shared/sql.ts b/server/server/models/shared/sql.ts similarity index 82% rename from server/models/shared/sql.ts rename to server/server/models/shared/sql.ts index 5aaeb49f0..3f22dd4e3 100644 --- a/server/models/shared/sql.ts +++ b/server/server/models/shared/sql.ts @@ -1,14 +1,17 @@ import { literal, Model, ModelStatic } from 'sequelize' -import { forceNumber } from '@shared/core-utils' -import { AttributesOnly } from '@shared/typescript-utils' +import { Literal } from 'sequelize/types/utils' +import { forceNumber } from '@peertube/peertube-core-utils' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' -function buildLocalAccountIdsIn () { +// FIXME: have to specify the result type to not break peertube typings generation +function buildLocalAccountIdsIn (): Literal { return literal( '(SELECT "account"."id" FROM "account" INNER JOIN "actor" ON "actor"."id" = "account"."actorId" AND "actor"."serverId" IS NULL)' ) } -function buildLocalActorIdsIn () { +// FIXME: have to specify the result type to not break peertube typings generation +function buildLocalActorIdsIn (): Literal { return literal( '(SELECT "actor"."id" FROM "actor" WHERE "actor"."serverId" IS NULL)' ) diff --git a/server/models/shared/update.ts b/server/server/models/shared/update.ts similarity index 100% rename from server/models/shared/update.ts rename to server/server/models/shared/update.ts diff --git a/server/models/user/sql/user-notitication-list-query-builder.ts b/server/server/models/user/sql/user-notitication-list-query-builder.ts similarity index 99% rename from server/models/user/sql/user-notitication-list-query-builder.ts rename to server/server/models/user/sql/user-notitication-list-query-builder.ts index 7b29807a3..ba3a2d70f 100644 --- a/server/models/user/sql/user-notitication-list-query-builder.ts +++ b/server/server/models/user/sql/user-notitication-list-query-builder.ts @@ -1,8 +1,8 @@ import { Sequelize } from 'sequelize' -import { AbstractRunQuery, ModelBuilder } from '@server/models/shared' -import { UserNotificationModelForApi } from '@server/types/models' -import { ActorImageType } from '@shared/models' -import { getSort } from '../../shared' +import { AbstractRunQuery, ModelBuilder } from '@server/models/shared/index.js' +import { UserNotificationModelForApi } from '@server/types/models/index.js' +import { ActorImageType } from '@peertube/peertube-models' +import { getSort } from '../../shared/index.js' export interface ListNotificationsOptions { userId: number diff --git a/server/models/user/user-notification-setting.ts b/server/server/models/user/user-notification-setting.ts similarity index 79% rename from server/models/user/user-notification-setting.ts rename to server/server/models/user/user-notification-setting.ts index 394494c0c..8b59fbe70 100644 --- a/server/models/user/user-notification-setting.ts +++ b/server/server/models/user/user-notification-setting.ts @@ -1,3 +1,7 @@ +import { type UserNotificationSetting, type UserNotificationSettingValueType } from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { TokensCache } from '@server/lib/auth/tokens-cache.js' +import { MNotificationSettingFormattable } from '@server/types/models/index.js' import { AfterDestroy, AfterUpdate, @@ -12,13 +16,9 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { TokensCache } from '@server/lib/auth/tokens-cache' -import { MNotificationSettingFormattable } from '@server/types/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { UserNotificationSetting, UserNotificationSettingValue } from '../../../shared/models/users/user-notification-setting.model' -import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications' -import { throwIfNotValid } from '../shared' -import { UserModel } from './user' +import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications.js' +import { throwIfNotValid } from '../shared/index.js' +import { UserModel } from './user.js' @Table({ tableName: 'userNotificationSetting', @@ -38,7 +38,7 @@ export class UserNotificationSettingModel extends Model throwIfNotValid(value, isUserNotificationSettingValid, 'newVideoFromSubscription') ) @Column - newVideoFromSubscription: UserNotificationSettingValue + newVideoFromSubscription: UserNotificationSettingValueType @AllowNull(false) @Default(null) @@ -47,7 +47,7 @@ export class UserNotificationSettingModel extends Model throwIfNotValid(value, isUserNotificationSettingValid, 'newCommentOnMyVideo') ) @Column - newCommentOnMyVideo: UserNotificationSettingValue + newCommentOnMyVideo: UserNotificationSettingValueType @AllowNull(false) @Default(null) @@ -56,7 +56,7 @@ export class UserNotificationSettingModel extends Model throwIfNotValid(value, isUserNotificationSettingValid, 'abuseAsModerator') ) @Column - abuseAsModerator: UserNotificationSettingValue + abuseAsModerator: UserNotificationSettingValueType @AllowNull(false) @Default(null) @@ -65,7 +65,7 @@ export class UserNotificationSettingModel extends Model throwIfNotValid(value, isUserNotificationSettingValid, 'videoAutoBlacklistAsModerator') ) @Column - videoAutoBlacklistAsModerator: UserNotificationSettingValue + videoAutoBlacklistAsModerator: UserNotificationSettingValueType @AllowNull(false) @Default(null) @@ -74,7 +74,7 @@ export class UserNotificationSettingModel extends Model throwIfNotValid(value, isUserNotificationSettingValid, 'blacklistOnMyVideo') ) @Column - blacklistOnMyVideo: UserNotificationSettingValue + blacklistOnMyVideo: UserNotificationSettingValueType @AllowNull(false) @Default(null) @@ -83,7 +83,7 @@ export class UserNotificationSettingModel extends Model throwIfNotValid(value, isUserNotificationSettingValid, 'myVideoPublished') ) @Column - myVideoPublished: UserNotificationSettingValue + myVideoPublished: UserNotificationSettingValueType @AllowNull(false) @Default(null) @@ -92,7 +92,7 @@ export class UserNotificationSettingModel extends Model throwIfNotValid(value, isUserNotificationSettingValid, 'myVideoImportFinished') ) @Column - myVideoImportFinished: UserNotificationSettingValue + myVideoImportFinished: UserNotificationSettingValueType @AllowNull(false) @Default(null) @@ -101,7 +101,7 @@ export class UserNotificationSettingModel extends Model throwIfNotValid(value, isUserNotificationSettingValid, 'newUserRegistration') ) @Column - newUserRegistration: UserNotificationSettingValue + newUserRegistration: UserNotificationSettingValueType @AllowNull(false) @Default(null) @@ -110,7 +110,7 @@ export class UserNotificationSettingModel extends Model throwIfNotValid(value, isUserNotificationSettingValid, 'newInstanceFollower') ) @Column - newInstanceFollower: UserNotificationSettingValue + newInstanceFollower: UserNotificationSettingValueType @AllowNull(false) @Default(null) @@ -119,7 +119,7 @@ export class UserNotificationSettingModel extends Model throwIfNotValid(value, isUserNotificationSettingValid, 'autoInstanceFollowing') ) @Column - autoInstanceFollowing: UserNotificationSettingValue + autoInstanceFollowing: UserNotificationSettingValueType @AllowNull(false) @Default(null) @@ -128,7 +128,7 @@ export class UserNotificationSettingModel extends Model throwIfNotValid(value, isUserNotificationSettingValid, 'newFollow') ) @Column - newFollow: UserNotificationSettingValue + newFollow: UserNotificationSettingValueType @AllowNull(false) @Default(null) @@ -137,7 +137,7 @@ export class UserNotificationSettingModel extends Model throwIfNotValid(value, isUserNotificationSettingValid, 'commentMention') ) @Column - commentMention: UserNotificationSettingValue + commentMention: UserNotificationSettingValueType @AllowNull(false) @Default(null) @@ -146,7 +146,7 @@ export class UserNotificationSettingModel extends Model throwIfNotValid(value, isUserNotificationSettingValid, 'abuseStateChange') ) @Column - abuseStateChange: UserNotificationSettingValue + abuseStateChange: UserNotificationSettingValueType @AllowNull(false) @Default(null) @@ -155,7 +155,7 @@ export class UserNotificationSettingModel extends Model throwIfNotValid(value, isUserNotificationSettingValid, 'abuseNewMessage') ) @Column - abuseNewMessage: UserNotificationSettingValue + abuseNewMessage: UserNotificationSettingValueType @AllowNull(false) @Default(null) @@ -164,7 +164,7 @@ export class UserNotificationSettingModel extends Model throwIfNotValid(value, isUserNotificationSettingValid, 'newPeerTubeVersion') ) @Column - newPeerTubeVersion: UserNotificationSettingValue + newPeerTubeVersion: UserNotificationSettingValueType @AllowNull(false) @Default(null) @@ -173,7 +173,7 @@ export class UserNotificationSettingModel extends Model throwIfNotValid(value, isUserNotificationSettingValid, 'newPluginVersion') ) @Column - newPluginVersion: UserNotificationSettingValue + newPluginVersion: UserNotificationSettingValueType @AllowNull(false) @Default(null) @@ -182,7 +182,7 @@ export class UserNotificationSettingModel extends Model throwIfNotValid(value, isUserNotificationSettingValid, 'myVideoStudioEditionFinished') ) @Column - myVideoStudioEditionFinished: UserNotificationSettingValue + myVideoStudioEditionFinished: UserNotificationSettingValueType @ForeignKey(() => UserModel) @Column @@ -194,7 +194,7 @@ export class UserNotificationSettingModel extends Model @CreatedAt createdAt: Date diff --git a/server/models/user/user-notification.ts b/server/server/models/user/user-notification.ts similarity index 88% rename from server/models/user/user-notification.ts rename to server/server/models/user/user-notification.ts index 667ee7f5f..a96cb666c 100644 --- a/server/models/user/user-notification.ts +++ b/server/server/models/user/user-notification.ts @@ -1,26 +1,26 @@ +import { forceNumber } from '@peertube/peertube-core-utils' +import { UserNotification, type UserNotificationType_Type } from '@peertube/peertube-models' +import { uuidToShort } from '@peertube/peertube-node-utils' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { getBiggestActorImage } from '@server/lib/actor-image.js' +import { UserNotificationIncludes, UserNotificationModelForApi } from '@server/types/models/user/index.js' import { ModelIndexesOptions, Op, WhereOptions } from 'sequelize' import { AllowNull, BelongsTo, Column, CreatedAt, Default, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' -import { getBiggestActorImage } from '@server/lib/actor-image' -import { UserNotificationIncludes, UserNotificationModelForApi } from '@server/types/models/user' -import { forceNumber } from '@shared/core-utils' -import { uuidToShort } from '@shared/extra-utils' -import { UserNotification, UserNotificationType } from '@shared/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { isBooleanValid } from '../../helpers/custom-validators/misc' -import { isUserNotificationTypeValid } from '../../helpers/custom-validators/user-notifications' -import { AbuseModel } from '../abuse/abuse' -import { AccountModel } from '../account/account' -import { ActorFollowModel } from '../actor/actor-follow' -import { ApplicationModel } from '../application/application' -import { PluginModel } from '../server/plugin' -import { throwIfNotValid } from '../shared' -import { VideoModel } from '../video/video' -import { VideoBlacklistModel } from '../video/video-blacklist' -import { VideoCommentModel } from '../video/video-comment' -import { VideoImportModel } from '../video/video-import' -import { UserNotificationListQueryBuilder } from './sql/user-notitication-list-query-builder' -import { UserModel } from './user' -import { UserRegistrationModel } from './user-registration' +import { isBooleanValid } from '../../helpers/custom-validators/misc.js' +import { isUserNotificationTypeValid } from '../../helpers/custom-validators/user-notifications.js' +import { AbuseModel } from '../abuse/abuse.js' +import { AccountModel } from '../account/account.js' +import { ActorFollowModel } from '../actor/actor-follow.js' +import { ApplicationModel } from '../application/application.js' +import { PluginModel } from '../server/plugin.js' +import { throwIfNotValid } from '../shared/index.js' +import { VideoBlacklistModel } from '../video/video-blacklist.js' +import { VideoCommentModel } from '../video/video-comment.js' +import { VideoImportModel } from '../video/video-import.js' +import { VideoModel } from '../video/video.js' +import { UserNotificationListQueryBuilder } from './sql/user-notitication-list-query-builder.js' +import { UserRegistrationModel } from './user-registration.js' +import { UserModel } from './user.js' @Table({ tableName: 'userNotification', @@ -116,7 +116,7 @@ export class UserNotificationModel extends Model throwIfNotValid(value, isUserNotificationTypeValid, 'type')) @Column - type: UserNotificationType + type: UserNotificationType_Type @AllowNull(false) @Default(false) @@ -140,7 +140,7 @@ export class UserNotificationModel extends Model @ForeignKey(() => VideoModel) @Column @@ -152,7 +152,7 @@ export class UserNotificationModel extends Model @ForeignKey(() => VideoCommentModel) @Column @@ -164,7 +164,7 @@ export class UserNotificationModel extends Model @ForeignKey(() => AbuseModel) @Column @@ -176,7 +176,7 @@ export class UserNotificationModel extends Model @ForeignKey(() => VideoBlacklistModel) @Column @@ -188,7 +188,7 @@ export class UserNotificationModel extends Model @ForeignKey(() => VideoImportModel) @Column @@ -200,7 +200,7 @@ export class UserNotificationModel extends Model @ForeignKey(() => AccountModel) @Column @@ -212,7 +212,7 @@ export class UserNotificationModel extends Model @ForeignKey(() => ActorFollowModel) @Column @@ -224,7 +224,7 @@ export class UserNotificationModel extends Model @ForeignKey(() => PluginModel) @Column @@ -236,7 +236,7 @@ export class UserNotificationModel extends Model @ForeignKey(() => ApplicationModel) @Column @@ -248,7 +248,7 @@ export class UserNotificationModel extends Model @ForeignKey(() => UserRegistrationModel) @Column @@ -260,7 +260,7 @@ export class UserNotificationModel extends Model static listForApi (userId: number, start: number, count: number, sort: string, unread?: boolean) { const where = { userId } diff --git a/server/models/user/user-registration.ts b/server/server/models/user/user-registration.ts similarity index 90% rename from server/models/user/user-registration.ts rename to server/server/models/user/user-registration.ts index adda3cc7e..c4bf50b1d 100644 --- a/server/models/user/user-registration.ts +++ b/server/server/models/user/user-registration.ts @@ -1,3 +1,14 @@ +import { UserRegistration, type UserRegistrationStateType } from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { + isRegistrationModerationResponseValid, + isRegistrationReasonValid, + isRegistrationStateValid +} from '@server/helpers/custom-validators/user-registration.js' +import { isVideoChannelDisplayNameValid } from '@server/helpers/custom-validators/video-channels.js' +import { cryptPassword } from '@server/helpers/peertube-crypto.js' +import { USER_REGISTRATION_STATES } from '@server/initializers/constants.js' +import { MRegistration, MRegistrationFormattable } from '@server/types/models/index.js' import { FindOptions, Op, WhereOptions } from 'sequelize' import { AllowNull, @@ -13,20 +24,9 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { - isRegistrationModerationResponseValid, - isRegistrationReasonValid, - isRegistrationStateValid -} from '@server/helpers/custom-validators/user-registration' -import { isVideoChannelDisplayNameValid } from '@server/helpers/custom-validators/video-channels' -import { cryptPassword } from '@server/helpers/peertube-crypto' -import { USER_REGISTRATION_STATES } from '@server/initializers/constants' -import { MRegistration, MRegistrationFormattable } from '@server/types/models' -import { UserRegistration, UserRegistrationState } from '@shared/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { isUserDisplayNameValid, isUserEmailVerifiedValid, isUserPasswordValid } from '../../helpers/custom-validators/users' -import { getSort, throwIfNotValid } from '../shared' -import { UserModel } from './user' +import { isUserDisplayNameValid, isUserEmailVerifiedValid, isUserPasswordValid } from '../../helpers/custom-validators/users.js' +import { getSort, throwIfNotValid } from '../shared/index.js' +import { UserModel } from './user.js' @Table({ tableName: 'userRegistration', @@ -54,7 +54,7 @@ export class UserRegistrationModel extends Model throwIfNotValid(value, isRegistrationStateValid, 'state')) @Column - state: UserRegistrationState + state: UserRegistrationStateType @AllowNull(false) @Is('RegistrationReason', value => throwIfNotValid(value, isRegistrationReasonValid, 'registration reason')) @@ -116,7 +116,7 @@ export class UserRegistrationModel extends Model @BeforeCreate static async cryptPasswordIfNeeded (instance: UserRegistrationModel) { diff --git a/server/models/user/user-video-history.ts b/server/server/models/user/user-video-history.ts similarity index 81% rename from server/models/user/user-video-history.ts rename to server/server/models/user/user-video-history.ts index f4d0889a1..4764f58eb 100644 --- a/server/models/user/user-video-history.ts +++ b/server/server/models/user/user-video-history.ts @@ -1,9 +1,10 @@ import { DestroyOptions, Op, Transaction } from 'sequelize' import { AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, IsInt, Model, Table, UpdatedAt } from 'sequelize-typescript' -import { MUserAccountId, MUserId } from '@server/types/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { VideoModel } from '../video/video' -import { UserModel } from './user' +import { ResultList } from '@peertube/peertube-models' +import { MUserAccountId, MUserId } from '@server/types/models/index.js' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { VideoModel } from '../video/video.js' +import { UserModel } from './user.js' @Table({ tableName: 'userVideoHistory', @@ -42,7 +43,7 @@ export class UserVideoHistoryModel extends Model @ForeignKey(() => UserModel) @Column @@ -54,9 +55,10 @@ export class UserVideoHistoryModel extends Model - static listForApi (user: MUserAccountId, start: number, count: number, search?: string) { + // FIXME: have to specify the result type to not break peertube typings generation + static listForApi (user: MUserAccountId, start: number, count: number, search?: string): Promise> { return VideoModel.listForApi({ start, count, diff --git a/server/models/user/user.ts b/server/server/models/user/user.ts similarity index 93% rename from server/models/user/user.ts rename to server/server/models/user/user.ts index ff6328d48..3c4495e3e 100644 --- a/server/models/user/user.ts +++ b/server/server/models/user/user.ts @@ -1,3 +1,26 @@ +import { forceNumber, hasUserRight, USER_ROLE_LABELS } from '@peertube/peertube-core-utils' +import { + AbuseState, + MyUser, + User, + UserAdminFlag, + UserRightType, + VideoPlaylistType, + type NSFWPolicyType, + type UserAdminFlagType, + type UserRoleType +} from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { TokensCache } from '@server/lib/auth/tokens-cache.js' +import { LiveQuotaStore } from '@server/lib/live/index.js' +import { + MMyUserFormattable, + MUser, + MUserDefault, + MUserFormattable, + MUserNotifSettingChannelDefault, + MUserWithNotificationSetting +} from '@server/types/models/index.js' import { col, FindOptions, fn, literal, Op, QueryTypes, where, WhereOptions } from 'sequelize' import { AfterDestroy, @@ -20,24 +43,7 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { TokensCache } from '@server/lib/auth/tokens-cache' -import { LiveQuotaStore } from '@server/lib/live' -import { - MMyUserFormattable, - MUser, - MUserDefault, - MUserFormattable, - MUserNotifSettingChannelDefault, - MUserWithNotificationSetting -} from '@server/types/models' -import { forceNumber } from '@shared/core-utils' -import { AttributesOnly } from '@shared/typescript-utils' -import { hasUserRight, USER_ROLE_LABELS } from '../../../shared/core-utils/users' -import { AbuseState, MyUser, UserRight, VideoPlaylistType } from '../../../shared/models' -import { User, UserRole } from '../../../shared/models/users' -import { UserAdminFlag } from '../../../shared/models/users/user-flag.model' -import { NSFWPolicyType } from '../../../shared/models/videos/nsfw-policy.type' -import { isThemeNameValid } from '../../helpers/custom-validators/plugins' +import { isThemeNameValid } from '../../helpers/custom-validators/plugins.js' import { isUserAdminFlagsValid, isUserAutoPlayNextVideoPlaylistValid, @@ -55,22 +61,22 @@ import { isUserVideoQuotaDailyValid, isUserVideoQuotaValid, isUserVideosHistoryEnabledValid -} from '../../helpers/custom-validators/users' -import { comparePassword, cryptPassword } from '../../helpers/peertube-crypto' -import { DEFAULT_USER_THEME_NAME, NSFW_POLICY_TYPES } from '../../initializers/constants' -import { getThemeOrDefault } from '../../lib/plugins/theme-utils' -import { AccountModel } from '../account/account' -import { ActorModel } from '../actor/actor' -import { ActorFollowModel } from '../actor/actor-follow' -import { ActorImageModel } from '../actor/actor-image' -import { OAuthTokenModel } from '../oauth/oauth-token' -import { getAdminUsersSort, throwIfNotValid } from '../shared' -import { VideoModel } from '../video/video' -import { VideoChannelModel } from '../video/video-channel' -import { VideoImportModel } from '../video/video-import' -import { VideoLiveModel } from '../video/video-live' -import { VideoPlaylistModel } from '../video/video-playlist' -import { UserNotificationSettingModel } from './user-notification-setting' +} from '../../helpers/custom-validators/users.js' +import { comparePassword, cryptPassword } from '../../helpers/peertube-crypto.js' +import { DEFAULT_USER_THEME_NAME, NSFW_POLICY_TYPES } from '../../initializers/constants.js' +import { getThemeOrDefault } from '../../lib/plugins/theme-utils.js' +import { AccountModel } from '../account/account.js' +import { ActorFollowModel } from '../actor/actor-follow.js' +import { ActorImageModel } from '../actor/actor-image.js' +import { ActorModel } from '../actor/actor.js' +import { OAuthTokenModel } from '../oauth/oauth-token.js' +import { getAdminUsersSort, throwIfNotValid } from '../shared/index.js' +import { VideoChannelModel } from '../video/video-channel.js' +import { VideoImportModel } from '../video/video-import.js' +import { VideoLiveModel } from '../video/video-live.js' +import { VideoPlaylistModel } from '../video/video-playlist.js' +import { VideoModel } from '../video/video.js' +import { UserNotificationSettingModel } from './user-notification-setting.js' enum ScopeNames { FOR_ME_API = 'FOR_ME_API', @@ -326,7 +332,7 @@ export class UserModel extends Model>> { @Default(UserAdminFlag.NONE) @Is('UserAdminFlags', value => throwIfNotValid(value, isUserAdminFlagsValid, 'user admin flags')) @Column - adminFlags?: UserAdminFlag + adminFlags?: UserAdminFlagType @AllowNull(false) @Default(false) @@ -343,7 +349,7 @@ export class UserModel extends Model>> { @AllowNull(false) @Is('UserRole', value => throwIfNotValid(value, isUserRoleValid, 'role')) @Column - role: number + role: UserRoleType @AllowNull(false) @Is('UserVideoQuota', value => throwIfNotValid(value, isUserVideoQuotaValid, 'video quota')) @@ -425,26 +431,26 @@ export class UserModel extends Model>> { onDelete: 'cascade', hooks: true }) - Account: AccountModel + Account: Awaited @HasOne(() => UserNotificationSettingModel, { foreignKey: 'userId', onDelete: 'cascade', hooks: true }) - NotificationSetting: UserNotificationSettingModel + NotificationSetting: Awaited @HasMany(() => VideoImportModel, { foreignKey: 'userId', onDelete: 'cascade' }) - VideoImports: VideoImportModel[] + VideoImports: Awaited[] @HasMany(() => OAuthTokenModel, { foreignKey: 'userId', onDelete: 'cascade' }) - OAuthTokens: OAuthTokenModel[] + OAuthTokens: Awaited[] // Used if we already set an encrypted password in user model skipPasswordEncryption = false @@ -513,9 +519,9 @@ export class UserModel extends Model>> { ]).then(([ total, data ]) => ({ total, data })) } - static listWithRight (right: UserRight): Promise { + static listWithRight (right: UserRightType): Promise { const roles = Object.keys(USER_ROLE_LABELS) - .map(k => parseInt(k, 10) as UserRole) + .map(k => parseInt(k, 10) as UserRoleType) .filter(role => hasUserRight(role, right)) const query = { @@ -858,11 +864,11 @@ export class UserModel extends Model>> { .then(u => u.map(u => u.username)) } - hasRight (right: UserRight) { + hasRight (right: UserRightType) { return hasUserRight(this.role, right) } - hasAdminFlag (flag: UserAdminFlag) { + hasAdminFlag (flag: UserAdminFlagType) { return this.adminFlags & flag } diff --git a/server/server/models/video/formatter/index.ts b/server/server/models/video/formatter/index.ts new file mode 100644 index 000000000..856595ad5 --- /dev/null +++ b/server/server/models/video/formatter/index.ts @@ -0,0 +1,2 @@ +export * from './video-activity-pub-format.js' +export * from './video-api-format.js' diff --git a/server/server/models/video/formatter/shared/index.ts b/server/server/models/video/formatter/shared/index.ts new file mode 100644 index 000000000..66fe5ff5b --- /dev/null +++ b/server/server/models/video/formatter/shared/index.ts @@ -0,0 +1 @@ +export * from './video-format-utils.js' diff --git a/server/models/video/formatter/shared/video-format-utils.ts b/server/server/models/video/formatter/shared/video-format-utils.ts similarity index 77% rename from server/models/video/formatter/shared/video-format-utils.ts rename to server/server/models/video/formatter/shared/video-format-utils.ts index df3bbdf1c..8a8d9f4b2 100644 --- a/server/models/video/formatter/shared/video-format-utils.ts +++ b/server/server/models/video/formatter/shared/video-format-utils.ts @@ -1,4 +1,4 @@ -import { MVideoFile } from '@server/types/models' +import { MVideoFile } from '@server/types/models/index.js' export function sortByResolutionDesc (fileA: MVideoFile, fileB: MVideoFile) { if (fileA.resolution < fileB.resolution) return 1 diff --git a/server/models/video/formatter/video-activity-pub-format.ts b/server/server/models/video/formatter/video-activity-pub-format.ts similarity index 94% rename from server/models/video/formatter/video-activity-pub-format.ts rename to server/server/models/video/formatter/video-activity-pub-format.ts index 694c66c33..759e6dbbc 100644 --- a/server/models/video/formatter/video-activity-pub-format.ts +++ b/server/server/models/video/formatter/video-activity-pub-format.ts @@ -1,7 +1,7 @@ -import { isArray } from '@server/helpers/custom-validators/misc' -import { generateMagnetUri } from '@server/helpers/webtorrent' -import { getActivityStreamDuration } from '@server/lib/activitypub/activity' -import { getLocalVideoFileMetadataUrl } from '@server/lib/video-urls' +import { isArray } from '@server/helpers/custom-validators/misc.js' +import { generateMagnetUri } from '@server/helpers/webtorrent.js' +import { getActivityStreamDuration } from '@server/lib/activitypub/activity.js' +import { getLocalVideoFileMetadataUrl } from '@server/lib/video-urls.js' import { ActivityIconObject, ActivityPlaylistUrlObject, @@ -10,18 +10,18 @@ import { ActivityTrackerUrlObject, ActivityUrlObject, VideoObject -} from '@shared/models' -import { MIMETYPES, WEBSERVER } from '../../../initializers/constants' +} from '@peertube/peertube-models' +import { MIMETYPES, WEBSERVER } from '../../../initializers/constants.js' import { getLocalVideoCommentsActivityPubUrl, getLocalVideoDislikesActivityPubUrl, getLocalVideoLikesActivityPubUrl, getLocalVideoSharesActivityPubUrl -} from '../../../lib/activitypub/url' -import { MStreamingPlaylistFiles, MUserId, MVideo, MVideoAP, MVideoFile } from '../../../types/models' -import { VideoCaptionModel } from '../video-caption' -import { sortByResolutionDesc } from './shared' -import { getCategoryLabel, getLanguageLabel, getLicenceLabel } from './video-api-format' +} from '../../../lib/activitypub/url.js' +import { MStreamingPlaylistFiles, MUserId, MVideo, MVideoAP, MVideoFile } from '../../../types/models/index.js' +import { VideoCaptionModel } from '../video-caption.js' +import { sortByResolutionDesc } from './shared/index.js' +import { getCategoryLabel, getLanguageLabel, getLicenceLabel } from './video-api-format.js' export function videoModelToActivityPubObject (video: MVideoAP): VideoObject { const language = video.language diff --git a/server/models/video/formatter/video-api-format.ts b/server/server/models/video/formatter/video-api-format.ts similarity index 95% rename from server/models/video/formatter/video-api-format.ts rename to server/server/models/video/formatter/video-api-format.ts index 7a58f5d3c..958832485 100644 --- a/server/models/video/formatter/video-api-format.ts +++ b/server/server/models/video/formatter/video-api-format.ts @@ -1,8 +1,8 @@ -import { generateMagnetUri } from '@server/helpers/webtorrent' -import { tracer } from '@server/lib/opentelemetry/tracing' -import { getLocalVideoFileMetadataUrl } from '@server/lib/video-urls' -import { VideoViewsManager } from '@server/lib/views/video-views-manager' -import { uuidToShort } from '@shared/extra-utils' +import { generateMagnetUri } from '@server/helpers/webtorrent.js' +import { tracer } from '@server/lib/opentelemetry/tracing.js' +import { getLocalVideoFileMetadataUrl } from '@server/lib/video-urls.js' +import { VideoViewsManager } from '@server/lib/views/video-views-manager.js' +import { uuidToShort } from '@peertube/peertube-node-utils' import { Video, VideoAdditionalAttributes, @@ -11,12 +11,12 @@ import { VideoInclude, VideosCommonQueryAfterSanitize, VideoStreamingPlaylist -} from '@shared/models' -import { isArray } from '../../../helpers/custom-validators/misc' -import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES, VIDEO_STATES } from '../../../initializers/constants' -import { MServer, MStreamingPlaylistRedundanciesOpt, MVideoFormattable, MVideoFormattableDetails } from '../../../types/models' -import { MVideoFileRedundanciesOpt } from '../../../types/models/video/video-file' -import { sortByResolutionDesc } from './shared' +} from '@peertube/peertube-models' +import { isArray } from '../../../helpers/custom-validators/misc.js' +import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES, VIDEO_STATES } from '../../../initializers/constants.js' +import { MServer, MStreamingPlaylistRedundanciesOpt, MVideoFormattable, MVideoFormattableDetails } from '../../../types/models/index.js' +import { MVideoFileRedundanciesOpt } from '../../../types/models/video/video-file.js' +import { sortByResolutionDesc } from './shared/index.js' export type VideoFormattingJSONOptions = { completeDescription?: boolean diff --git a/server/models/video/schedule-video-update.ts b/server/server/models/video/schedule-video-update.ts similarity index 73% rename from server/models/video/schedule-video-update.ts rename to server/server/models/video/schedule-video-update.ts index b3cf26966..229610d87 100644 --- a/server/models/video/schedule-video-update.ts +++ b/server/server/models/video/schedule-video-update.ts @@ -1,9 +1,9 @@ import { Op, Transaction } from 'sequelize' -import { AllowNull, BelongsTo, Column, CreatedAt, Default, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript' -import { MScheduleVideoUpdateFormattable, MScheduleVideoUpdate } from '@server/types/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { VideoPrivacy } from '../../../shared/models/videos' -import { VideoModel } from './video' +import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript' +import { VideoPrivacy } from '@peertube/peertube-models' +import { MScheduleVideoUpdate, MScheduleVideoUpdateFormattable } from '@server/types/models/index.js' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { VideoModel } from './video.js' @Table({ tableName: 'scheduleVideoUpdate', @@ -26,8 +26,8 @@ export class ScheduleVideoUpdateModel extends Model static areVideosToUpdate () { const query = { diff --git a/server/models/video/sql/comment/video-comment-list-query-builder.ts b/server/server/models/video/sql/comment/video-comment-list-query-builder.ts similarity index 98% rename from server/models/video/sql/comment/video-comment-list-query-builder.ts rename to server/server/models/video/sql/comment/video-comment-list-query-builder.ts index a7eed22a1..0a9388fda 100644 --- a/server/models/video/sql/comment/video-comment-list-query-builder.ts +++ b/server/server/models/video/sql/comment/video-comment-list-query-builder.ts @@ -1,8 +1,8 @@ import { Model, Sequelize, Transaction } from 'sequelize' -import { AbstractRunQuery, ModelBuilder } from '@server/models/shared' -import { ActorImageType, VideoPrivacy } from '@shared/models' -import { createSafeIn, getSort, parseRowCountResult } from '../../../shared' -import { VideoCommentTableAttributes } from './video-comment-table-attributes' +import { AbstractRunQuery, ModelBuilder } from '@server/models/shared/index.js' +import { ActorImageType, VideoPrivacy } from '@peertube/peertube-models' +import { createSafeIn, getSort, parseRowCountResult } from '../../../shared/index.js' +import { VideoCommentTableAttributes } from './video-comment-table-attributes.js' export interface ListVideoCommentsOptions { selectType: 'api' | 'feed' | 'comment-only' diff --git a/server/models/video/sql/comment/video-comment-table-attributes.ts b/server/server/models/video/sql/comment/video-comment-table-attributes.ts similarity index 76% rename from server/models/video/sql/comment/video-comment-table-attributes.ts rename to server/server/models/video/sql/comment/video-comment-table-attributes.ts index 87f8750c1..c7a8a9768 100644 --- a/server/models/video/sql/comment/video-comment-table-attributes.ts +++ b/server/server/models/video/sql/comment/video-comment-table-attributes.ts @@ -1,9 +1,9 @@ -import { Memoize } from '@server/helpers/memoize' -import { AccountModel } from '@server/models/account/account' -import { ActorModel } from '@server/models/actor/actor' -import { ActorImageModel } from '@server/models/actor/actor-image' -import { ServerModel } from '@server/models/server/server' -import { VideoCommentModel } from '../../video-comment' +import { Memoize } from '@server/helpers/memoize.js' +import { AccountModel } from '@server/models/account/account.js' +import { ActorModel } from '@server/models/actor/actor.js' +import { ActorImageModel } from '@server/models/actor/actor-image.js' +import { ServerModel } from '@server/models/server/server.js' +import { VideoCommentModel } from '../../video-comment.js' export class VideoCommentTableAttributes { diff --git a/server/server/models/video/sql/video/index.ts b/server/server/models/video/sql/video/index.ts new file mode 100644 index 000000000..003f59861 --- /dev/null +++ b/server/server/models/video/sql/video/index.ts @@ -0,0 +1,3 @@ +export * from './video-model-get-query-builder.js' +export * from './videos-id-list-query-builder.js' +export * from './videos-model-list-query-builder.js' diff --git a/server/models/video/sql/video/shared/abstract-video-query-builder.ts b/server/server/models/video/sql/video/shared/abstract-video-query-builder.ts similarity index 97% rename from server/models/video/sql/video/shared/abstract-video-query-builder.ts rename to server/server/models/video/sql/video/shared/abstract-video-query-builder.ts index 56a00aa0c..1175c75eb 100644 --- a/server/models/video/sql/video/shared/abstract-video-query-builder.ts +++ b/server/server/models/video/sql/video/shared/abstract-video-query-builder.ts @@ -1,10 +1,10 @@ import { Sequelize } from 'sequelize' import validator from 'validator' -import { MUserAccountId } from '@server/types/models' -import { ActorImageType } from '@shared/models' -import { AbstractRunQuery } from '../../../../shared/abstract-run-query' -import { createSafeIn } from '../../../../shared' -import { VideoTableAttributes } from './video-table-attributes' +import { MUserAccountId } from '@server/types/models/index.js' +import { ActorImageType } from '@peertube/peertube-models' +import { AbstractRunQuery } from '../../../../shared/abstract-run-query.js' +import { createSafeIn } from '../../../../shared/index.js' +import { VideoTableAttributes } from './video-table-attributes.js' /** * @@ -325,7 +325,7 @@ export class AbstractVideoQueryBuilder extends AbstractRunQuery { return } - if (validator.isInt('' + options.id)) { + if (validator.default.isInt('' + options.id)) { this.where = 'WHERE "video".id = :videoId' } else { this.where = 'WHERE uuid = :videoId' diff --git a/server/models/video/sql/video/shared/video-file-query-builder.ts b/server/server/models/video/sql/video/shared/video-file-query-builder.ts similarity index 99% rename from server/models/video/sql/video/shared/video-file-query-builder.ts rename to server/server/models/video/sql/video/shared/video-file-query-builder.ts index 196b72b43..b7d3e06d9 100644 --- a/server/models/video/sql/video/shared/video-file-query-builder.ts +++ b/server/server/models/video/sql/video/shared/video-file-query-builder.ts @@ -1,5 +1,5 @@ import { Sequelize, Transaction } from 'sequelize' -import { AbstractVideoQueryBuilder } from './abstract-video-query-builder' +import { AbstractVideoQueryBuilder } from './abstract-video-query-builder.js' export type FileQueryOptions = { id?: string | number diff --git a/server/models/video/sql/video/shared/video-model-builder.ts b/server/server/models/video/sql/video/shared/video-model-builder.ts similarity index 93% rename from server/models/video/sql/video/shared/video-model-builder.ts rename to server/server/models/video/sql/video/shared/video-model-builder.ts index 740aa842f..d5746b41a 100644 --- a/server/models/video/sql/video/shared/video-model-builder.ts +++ b/server/server/models/video/sql/video/shared/video-model-builder.ts @@ -1,24 +1,23 @@ - -import { AccountModel } from '@server/models/account/account' -import { AccountBlocklistModel } from '@server/models/account/account-blocklist' -import { ActorModel } from '@server/models/actor/actor' -import { ActorImageModel } from '@server/models/actor/actor-image' -import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy' -import { ServerModel } from '@server/models/server/server' -import { ServerBlocklistModel } from '@server/models/server/server-blocklist' -import { TrackerModel } from '@server/models/server/tracker' -import { UserVideoHistoryModel } from '@server/models/user/user-video-history' -import { VideoInclude } from '@shared/models' -import { ScheduleVideoUpdateModel } from '../../../schedule-video-update' -import { TagModel } from '../../../tag' -import { ThumbnailModel } from '../../../thumbnail' -import { VideoModel } from '../../../video' -import { VideoBlacklistModel } from '../../../video-blacklist' -import { VideoChannelModel } from '../../../video-channel' -import { VideoFileModel } from '../../../video-file' -import { VideoLiveModel } from '../../../video-live' -import { VideoStreamingPlaylistModel } from '../../../video-streaming-playlist' -import { VideoTableAttributes } from './video-table-attributes' +import { VideoInclude, VideoIncludeType } from '@peertube/peertube-models' +import { AccountBlocklistModel } from '@server/models/account/account-blocklist.js' +import { AccountModel } from '@server/models/account/account.js' +import { ActorImageModel } from '@server/models/actor/actor-image.js' +import { ActorModel } from '@server/models/actor/actor.js' +import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy.js' +import { ServerBlocklistModel } from '@server/models/server/server-blocklist.js' +import { ServerModel } from '@server/models/server/server.js' +import { TrackerModel } from '@server/models/server/tracker.js' +import { UserVideoHistoryModel } from '@server/models/user/user-video-history.js' +import { ScheduleVideoUpdateModel } from '../../../schedule-video-update.js' +import { TagModel } from '../../../tag.js' +import { ThumbnailModel } from '../../../thumbnail.js' +import { VideoBlacklistModel } from '../../../video-blacklist.js' +import { VideoChannelModel } from '../../../video-channel.js' +import { VideoFileModel } from '../../../video-file.js' +import { VideoLiveModel } from '../../../video-live.js' +import { VideoStreamingPlaylistModel } from '../../../video-streaming-playlist.js' +import { VideoModel } from '../../../video.js' +import { VideoTableAttributes } from './video-table-attributes.js' type SQLRow = { [id: string]: string | number } @@ -59,7 +58,7 @@ export class VideoModelBuilder { buildVideosFromRows (options: { rows: SQLRow[] - include?: VideoInclude + include?: VideoIncludeType rowsWebVideoFiles?: SQLRow[] rowsStreamingPlaylist?: SQLRow[] }) { diff --git a/server/models/video/sql/video/shared/video-table-attributes.ts b/server/server/models/video/sql/video/shared/video-table-attributes.ts similarity index 100% rename from server/models/video/sql/video/shared/video-table-attributes.ts rename to server/server/models/video/sql/video/shared/video-table-attributes.ts diff --git a/server/models/video/sql/video/video-model-get-query-builder.ts b/server/server/models/video/sql/video/video-model-get-query-builder.ts similarity index 97% rename from server/models/video/sql/video/video-model-get-query-builder.ts rename to server/server/models/video/sql/video/video-model-get-query-builder.ts index 3f43d4d92..1d55e3e93 100644 --- a/server/models/video/sql/video/video-model-get-query-builder.ts +++ b/server/server/models/video/sql/video/video-model-get-query-builder.ts @@ -1,9 +1,9 @@ import { Sequelize, Transaction } from 'sequelize' -import { pick } from '@shared/core-utils' -import { AbstractVideoQueryBuilder } from './shared/abstract-video-query-builder' -import { VideoFileQueryBuilder } from './shared/video-file-query-builder' -import { VideoModelBuilder } from './shared/video-model-builder' -import { VideoTableAttributes } from './shared/video-table-attributes' +import { pick } from '@peertube/peertube-core-utils' +import { AbstractVideoQueryBuilder } from './shared/abstract-video-query-builder.js' +import { VideoFileQueryBuilder } from './shared/video-file-query-builder.js' +import { VideoModelBuilder } from './shared/video-model-builder.js' +import { VideoTableAttributes } from './shared/video-table-attributes.js' /** * diff --git a/server/models/video/sql/video/videos-id-list-query-builder.ts b/server/server/models/video/sql/video/videos-id-list-query-builder.ts similarity index 97% rename from server/models/video/sql/video/videos-id-list-query-builder.ts rename to server/server/models/video/sql/video/videos-id-list-query-builder.ts index 7f2376102..090eaddbc 100644 --- a/server/models/video/sql/video/videos-id-list-query-builder.ts +++ b/server/server/models/video/sql/video/videos-id-list-query-builder.ts @@ -1,13 +1,13 @@ import { Sequelize, Transaction } from 'sequelize' import validator from 'validator' -import { exists } from '@server/helpers/custom-validators/misc' -import { WEBSERVER } from '@server/initializers/constants' -import { buildSortDirectionAndField } from '@server/models/shared' -import { MUserAccountId, MUserId } from '@server/types/models' -import { forceNumber } from '@shared/core-utils' -import { VideoInclude, VideoPrivacy, VideoState } from '@shared/models' -import { createSafeIn, parseRowCountResult } from '../../../shared' -import { AbstractRunQuery } from '../../../shared/abstract-run-query' +import { forceNumber } from '@peertube/peertube-core-utils' +import { VideoInclude, VideoIncludeType, VideoPrivacy, VideoPrivacyType, VideoState } from '@peertube/peertube-models' +import { exists } from '@server/helpers/custom-validators/misc.js' +import { WEBSERVER } from '@server/initializers/constants.js' +import { buildSortDirectionAndField } from '@server/models/shared/index.js' +import { MUserAccountId, MUserId } from '@server/types/models/index.js' +import { AbstractRunQuery } from '../../../shared/abstract-run-query.js' +import { createSafeIn, parseRowCountResult } from '../../../shared/index.js' /** * @@ -35,14 +35,14 @@ export type BuildVideosListQueryOptions = { host?: string isLive?: boolean isLocal?: boolean - include?: VideoInclude + include?: VideoIncludeType categoryOneOf?: number[] licenceOneOf?: number[] languageOneOf?: string[] tagsOneOf?: string[] tagsAllOf?: string[] - privacyOneOf?: VideoPrivacy[] + privacyOneOf?: VideoPrivacyType[] uuids?: string[] @@ -458,7 +458,7 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery { ) } - private wherePrivacyOneOf (privacyOneOf: VideoPrivacy[]) { + private wherePrivacyOneOf (privacyOneOf: VideoPrivacyType[]) { this.and.push('"video"."privacy" IN (:privacyOneOf)') this.replacements.privacyOneOf = privacyOneOf } @@ -568,7 +568,7 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery { ' AND "video"."id" = "videoTag"."videoId"' + ' )' - if (validator.isUUID(search)) { + if (validator.default.isUUID(search)) { base += ` OR "video"."uuid" = ${escapedSearch}` } diff --git a/server/models/video/sql/video/videos-model-list-query-builder.ts b/server/server/models/video/sql/video/videos-model-list-query-builder.ts similarity index 92% rename from server/models/video/sql/video/videos-model-list-query-builder.ts rename to server/server/models/video/sql/video/videos-model-list-query-builder.ts index b73dc28cd..9eb26085d 100644 --- a/server/models/video/sql/video/videos-model-list-query-builder.ts +++ b/server/server/models/video/sql/video/videos-model-list-query-builder.ts @@ -1,10 +1,10 @@ import { Sequelize } from 'sequelize' -import { pick } from '@shared/core-utils' -import { VideoInclude } from '@shared/models' -import { AbstractVideoQueryBuilder } from './shared/abstract-video-query-builder' -import { VideoFileQueryBuilder } from './shared/video-file-query-builder' -import { VideoModelBuilder } from './shared/video-model-builder' -import { BuildVideosListQueryOptions, VideosIdListQueryBuilder } from './videos-id-list-query-builder' +import { pick } from '@peertube/peertube-core-utils' +import { VideoInclude } from '@peertube/peertube-models' +import { AbstractVideoQueryBuilder } from './shared/abstract-video-query-builder.js' +import { VideoFileQueryBuilder } from './shared/video-file-query-builder.js' +import { VideoModelBuilder } from './shared/video-model-builder.js' +import { BuildVideosListQueryOptions, VideosIdListQueryBuilder } from './videos-id-list-query-builder.js' /** * diff --git a/server/models/video/storyboard.ts b/server/server/models/video/storyboard.ts similarity index 89% rename from server/models/video/storyboard.ts rename to server/server/models/video/storyboard.ts index 1c3c6d850..1d0a8e429 100644 --- a/server/models/video/storyboard.ts +++ b/server/server/models/video/storyboard.ts @@ -1,13 +1,13 @@ -import { remove } from 'fs-extra' +import { remove } from 'fs-extra/esm' import { join } from 'path' import { AfterDestroy, AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript' -import { CONFIG } from '@server/initializers/config' -import { MStoryboard, MStoryboardVideo, MVideo } from '@server/types/models' -import { Storyboard } from '@shared/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { logger } from '../../helpers/logger' -import { CONSTRAINTS_FIELDS, LAZY_STATIC_PATHS, WEBSERVER } from '../../initializers/constants' -import { VideoModel } from './video' +import { CONFIG } from '@server/initializers/config.js' +import { MStoryboard, MStoryboardVideo, MVideo } from '@server/types/models/index.js' +import { Storyboard } from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { logger } from '../../helpers/logger.js' +import { CONSTRAINTS_FIELDS, LAZY_STATIC_PATHS, WEBSERVER } from '../../initializers/constants.js' +import { VideoModel } from './video.js' import { Transaction } from 'sequelize' @Table({ @@ -63,7 +63,7 @@ export class StoryboardModel extends Model @CreatedAt createdAt: Date diff --git a/server/models/video/tag.ts b/server/server/models/video/tag.ts similarity index 85% rename from server/models/video/tag.ts rename to server/server/models/video/tag.ts index cebde3755..dee954795 100644 --- a/server/models/video/tag.ts +++ b/server/server/models/video/tag.ts @@ -1,12 +1,12 @@ import { col, fn, QueryTypes, Transaction } from 'sequelize' import { AllowNull, BelongsToMany, Column, CreatedAt, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' -import { MTag } from '@server/types/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { VideoPrivacy, VideoState } from '../../../shared/models/videos' -import { isVideoTagValid } from '../../helpers/custom-validators/videos' -import { throwIfNotValid } from '../shared' -import { VideoModel } from './video' -import { VideoTagModel } from './video-tag' +import { VideoPrivacy, VideoState } from '@peertube/peertube-models' +import { MTag } from '@server/types/models/index.js' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { isVideoTagValid } from '../../helpers/custom-validators/videos.js' +import { throwIfNotValid } from '../shared/index.js' +import { VideoTagModel } from './video-tag.js' +import { VideoModel } from './video.js' @Table({ tableName: 'tag', @@ -40,7 +40,7 @@ export class TagModel extends Model>> { through: () => VideoTagModel, onDelete: 'CASCADE' }) - Videos: VideoModel[] + Videos: Awaited[] static findOrCreateTags (tags: string[], transaction: Transaction): Promise { if (tags === null) return Promise.resolve([]) diff --git a/server/models/video/thumbnail.ts b/server/server/models/video/thumbnail.ts similarity index 83% rename from server/models/video/thumbnail.ts rename to server/server/models/video/thumbnail.ts index 1722acdb4..4791b8b75 100644 --- a/server/models/video/thumbnail.ts +++ b/server/server/models/video/thumbnail.ts @@ -1,4 +1,8 @@ -import { remove } from 'fs-extra' +import { ThumbnailType, type ThumbnailType_Type } from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { afterCommitIfTransaction } from '@server/helpers/database-utils.js' +import { MThumbnail, MThumbnailVideo, MVideo } from '@server/types/models/index.js' +import { remove } from 'fs-extra/esm' import { join } from 'path' import { AfterDestroy, @@ -15,15 +19,11 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { afterCommitIfTransaction } from '@server/helpers/database-utils' -import { MThumbnail, MThumbnailVideo, MVideo } from '@server/types/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { ThumbnailType } from '../../../shared/models/videos/thumbnail.type' -import { logger } from '../../helpers/logger' -import { CONFIG } from '../../initializers/config' -import { CONSTRAINTS_FIELDS, LAZY_STATIC_PATHS, WEBSERVER } from '../../initializers/constants' -import { VideoModel } from './video' -import { VideoPlaylistModel } from './video-playlist' +import { logger } from '../../helpers/logger.js' +import { CONFIG } from '../../initializers/config.js' +import { CONSTRAINTS_FIELDS, LAZY_STATIC_PATHS, WEBSERVER } from '../../initializers/constants.js' +import { VideoPlaylistModel } from './video-playlist.js' +import { VideoModel } from './video.js' @Table({ tableName: 'thumbnail', @@ -59,7 +59,7 @@ export class ThumbnailModel extends Model @AllowNull(false) @Column - type: ThumbnailType + type: ThumbnailType_Type @AllowNull(true) @Column(DataType.STRING(CONSTRAINTS_FIELDS.COMMONS.URL.max)) @@ -83,7 +83,7 @@ export class ThumbnailModel extends Model }, onDelete: 'CASCADE' }) - Video: VideoModel + Video: Awaited @ForeignKey(() => VideoPlaylistModel) @Column @@ -95,7 +95,7 @@ export class ThumbnailModel extends Model }, onDelete: 'CASCADE' }) - VideoPlaylist: VideoPlaylistModel + VideoPlaylist: Awaited @CreatedAt createdAt: Date @@ -106,7 +106,7 @@ export class ThumbnailModel extends Model // If this thumbnail replaced existing one, track the old name previousThumbnailFilename: string - private static readonly types: { [ id in ThumbnailType ]: { label: string, directory: string, staticPath: string } } = { + private static readonly types: { [ id in ThumbnailType_Type ]: { label: string, directory: string, staticPath: string } } = { [ThumbnailType.MINIATURE]: { label: 'miniature', directory: CONFIG.STORAGE.THUMBNAILS_DIR, @@ -134,7 +134,7 @@ export class ThumbnailModel extends Model .catch(err => logger.error('Cannot remove thumbnail file %s.', instance.filename, { err })) } - static loadByFilename (filename: string, thumbnailType: ThumbnailType): Promise { + static loadByFilename (filename: string, thumbnailType: ThumbnailType_Type): Promise { const query = { where: { filename, @@ -145,7 +145,7 @@ export class ThumbnailModel extends Model return ThumbnailModel.findOne(query) } - static loadWithVideoByFilename (filename: string, thumbnailType: ThumbnailType): Promise { + static loadWithVideoByFilename (filename: string, thumbnailType: ThumbnailType_Type): Promise { const query = { where: { filename, @@ -162,7 +162,7 @@ export class ThumbnailModel extends Model return ThumbnailModel.findOne(query) } - static buildPath (type: ThumbnailType, filename: string) { + static buildPath (type: ThumbnailType_Type, filename: string) { const directory = ThumbnailModel.types[type].directory return join(directory, filename) diff --git a/server/models/video/video-blacklist.ts b/server/server/models/video/video-blacklist.ts similarity index 84% rename from server/models/video/video-blacklist.ts rename to server/server/models/video/video-blacklist.ts index 9247d0e2b..0f6930034 100644 --- a/server/models/video/video-blacklist.ts +++ b/server/server/models/video/video-blacklist.ts @@ -1,14 +1,14 @@ +import { VideoBlacklist, type VideoBlacklistType_Type } from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { MVideoBlacklist, MVideoBlacklistFormattable } from '@server/types/models/index.js' import { FindOptions } from 'sequelize' import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' -import { MVideoBlacklist, MVideoBlacklistFormattable } from '@server/types/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { VideoBlacklist, VideoBlacklistType } from '../../../shared/models/videos' -import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../helpers/custom-validators/video-blacklist' -import { CONSTRAINTS_FIELDS } from '../../initializers/constants' -import { getBlacklistSort, searchAttribute, throwIfNotValid } from '../shared' -import { ThumbnailModel } from './thumbnail' -import { VideoModel } from './video' -import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from './video-channel' +import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../helpers/custom-validators/video-blacklist.js' +import { CONSTRAINTS_FIELDS } from '../../initializers/constants.js' +import { getBlacklistSort, searchAttribute, throwIfNotValid } from '../shared/index.js' +import { ThumbnailModel } from './thumbnail.js' +import { SummaryOptions, VideoChannelModel, ScopeNames as VideoChannelScopeNames } from './video-channel.js' +import { VideoModel } from './video.js' @Table({ tableName: 'videoBlacklist', @@ -34,7 +34,7 @@ export class VideoBlacklistModel extends Model throwIfNotValid(value, isVideoBlacklistTypeValid, 'type')) @Column - type: VideoBlacklistType + type: VideoBlacklistType_Type @CreatedAt createdAt: Date @@ -52,14 +52,14 @@ export class VideoBlacklistModel extends Model static listForApi (parameters: { start: number count: number sort: string search?: string - type?: VideoBlacklistType + type?: VideoBlacklistType_Type }) { const { start, count, sort, search, type } = parameters diff --git a/server/models/video/video-caption.ts b/server/server/models/video/video-caption.ts similarity index 88% rename from server/models/video/video-caption.ts rename to server/server/models/video/video-caption.ts index dd4cefd65..312f23a30 100644 --- a/server/models/video/video-caption.ts +++ b/server/server/models/video/video-caption.ts @@ -1,4 +1,4 @@ -import { remove } from 'fs-extra' +import { remove } from 'fs-extra/esm' import { join } from 'path' import { Op, OrderItem, Transaction } from 'sequelize' import { @@ -15,16 +15,22 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { MVideo, MVideoCaption, MVideoCaptionFormattable, MVideoCaptionLanguageUrl, MVideoCaptionVideo } from '@server/types/models' -import { buildUUID } from '@shared/extra-utils' -import { AttributesOnly } from '@shared/typescript-utils' -import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model' -import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions' -import { logger } from '../../helpers/logger' -import { CONFIG } from '../../initializers/config' -import { CONSTRAINTS_FIELDS, LAZY_STATIC_PATHS, VIDEO_LANGUAGES, WEBSERVER } from '../../initializers/constants' -import { buildWhereIdOrUUID, throwIfNotValid } from '../shared' -import { VideoModel } from './video' +import { VideoCaption } from '@peertube/peertube-models' +import { + MVideo, + MVideoCaption, + MVideoCaptionFormattable, + MVideoCaptionLanguageUrl, + MVideoCaptionVideo +} from '@server/types/models/index.js' +import { buildUUID } from '@peertube/peertube-node-utils' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions.js' +import { logger } from '../../helpers/logger.js' +import { CONFIG } from '../../initializers/config.js' +import { CONSTRAINTS_FIELDS, LAZY_STATIC_PATHS, VIDEO_LANGUAGES, WEBSERVER } from '../../initializers/constants.js' +import { buildWhereIdOrUUID, throwIfNotValid } from '../shared/index.js' +import { VideoModel } from './video.js' export enum ScopeNames { WITH_VIDEO_UUID_AND_REMOTE = 'WITH_VIDEO_UUID_AND_REMOTE' @@ -88,7 +94,7 @@ export class VideoCaptionModel extends Model @BeforeDestroy static async removeFiles (instance: VideoCaptionModel, options) { diff --git a/server/models/video/video-change-ownership.ts b/server/server/models/video/video-change-ownership.ts similarity index 84% rename from server/models/video/video-change-ownership.ts rename to server/server/models/video/video-change-ownership.ts index 26f072f4f..152f85a22 100644 --- a/server/models/video/video-change-ownership.ts +++ b/server/server/models/video/video-change-ownership.ts @@ -1,10 +1,10 @@ +import { VideoChangeOwnership, type VideoChangeOwnershipStatusType } from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { MVideoChangeOwnershipFormattable, MVideoChangeOwnershipFull } from '@server/types/models/video/video-change-ownership.js' import { AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' -import { MVideoChangeOwnershipFormattable, MVideoChangeOwnershipFull } from '@server/types/models/video/video-change-ownership' -import { AttributesOnly } from '@shared/typescript-utils' -import { VideoChangeOwnership, VideoChangeOwnershipStatus } from '../../../shared/models/videos' -import { AccountModel } from '../account/account' -import { getSort } from '../shared' -import { ScopeNames as VideoScopeNames, VideoModel } from './video' +import { AccountModel } from '../account/account.js' +import { getSort } from '../shared/index.js' +import { VideoModel, ScopeNames as VideoScopeNames } from './video.js' enum ScopeNames { WITH_ACCOUNTS = 'WITH_ACCOUNTS', @@ -63,7 +63,7 @@ export class VideoChangeOwnershipModel extends Model AccountModel) @Column @@ -76,7 +76,7 @@ export class VideoChangeOwnershipModel extends Model @ForeignKey(() => AccountModel) @Column @@ -89,7 +89,7 @@ export class VideoChangeOwnershipModel extends Model @ForeignKey(() => VideoModel) @Column @@ -101,7 +101,7 @@ export class VideoChangeOwnershipModel extends Model static listForApi (nextOwnerId: number, start: number, count: number, sort: string) { const query = { diff --git a/server/models/video/video-channel-sync.ts b/server/server/models/video/video-channel-sync.ts similarity index 86% rename from server/models/video/video-channel-sync.ts rename to server/server/models/video/video-channel-sync.ts index a4cbf51f5..da2a99593 100644 --- a/server/models/video/video-channel-sync.ts +++ b/server/server/models/video/video-channel-sync.ts @@ -1,3 +1,9 @@ +import { VideoChannelSync, VideoChannelSyncState, type VideoChannelSyncStateType } from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { isUrlValid } from '@server/helpers/custom-validators/activitypub/misc.js' +import { isVideoChannelSyncStateValid } from '@server/helpers/custom-validators/video-channel-syncs.js' +import { CONSTRAINTS_FIELDS, VIDEO_CHANNEL_SYNC_STATE } from '@server/initializers/constants.js' +import { MChannelSync, MChannelSyncChannel, MChannelSyncFormattable } from '@server/types/models/index.js' import { Op } from 'sequelize' import { AllowNull, @@ -13,16 +19,10 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { isUrlValid } from '@server/helpers/custom-validators/activitypub/misc' -import { isVideoChannelSyncStateValid } from '@server/helpers/custom-validators/video-channel-syncs' -import { CONSTRAINTS_FIELDS, VIDEO_CHANNEL_SYNC_STATE } from '@server/initializers/constants' -import { MChannelSync, MChannelSyncChannel, MChannelSyncFormattable } from '@server/types/models' -import { VideoChannelSync, VideoChannelSyncState } from '@shared/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { AccountModel } from '../account/account' -import { UserModel } from '../user/user' -import { getChannelSyncSort, throwIfNotValid } from '../shared' -import { VideoChannelModel } from './video-channel' +import { AccountModel } from '../account/account.js' +import { getChannelSyncSort, throwIfNotValid } from '../shared/index.js' +import { UserModel } from '../user/user.js' +import { VideoChannelModel } from './video-channel.js' @DefaultScope(() => ({ include: [ @@ -48,6 +48,16 @@ export class VideoChannelSyncModel extends Model throwIfNotValid(value, isVideoChannelSyncStateValid, 'state')) + @Column + state: VideoChannelSyncStateType + + @AllowNull(true) + @Column(DataType.DATE) + lastSyncAt: Date + @CreatedAt createdAt: Date @@ -64,17 +74,7 @@ export class VideoChannelSyncModel extends Model throwIfNotValid(value, isVideoChannelSyncStateValid, 'state')) - @Column - state: VideoChannelSyncState - - @AllowNull(true) - @Column(DataType.DATE) - lastSyncAt: Date + VideoChannel: Awaited static listByAccountForAPI (options: { accountId: number diff --git a/server/models/video/video-channel.ts b/server/server/models/video/video-channel.ts similarity index 95% rename from server/models/video/video-channel.ts rename to server/server/models/video/video-channel.ts index 2c38850d7..5a13fee24 100644 --- a/server/models/video/video-channel.ts +++ b/server/server/models/video/video-channel.ts @@ -1,3 +1,9 @@ +import { forceNumber, pick } from '@peertube/peertube-core-utils' +import { ActivityPubActor, VideoChannel, VideoChannelSummary } from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { CONFIG } from '@server/initializers/config.js' +import { InternalEventEmitter } from '@server/lib/internal-event-emitter.js' +import { MAccountHost } from '@server/types/models/index.js' import { FindOptions, Includeable, literal, Op, QueryTypes, ScopeOptions, Transaction, WhereOptions } from 'sequelize' import { AfterCreate, @@ -20,34 +26,27 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { CONFIG } from '@server/initializers/config' -import { InternalEventEmitter } from '@server/lib/internal-event-emitter' -import { MAccountHost } from '@server/types/models' -import { forceNumber, pick } from '@shared/core-utils' -import { AttributesOnly } from '@shared/typescript-utils' -import { ActivityPubActor } from '../../../shared/models/activitypub' -import { VideoChannel, VideoChannelSummary } from '../../../shared/models/videos' import { isVideoChannelDescriptionValid, isVideoChannelDisplayNameValid, isVideoChannelSupportValid -} from '../../helpers/custom-validators/video-channels' -import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers/constants' -import { sendDeleteActor } from '../../lib/activitypub/send' +} from '../../helpers/custom-validators/video-channels.js' +import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers/constants.js' +import { sendDeleteActor } from '../../lib/activitypub/send/index.js' import { - MChannel, MChannelActor, MChannelAP, MChannelBannerAccountDefault, MChannelFormattable, MChannelHost, - MChannelSummaryFormattable -} from '../../types/models/video' -import { AccountModel, ScopeNames as AccountModelScopeNames, SummaryOptions as AccountSummaryOptions } from '../account/account' -import { ActorModel, unusedActorAttributesForAPI } from '../actor/actor' -import { ActorFollowModel } from '../actor/actor-follow' -import { ActorImageModel } from '../actor/actor-image' -import { ServerModel } from '../server/server' + MChannelSummaryFormattable, + type MChannel +} from '../../types/models/video/index.js' +import { AccountModel, ScopeNames as AccountModelScopeNames, SummaryOptions as AccountSummaryOptions } from '../account/account.js' +import { ActorFollowModel } from '../actor/actor-follow.js' +import { ActorImageModel } from '../actor/actor-image.js' +import { ActorModel, unusedActorAttributesForAPI } from '../actor/actor.js' +import { ServerModel } from '../server/server.js' import { buildServerIdsFollowedBy, buildTrigramSearchIndex, @@ -55,9 +54,9 @@ import { getSort, setAsUpdated, throwIfNotValid -} from '../shared' -import { VideoModel } from './video' -import { VideoPlaylistModel } from './video-playlist' +} from '../shared/index.js' +import { VideoPlaylistModel } from './video-playlist.js' +import { VideoModel } from './video.js' export enum ScopeNames { FOR_API = 'FOR_API', @@ -389,7 +388,7 @@ export class VideoChannelModel extends Model @ForeignKey(() => AccountModel) @Column @@ -400,7 +399,7 @@ export class VideoChannelModel extends Model @HasMany(() => VideoModel, { foreignKey: { @@ -410,7 +409,7 @@ export class VideoChannelModel extends Model[] @HasMany(() => VideoPlaylistModel, { foreignKey: { @@ -419,7 +418,7 @@ export class VideoChannelModel extends Model[] @AfterCreate static notifyCreate (channel: MChannel) { diff --git a/server/models/video/video-comment.ts b/server/server/models/video/video-comment.ts similarity index 86% rename from server/models/video/video-comment.ts rename to server/server/models/video/video-comment.ts index ff5142809..001ef85bb 100644 --- a/server/models/video/video-comment.ts +++ b/server/server/models/video/video-comment.ts @@ -13,17 +13,14 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { getServerActor } from '@server/models/application/application' -import { MAccount, MAccountId, MUserAccountId } from '@server/types/models' -import { pick, uniqify } from '@shared/core-utils' -import { AttributesOnly } from '@shared/typescript-utils' -import { ActivityTagObject, ActivityTombstoneObject } from '../../../shared/models/activitypub/objects/common-objects' -import { VideoCommentObject } from '../../../shared/models/activitypub/objects/video-comment-object' -import { VideoComment, VideoCommentAdmin } from '../../../shared/models/videos/comment/video-comment.model' -import { actorNameAlphabet } from '../../helpers/custom-validators/activitypub/actor' -import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' -import { regexpCapture } from '../../helpers/regexp' -import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers/constants' +import { pick } from '@peertube/peertube-core-utils' +import { ActivityTagObject, ActivityTombstoneObject, VideoComment, VideoCommentAdmin, VideoCommentObject } from '@peertube/peertube-models' +import { extractMentions } from '@server/helpers/mentions.js' +import { getServerActor } from '@server/models/application/application.js' +import { MAccount, MAccountId, MUserAccountId } from '@server/types/models/index.js' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc.js' +import { CONSTRAINTS_FIELDS } from '../../initializers/constants.js' import { MComment, MCommentAdminFormattable, @@ -36,14 +33,14 @@ import { MCommentOwnerVideoFeed, MCommentOwnerVideoReply, MVideoImmutable -} from '../../types/models/video' -import { VideoCommentAbuseModel } from '../abuse/video-comment-abuse' -import { AccountModel } from '../account/account' -import { ActorModel } from '../actor/actor' -import { buildLocalAccountIdsIn, buildSQLAttributes, throwIfNotValid } from '../shared' -import { ListVideoCommentsOptions, VideoCommentListQueryBuilder } from './sql/comment/video-comment-list-query-builder' -import { VideoModel } from './video' -import { VideoChannelModel } from './video-channel' +} from '../../types/models/video/index.js' +import { VideoCommentAbuseModel } from '../abuse/video-comment-abuse.js' +import { AccountModel } from '../account/account.js' +import { ActorModel } from '../actor/actor.js' +import { buildLocalAccountIdsIn, buildSQLAttributes, throwIfNotValid } from '../shared/index.js' +import { ListVideoCommentsOptions, VideoCommentListQueryBuilder } from './sql/comment/video-comment-list-query-builder.js' +import { VideoChannelModel } from './video-channel.js' +import { VideoModel } from './video.js' export enum ScopeNames { WITH_ACCOUNT = 'WITH_ACCOUNT', @@ -143,7 +140,7 @@ export class VideoCommentModel extends Model @ForeignKey(() => VideoCommentModel) @Column @@ -157,7 +154,7 @@ export class VideoCommentModel extends Model | null @ForeignKey(() => VideoModel) @Column @@ -169,7 +166,7 @@ export class VideoCommentModel extends Model @ForeignKey(() => AccountModel) @Column @@ -181,7 +178,7 @@ export class VideoCommentModel extends Model @HasMany(() => VideoCommentAbuseModel, { foreignKey: { @@ -190,7 +187,7 @@ export class VideoCommentModel extends Model[] // --------------------------------------------------------------------------- @@ -531,41 +528,7 @@ export class VideoCommentModel extends Model username1 || username2), - - regexpCapture(this.text, endMentionRegex) - .map(([ , username1, username2 ]) => username1 || username2), - - regexpCapture(this.text, remoteMentionsRegex) - .map(([ , username ]) => username) - ) - - // Include local mentions - if (this.isOwned()) { - const localMentionsRegex = new RegExp(' ' + localMention + ' ', 'g') - - result = result.concat( - regexpCapture(this.text, localMentionsRegex) - .map(([ , username ]) => username) - ) - } - - return uniqify(result) + return extractMentions(this.text, this.isOwned()) } toFormattedJSON (this: MCommentFormattable) { diff --git a/server/models/video/video-file.ts b/server/server/models/video/video-file.ts similarity index 93% rename from server/models/video/video-file.ts rename to server/server/models/video/video-file.ts index ee34ad2ff..735bda2d5 100644 --- a/server/models/video/video-file.ts +++ b/server/server/models/video/video-file.ts @@ -1,4 +1,19 @@ -import { remove } from 'fs-extra' +import { VideoResolution, VideoStorage, type VideoStorageType } from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { logger } from '@server/helpers/logger.js' +import { extractVideo } from '@server/helpers/video.js' +import { CONFIG } from '@server/initializers/config.js' +import { buildRemoteVideoBaseUrl } from '@server/lib/activitypub/url.js' +import { + getHLSPrivateFileUrl, + getHLSPublicFileUrl, + getWebVideoPrivateFileUrl, + getWebVideoPublicFileUrl +} from '@server/lib/object-storage/index.js' +import { getFSTorrentFilePath } from '@server/lib/paths.js' +import { isVideoInPrivateDirectory } from '@server/lib/video-privacy.js' +import { MStreamingPlaylistVideo, MVideo, MVideoWithHost, isStreamingPlaylist } from '@server/types/models/index.js' +import { remove } from 'fs-extra/esm' import memoizee from 'memoizee' import { join } from 'path' import { FindOptions, Op, Transaction, WhereOptions } from 'sequelize' @@ -19,28 +34,13 @@ import { UpdatedAt } from 'sequelize-typescript' import validator from 'validator' -import { logger } from '@server/helpers/logger' -import { extractVideo } from '@server/helpers/video' -import { CONFIG } from '@server/initializers/config' -import { buildRemoteVideoBaseUrl } from '@server/lib/activitypub/url' -import { - getHLSPrivateFileUrl, - getHLSPublicFileUrl, - getWebVideoPrivateFileUrl, - getWebVideoPublicFileUrl -} from '@server/lib/object-storage' -import { getFSTorrentFilePath } from '@server/lib/paths' -import { isVideoInPrivateDirectory } from '@server/lib/video-privacy' -import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoWithHost } from '@server/types/models' -import { VideoResolution, VideoStorage } from '@shared/models' -import { AttributesOnly } from '@shared/typescript-utils' import { + isVideoFPSResolutionValid, isVideoFileExtnameValid, isVideoFileInfoHashValid, isVideoFileResolutionValid, - isVideoFileSizeValid, - isVideoFPSResolutionValid -} from '../../helpers/custom-validators/videos' + isVideoFileSizeValid +} from '../../helpers/custom-validators/videos.js' import { LAZY_STATIC_PATHS, MEMOIZE_LENGTH, @@ -48,12 +48,12 @@ import { STATIC_DOWNLOAD_PATHS, STATIC_PATHS, WEBSERVER -} from '../../initializers/constants' -import { MVideoFile, MVideoFileStreamingPlaylistVideo, MVideoFileVideo } from '../../types/models/video/video-file' -import { VideoRedundancyModel } from '../redundancy/video-redundancy' -import { doesExist, parseAggregateResult, throwIfNotValid } from '../shared' -import { VideoModel } from './video' -import { VideoStreamingPlaylistModel } from './video-streaming-playlist' +} from '../../initializers/constants.js' +import { MVideoFile, MVideoFileStreamingPlaylistVideo, MVideoFileVideo } from '../../types/models/video/video-file.js' +import { VideoRedundancyModel } from '../redundancy/video-redundancy.js' +import { doesExist, parseAggregateResult, throwIfNotValid } from '../shared/index.js' +import { VideoStreamingPlaylistModel } from './video-streaming-playlist.js' +import { VideoModel } from './video.js' export enum ScopeNames { WITH_VIDEO = 'WITH_VIDEO', @@ -225,7 +225,7 @@ export class VideoFileModel extends Model @AllowNull(false) @Default(VideoStorage.FILE_SYSTEM) @Column - storage: VideoStorage + storage: VideoStorageType @BelongsTo(() => VideoModel, { foreignKey: { @@ -233,7 +233,7 @@ export class VideoFileModel extends Model }, onDelete: 'CASCADE' }) - Video: VideoModel + Video: Awaited @ForeignKey(() => VideoStreamingPlaylistModel) @Column @@ -245,7 +245,7 @@ export class VideoFileModel extends Model }, onDelete: 'CASCADE' }) - VideoStreamingPlaylist: VideoStreamingPlaylistModel + VideoStreamingPlaylist: Awaited @HasMany(() => VideoRedundancyModel, { foreignKey: { @@ -254,7 +254,7 @@ export class VideoFileModel extends Model onDelete: 'CASCADE', hooks: true }) - RedundancyVideos: VideoRedundancyModel[] + RedundancyVideos: Awaited[] static doesInfohashExistCached = memoizee(VideoFileModel.doesInfohashExist, { promise: true, @@ -334,7 +334,7 @@ export class VideoFileModel extends Model } static loadWithVideoOrPlaylist (id: number, videoIdOrUUID: number | string) { - const whereVideo = validator.isUUID(videoIdOrUUID + '') + const whereVideo = validator.default.isUUID(videoIdOrUUID + '') ? { uuid: videoIdOrUUID } : { id: videoIdOrUUID } diff --git a/server/models/video/video-import.ts b/server/server/models/video/video-import.ts similarity index 90% rename from server/models/video/video-import.ts rename to server/server/models/video/video-import.ts index c040e0fda..4de0cb104 100644 --- a/server/models/video/video-import.ts +++ b/server/server/models/video/video-import.ts @@ -1,3 +1,7 @@ +import { VideoImport, VideoImportState, type VideoImportStateType } from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { afterCommitIfTransaction } from '@server/helpers/database-utils.js' +import { MVideoImportDefault, MVideoImportFormattable } from '@server/types/models/video/video-import.js' import { IncludeOptions, Op, WhereOptions } from 'sequelize' import { AfterUpdate, @@ -14,17 +18,13 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { afterCommitIfTransaction } from '@server/helpers/database-utils' -import { MVideoImportDefault, MVideoImportFormattable } from '@server/types/models/video/video-import' -import { VideoImport, VideoImportState } from '@shared/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { isVideoImportStateValid, isVideoImportTargetUrlValid } from '../../helpers/custom-validators/video-imports' -import { isVideoMagnetUriValid } from '../../helpers/custom-validators/videos' -import { CONSTRAINTS_FIELDS, VIDEO_IMPORT_STATES } from '../../initializers/constants' -import { UserModel } from '../user/user' -import { getSort, searchAttribute, throwIfNotValid } from '../shared' -import { ScopeNames as VideoModelScopeNames, VideoModel } from './video' -import { VideoChannelSyncModel } from './video-channel-sync' +import { isVideoImportStateValid, isVideoImportTargetUrlValid } from '../../helpers/custom-validators/video-imports.js' +import { isVideoMagnetUriValid } from '../../helpers/custom-validators/videos.js' +import { CONSTRAINTS_FIELDS, VIDEO_IMPORT_STATES } from '../../initializers/constants.js' +import { getSort, searchAttribute, throwIfNotValid } from '../shared/index.js' +import { UserModel } from '../user/user.js' +import { VideoChannelSyncModel } from './video-channel-sync.js' +import { VideoModel, ScopeNames as VideoModelScopeNames } from './video.js' const defaultVideoScope = () => { return VideoModel.scope([ @@ -91,7 +91,7 @@ export class VideoImportModel extends Model throwIfNotValid(value, isVideoImportStateValid, 'state')) @Column - state: VideoImportState + state: VideoImportStateType @AllowNull(true) @Default(null) @@ -108,7 +108,7 @@ export class VideoImportModel extends Model @ForeignKey(() => VideoModel) @Column @@ -120,7 +120,7 @@ export class VideoImportModel extends Model @ForeignKey(() => VideoChannelSyncModel) @Column @@ -132,7 +132,7 @@ export class VideoImportModel extends Model @AfterUpdate static deleteVideoIfFailed (instance: VideoImportModel, options) { diff --git a/server/models/video/video-job-info.ts b/server/server/models/video/video-job-info.ts similarity index 93% rename from server/models/video/video-job-info.ts rename to server/server/models/video/video-job-info.ts index 5845b8c74..4fd956528 100644 --- a/server/models/video/video-job-info.ts +++ b/server/server/models/video/video-job-info.ts @@ -1,8 +1,8 @@ import { Op, QueryTypes, Transaction } from 'sequelize' import { AllowNull, BelongsTo, Column, CreatedAt, Default, ForeignKey, IsInt, Model, Table, Unique, UpdatedAt } from 'sequelize-typescript' -import { forceNumber } from '@shared/core-utils' -import { AttributesOnly } from '@shared/typescript-utils' -import { VideoModel } from './video' +import { forceNumber } from '@peertube/peertube-core-utils' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { VideoModel } from './video.js' export type VideoJobInfoColumnType = 'pendingMove' | 'pendingTranscode' @@ -50,7 +50,7 @@ export class VideoJobInfoModel extends Model static load (videoId: number, transaction?: Transaction) { const where = { diff --git a/server/models/video/video-live-replay-setting.ts b/server/server/models/video/video-live-replay-setting.ts similarity index 82% rename from server/models/video/video-live-replay-setting.ts rename to server/server/models/video/video-live-replay-setting.ts index 1c824dfa2..174d0c1f5 100644 --- a/server/models/video/video-live-replay-setting.ts +++ b/server/server/models/video/video-live-replay-setting.ts @@ -1,9 +1,9 @@ -import { isVideoPrivacyValid } from '@server/helpers/custom-validators/videos' -import { MLiveReplaySetting } from '@server/types/models/video/video-live-replay-setting' -import { VideoPrivacy } from '@shared/models/videos/video-privacy.enum' +import { type VideoPrivacyType } from '@peertube/peertube-models' +import { isVideoPrivacyValid } from '@server/helpers/custom-validators/videos.js' +import { MLiveReplaySetting } from '@server/types/models/video/video-live-replay-setting.js' import { Transaction } from 'sequelize' import { AllowNull, Column, CreatedAt, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' -import { throwIfNotValid } from '../shared/sequelize-helpers' +import { throwIfNotValid } from '../shared/sequelize-helpers.js' @Table({ tableName: 'videoLiveReplaySetting' @@ -19,7 +19,7 @@ export class VideoLiveReplaySettingModel extends Model throwIfNotValid(value, isVideoPrivacyValid, 'privacy')) @Column - privacy: VideoPrivacy + privacy: VideoPrivacyType static load (id: number, transaction?: Transaction): Promise { return VideoLiveReplaySettingModel.findOne({ diff --git a/server/models/video/video-live-session.ts b/server/server/models/video/video-live-session.ts similarity index 90% rename from server/models/video/video-live-session.ts rename to server/server/models/video/video-live-session.ts index 9426f5d11..33bd40d89 100644 --- a/server/models/video/video-live-session.ts +++ b/server/server/models/video/video-live-session.ts @@ -1,3 +1,7 @@ +import { LiveVideoSession, type LiveVideoErrorType } from '@peertube/peertube-models' +import { uuidToShort } from '@peertube/peertube-node-utils' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { MVideoLiveSession, MVideoLiveSessionReplay } from '@server/types/models/index.js' import { FindOptions } from 'sequelize' import { AllowNull, @@ -12,12 +16,8 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { MVideoLiveSession, MVideoLiveSessionReplay } from '@server/types/models' -import { uuidToShort } from '@shared/extra-utils' -import { LiveVideoError, LiveVideoSession } from '@shared/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { VideoModel } from './video' -import { VideoLiveReplaySettingModel } from './video-live-replay-setting' +import { VideoLiveReplaySettingModel } from './video-live-replay-setting.js' +import { VideoModel } from './video.js' export enum ScopeNames { WITH_REPLAY = 'WITH_REPLAY' @@ -72,7 +72,7 @@ export class VideoLiveSessionModel extends Model @ForeignKey(() => VideoModel) @Column @@ -108,7 +108,7 @@ export class VideoLiveSessionModel extends Model @ForeignKey(() => VideoLiveReplaySettingModel) @Column @@ -120,7 +120,7 @@ export class VideoLiveSessionModel extends Model @BeforeDestroy static deleteReplaySetting (instance: VideoLiveSessionModel) { diff --git a/server/models/video/video-live.ts b/server/server/models/video/video-live.ts similarity index 86% rename from server/models/video/video-live.ts rename to server/server/models/video/video-live.ts index ca1118641..fefaa053a 100644 --- a/server/models/video/video-live.ts +++ b/server/server/models/video/video-live.ts @@ -1,3 +1,8 @@ +import { LiveVideo, VideoState, type LiveVideoLatencyModeType } from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { CONFIG } from '@server/initializers/config.js' +import { WEBSERVER } from '@server/initializers/constants.js' +import { MVideoLive, MVideoLiveVideoWithSetting } from '@server/types/models/index.js' import { Transaction } from 'sequelize' import { AllowNull, @@ -12,14 +17,9 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { CONFIG } from '@server/initializers/config' -import { WEBSERVER } from '@server/initializers/constants' -import { MVideoLive, MVideoLiveVideoWithSetting } from '@server/types/models' -import { LiveVideo, LiveVideoLatencyMode, VideoState } from '@shared/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { VideoModel } from './video' -import { VideoBlacklistModel } from './video-blacklist' -import { VideoLiveReplaySettingModel } from './video-live-replay-setting' +import { VideoBlacklistModel } from './video-blacklist.js' +import { VideoLiveReplaySettingModel } from './video-live-replay-setting.js' +import { VideoModel } from './video.js' @DefaultScope(() => ({ include: [ @@ -68,7 +68,7 @@ export class VideoLiveModel extends Model @AllowNull(false) @Column - latencyMode: LiveVideoLatencyMode + latencyMode: LiveVideoLatencyModeType @CreatedAt createdAt: Date @@ -86,7 +86,7 @@ export class VideoLiveModel extends Model }, onDelete: 'cascade' }) - Video: VideoModel + Video: Awaited @ForeignKey(() => VideoLiveReplaySettingModel) @Column @@ -98,7 +98,7 @@ export class VideoLiveModel extends Model }, onDelete: 'set null' }) - ReplaySetting: VideoLiveReplaySettingModel + ReplaySetting: Awaited @BeforeDestroy static deleteReplaySetting (instance: VideoLiveModel, options: { transaction: Transaction }) { diff --git a/server/models/video/video-password.ts b/server/server/models/video/video-password.ts similarity index 88% rename from server/models/video/video-password.ts rename to server/server/models/video/video-password.ts index 648366c3b..f841f320e 100644 --- a/server/models/video/video-password.ts +++ b/server/server/models/video/video-password.ts @@ -1,12 +1,12 @@ import { AllowNull, BelongsTo, Column, CreatedAt, DefaultScope, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' -import { VideoModel } from './video' -import { AttributesOnly } from '@shared/typescript-utils' -import { ResultList, VideoPassword } from '@shared/models' -import { getSort, throwIfNotValid } from '../shared' +import { VideoModel } from './video.js' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { ResultList, VideoPassword } from '@peertube/peertube-models' +import { getSort, throwIfNotValid } from '../shared/index.js' import { FindOptions, Transaction } from 'sequelize' -import { MVideoPassword } from '@server/types/models' -import { isPasswordValid } from '@server/helpers/custom-validators/videos' -import { pick } from '@shared/core-utils' +import { MVideoPassword } from '@server/types/models/index.js' +import { isPasswordValid } from '@server/helpers/custom-validators/videos.js' +import { pick } from '@peertube/peertube-core-utils' @DefaultScope(() => ({ include: [ @@ -48,7 +48,7 @@ export class VideoPasswordModel extends Model static async countByVideoId (videoId: number, t?: Transaction) { const query: FindOptions = { diff --git a/server/models/video/video-playlist-element.ts b/server/server/models/video/video-playlist-element.ts similarity index 89% rename from server/models/video/video-playlist-element.ts rename to server/server/models/video/video-playlist-element.ts index 61ae6b9fe..62b0e3434 100644 --- a/server/models/video/video-playlist-element.ts +++ b/server/server/models/video/video-playlist-element.ts @@ -15,25 +15,29 @@ import { UpdatedAt } from 'sequelize-typescript' import validator from 'validator' -import { MUserAccountId } from '@server/types/models' +import { forceNumber } from '@peertube/peertube-core-utils' +import { + PlaylistElementObject, + VideoPlaylistElement, + VideoPlaylistElementType, + VideoPrivacy, + VideoPrivacyType +} from '@peertube/peertube-models' +import { MUserAccountId } from '@server/types/models/index.js' import { MVideoPlaylistElement, MVideoPlaylistElementAP, MVideoPlaylistElementFormattable, MVideoPlaylistElementVideoUrlPlaylistPrivacy, MVideoPlaylistVideoThumbnail -} from '@server/types/models/video/video-playlist-element' -import { forceNumber } from '@shared/core-utils' -import { AttributesOnly } from '@shared/typescript-utils' -import { PlaylistElementObject } from '../../../shared/models/activitypub/objects/playlist-element-object' -import { VideoPrivacy } from '../../../shared/models/videos' -import { VideoPlaylistElement, VideoPlaylistElementType } from '../../../shared/models/videos/playlist/video-playlist-element.model' -import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' -import { CONSTRAINTS_FIELDS } from '../../initializers/constants' -import { AccountModel } from '../account/account' -import { getSort, throwIfNotValid } from '../shared' -import { ForAPIOptions, ScopeNames as VideoScopeNames, VideoModel } from './video' -import { VideoPlaylistModel } from './video-playlist' +} from '@server/types/models/video/video-playlist-element.js' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc.js' +import { CONSTRAINTS_FIELDS } from '../../initializers/constants.js' +import { AccountModel } from '../account/account.js' +import { getSort, throwIfNotValid } from '../shared/index.js' +import { VideoPlaylistModel } from './video-playlist.js' +import { ForAPIOptions, ScopeNames as VideoScopeNames, VideoModel } from './video.js' @Table({ tableName: 'videoPlaylistElement', @@ -91,7 +95,7 @@ export class VideoPlaylistElementModel extends Model @ForeignKey(() => VideoModel) @Column @@ -103,7 +107,7 @@ export class VideoPlaylistElementModel extends Model static deleteAllOf (videoPlaylistId: number, transaction?: Transaction) { const query = { @@ -186,7 +190,7 @@ export class VideoPlaylistElementModel extends Model { - const playlistWhere = validator.isUUID('' + playlistId) + const playlistWhere = validator.default.isUUID('' + playlistId) ? { uuid: playlistId } : { id: playlistId } @@ -337,7 +341,8 @@ export class VideoPlaylistElementModel extends Model([ VideoPrivacy.PRIVATE, VideoPrivacy.INTERNAL, VideoPrivacy.PASSWORD_PROTECTED ]) + if (protectedPrivacy.has(video.privacy)) { return VideoPlaylistElementType.PRIVATE } diff --git a/server/models/video/video-playlist.ts b/server/server/models/video/video-playlist.ts similarity index 92% rename from server/models/video/video-playlist.ts rename to server/server/models/video/video-playlist.ts index 15999d409..716e78c4c 100644 --- a/server/models/video/video-playlist.ts +++ b/server/server/models/video/video-playlist.ts @@ -1,3 +1,17 @@ +import { buildPlaylistEmbedPath, buildPlaylistWatchPath, pick } from '@peertube/peertube-core-utils' +import { + ActivityIconObject, + PlaylistObject, + VideoPlaylist, + VideoPlaylistPrivacy, + VideoPlaylistType, + type VideoPlaylistPrivacyType, + type VideoPlaylistType_Type +} from '@peertube/peertube-models' +import { buildUUID, uuidToShort } from '@peertube/peertube-node-utils' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { activityPubCollectionPagination } from '@server/lib/activitypub/collection.js' +import { MAccountId, MChannelId } from '@server/types/models/index.js' import { join } from 'path' import { FindOptions, Includeable, literal, Op, ScopeOptions, Sequelize, Transaction, WhereOptions } from 'sequelize' import { @@ -17,18 +31,12 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { activityPubCollectionPagination } from '@server/lib/activitypub/collection' -import { MAccountId, MChannelId } from '@server/types/models' -import { buildPlaylistEmbedPath, buildPlaylistWatchPath, pick } from '@shared/core-utils' -import { buildUUID, uuidToShort } from '@shared/extra-utils' -import { ActivityIconObject, PlaylistObject, VideoPlaylist, VideoPlaylistPrivacy, VideoPlaylistType } from '@shared/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' +import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc.js' import { isVideoPlaylistDescriptionValid, isVideoPlaylistNameValid, isVideoPlaylistPrivacyValid -} from '../../helpers/custom-validators/video-playlists' +} from '../../helpers/custom-validators/video-playlists.js' import { ACTIVITY_PUB, CONSTRAINTS_FIELDS, @@ -37,8 +45,8 @@ import { VIDEO_PLAYLIST_PRIVACIES, VIDEO_PLAYLIST_TYPES, WEBSERVER -} from '../../initializers/constants' -import { MThumbnail } from '../../types/models/video/thumbnail' +} from '../../initializers/constants.js' +import { MThumbnail } from '../../types/models/video/thumbnail.js' import { MVideoPlaylistAccountThumbnail, MVideoPlaylistAP, @@ -46,9 +54,9 @@ import { MVideoPlaylistFull, MVideoPlaylistFullSummary, MVideoPlaylistSummaryWithElements -} from '../../types/models/video/video-playlist' -import { AccountModel, ScopeNames as AccountScopeNames, SummaryOptions } from '../account/account' -import { ActorModel } from '../actor/actor' +} from '../../types/models/video/video-playlist.js' +import { AccountModel, ScopeNames as AccountScopeNames, SummaryOptions } from '../account/account.js' +import { ActorModel } from '../actor/actor.js' import { buildServerIdsFollowedBy, buildTrigramSearchIndex, @@ -58,10 +66,10 @@ import { isOutdated, setAsUpdated, throwIfNotValid -} from '../shared' -import { ThumbnailModel } from './thumbnail' -import { ScopeNames as VideoChannelScopeNames, VideoChannelModel } from './video-channel' -import { VideoPlaylistElementModel } from './video-playlist-element' +} from '../shared/index.js' +import { ThumbnailModel } from './thumbnail.js' +import { VideoChannelModel, ScopeNames as VideoChannelScopeNames } from './video-channel.js' +import { VideoPlaylistElementModel } from './video-playlist-element.js' enum ScopeNames { AVAILABLE_FOR_LIST = 'AVAILABLE_FOR_LIST', @@ -74,7 +82,7 @@ enum ScopeNames { type AvailableForListOptions = { followerActorId?: number - type?: VideoPlaylistType + type?: VideoPlaylistType_Type accountId?: number videoChannelId?: number listMyPlaylists?: boolean @@ -299,7 +307,7 @@ export class VideoPlaylistModel extends Model throwIfNotValid(value, isVideoPlaylistPrivacyValid, 'privacy')) @Column - privacy: VideoPlaylistPrivacy + privacy: VideoPlaylistPrivacyType @AllowNull(false) @Is('VideoPlaylistUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'url')) @@ -315,7 +323,7 @@ export class VideoPlaylistModel extends Model AccountModel) @Column @@ -327,7 +335,7 @@ export class VideoPlaylistModel extends Model @ForeignKey(() => VideoChannelModel) @Column @@ -339,7 +347,7 @@ export class VideoPlaylistModel extends Model @HasMany(() => VideoPlaylistElementModel, { foreignKey: { @@ -348,7 +356,7 @@ export class VideoPlaylistModel extends Model[] @HasOne(() => ThumbnailModel, { foreignKey: { @@ -358,7 +366,7 @@ export class VideoPlaylistModel extends Model static listForApi (options: AvailableForListOptions & { start: number @@ -550,11 +558,11 @@ export class VideoPlaylistModel extends Model @ForeignKey(() => VideoModel) @Column @@ -87,7 +87,7 @@ export class VideoShareModel extends Model static load (actorId: number | string, videoId: number | string, t?: Transaction): Promise { return VideoShareModel.scope(ScopeNames.WITH_ACTOR).findOne({ diff --git a/server/models/video/video-source.ts b/server/server/models/video/video-source.ts similarity index 81% rename from server/models/video/video-source.ts rename to server/server/models/video/video-source.ts index 1b6868b85..32743e796 100644 --- a/server/models/video/video-source.ts +++ b/server/server/models/video/video-source.ts @@ -1,9 +1,9 @@ import { Transaction } from 'sequelize' import { AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript' -import { VideoSource } from '@shared/models/videos/video-source' -import { AttributesOnly } from '@shared/typescript-utils' -import { getSort } from '../shared' -import { VideoModel } from './video' +import { VideoSource } from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { getSort } from '../shared/index.js' +import { VideoModel } from './video.js' @Table({ tableName: 'videoSource', @@ -37,7 +37,7 @@ export class VideoSourceModel extends Model static loadLatest (videoId: number, transaction?: Transaction) { return VideoSourceModel.findOne({ diff --git a/server/models/video/video-streaming-playlist.ts b/server/server/models/video/video-streaming-playlist.ts similarity index 89% rename from server/models/video/video-streaming-playlist.ts rename to server/server/models/video/video-streaming-playlist.ts index a85c79c9f..0c4043c44 100644 --- a/server/models/video/video-streaming-playlist.ts +++ b/server/server/models/video/video-streaming-playlist.ts @@ -1,3 +1,17 @@ +import { + VideoStorage, + VideoStreamingPlaylistType, + type VideoStorageType, + type VideoStreamingPlaylistType_Type +} from '@peertube/peertube-models' +import { sha1 } from '@peertube/peertube-node-utils' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { CONFIG } from '@server/initializers/config.js' +import { getHLSPrivateFileUrl, getHLSPublicFileUrl } from '@server/lib/object-storage/index.js' +import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename } from '@server/lib/paths.js' +import { isVideoInPrivateDirectory } from '@server/lib/video-privacy.js' +import { VideoFileModel } from '@server/models/video/video-file.js' +import { MStreamingPlaylist, MStreamingPlaylistFilesVideo, MVideo } from '@server/types/models/index.js' import memoizee from 'memoizee' import { join } from 'path' import { Op, Transaction } from 'sequelize' @@ -15,19 +29,9 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { CONFIG } from '@server/initializers/config' -import { getHLSPrivateFileUrl, getHLSPublicFileUrl } from '@server/lib/object-storage' -import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename } from '@server/lib/paths' -import { isVideoInPrivateDirectory } from '@server/lib/video-privacy' -import { VideoFileModel } from '@server/models/video/video-file' -import { MStreamingPlaylist, MStreamingPlaylistFilesVideo, MVideo } from '@server/types/models' -import { sha1 } from '@shared/extra-utils' -import { VideoStorage } from '@shared/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type' -import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' -import { isArrayOf } from '../../helpers/custom-validators/misc' -import { isVideoFileInfoHashValid } from '../../helpers/custom-validators/videos' +import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc.js' +import { isArrayOf } from '../../helpers/custom-validators/misc.js' +import { isVideoFileInfoHashValid } from '../../helpers/custom-validators/videos.js' import { CONSTRAINTS_FIELDS, MEMOIZE_LENGTH, @@ -35,10 +39,10 @@ import { P2P_MEDIA_LOADER_PEER_VERSION, STATIC_PATHS, WEBSERVER -} from '../../initializers/constants' -import { VideoRedundancyModel } from '../redundancy/video-redundancy' -import { doesExist, throwIfNotValid } from '../shared' -import { VideoModel } from './video' +} from '../../initializers/constants.js' +import { VideoRedundancyModel } from '../redundancy/video-redundancy.js' +import { doesExist, throwIfNotValid } from '../shared/index.js' +import { VideoModel } from './video.js' @Table({ tableName: 'videoStreamingPlaylist', @@ -65,7 +69,7 @@ export class VideoStreamingPlaylistModel extends Model VideoModel, { foreignKey: { @@ -109,7 +113,7 @@ export class VideoStreamingPlaylistModel extends Model @HasMany(() => VideoFileModel, { foreignKey: { @@ -117,7 +121,7 @@ export class VideoStreamingPlaylistModel extends Model[] @HasMany(() => VideoRedundancyModel, { foreignKey: { @@ -126,7 +130,7 @@ export class VideoStreamingPlaylistModel extends Model[] static doesInfohashExistCached = memoizee(VideoStreamingPlaylistModel.doesInfohashExist, { promise: true, diff --git a/server/models/video/video-tag.ts b/server/server/models/video/video-tag.ts similarity index 77% rename from server/models/video/video-tag.ts rename to server/server/models/video/video-tag.ts index 7e880c968..5c36a8de5 100644 --- a/server/models/video/video-tag.ts +++ b/server/server/models/video/video-tag.ts @@ -1,7 +1,7 @@ import { Column, CreatedAt, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript' -import { AttributesOnly } from '@shared/typescript-utils' -import { TagModel } from './tag' -import { VideoModel } from './video' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { TagModel } from './tag.js' +import { VideoModel } from './video.js' @Table({ tableName: 'videoTag', diff --git a/server/models/video/video.ts b/server/server/models/video/video.ts similarity index 91% rename from server/models/video/video.ts rename to server/server/models/video/video.ts index 73308182d..a6383b7c7 100644 --- a/server/models/video/video.ts +++ b/server/server/models/video/video.ts @@ -1,7 +1,45 @@ +import { buildVideoEmbedPath, buildVideoWatchPath, pick } from '@peertube/peertube-core-utils' +import { ffprobePromise, getAudioStream, getVideoStreamDimensionsInfo, getVideoStreamFPS, hasAudioStream } from '@peertube/peertube-ffmpeg' +import { + ResultList, + ThumbnailType, + UserRight, + Video, + VideoDetails, + VideoFile, + VideoInclude, + VideoIncludeType, + VideoObject, + VideoPrivacy, + VideoRateType, + VideoState, + VideoStorage, + VideoStreamingPlaylistType, + type VideoPrivacyType, + type VideoStateType +} from '@peertube/peertube-models' +import { uuidToShort } from '@peertube/peertube-node-utils' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video.js' +import { InternalEventEmitter } from '@server/lib/internal-event-emitter.js' +import { LiveManager } from '@server/lib/live/live-manager.js' +import { + removeHLSFileObjectStorageByFilename, + removeHLSObjectStorage, + removeWebVideoObjectStorage +} from '@server/lib/object-storage/index.js' +import { tracer } from '@server/lib/opentelemetry/tracing.js' +import { getHLSDirectory, getHLSRedundancyDirectory, getHlsResolutionPlaylistFilename } from '@server/lib/paths.js' +import { Hooks } from '@server/lib/plugins/hooks.js' +import { VideoPathManager } from '@server/lib/video-path-manager.js' +import { isVideoInPrivateDirectory } from '@server/lib/video-privacy.js' +import { getServerActor } from '@server/models/application/application.js' +import { ModelCache } from '@server/models/shared/model-cache.js' import Bluebird from 'bluebird' -import { remove } from 'fs-extra' -import { maxBy, minBy } from 'lodash' -import { FindOptions, Includeable, IncludeOptions, Op, QueryTypes, ScopeOptions, Sequelize, Transaction, WhereOptions } from 'sequelize' +import { remove } from 'fs-extra/esm' +import maxBy from 'lodash-es/maxBy.js' +import minBy from 'lodash-es/minBy.js' +import { FindOptions, IncludeOptions, Includeable, Op, QueryTypes, ScopeOptions, Sequelize, Transaction, WhereOptions } from 'sequelize' import { AfterCreate, AfterDestroy, @@ -26,39 +64,9 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video' -import { InternalEventEmitter } from '@server/lib/internal-event-emitter' -import { LiveManager } from '@server/lib/live/live-manager' -import { removeHLSFileObjectStorageByFilename, removeHLSObjectStorage, removeWebVideoObjectStorage } from '@server/lib/object-storage' -import { tracer } from '@server/lib/opentelemetry/tracing' -import { getHLSDirectory, getHLSRedundancyDirectory, getHlsResolutionPlaylistFilename } from '@server/lib/paths' -import { Hooks } from '@server/lib/plugins/hooks' -import { VideoPathManager } from '@server/lib/video-path-manager' -import { isVideoInPrivateDirectory } from '@server/lib/video-privacy' -import { getServerActor } from '@server/models/application/application' -import { ModelCache } from '@server/models/shared/model-cache' -import { buildVideoEmbedPath, buildVideoWatchPath, pick } from '@shared/core-utils' -import { uuidToShort } from '@shared/extra-utils' -import { ffprobePromise, getAudioStream, getVideoStreamDimensionsInfo, getVideoStreamFPS, hasAudioStream } from '@shared/ffmpeg' -import { - ResultList, - ThumbnailType, - UserRight, - Video, - VideoDetails, - VideoFile, - VideoInclude, - VideoObject, - VideoPrivacy, - VideoRateType, - VideoState, - VideoStorage, - VideoStreamingPlaylistType -} from '@shared/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { peertubeTruncate } from '../../helpers/core-utils' -import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' -import { exists, isArray, isBooleanValid, isUUIDValid } from '../../helpers/custom-validators/misc' +import { peertubeTruncate } from '../../helpers/core-utils.js' +import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc.js' +import { exists, isArray, isBooleanValid, isUUIDValid } from '../../helpers/custom-validators/misc.js' import { isVideoDescriptionValid, isVideoDurationValid, @@ -66,11 +74,11 @@ import { isVideoPrivacyValid, isVideoStateValid, isVideoSupportValid -} from '../../helpers/custom-validators/videos' -import { logger } from '../../helpers/logger' -import { CONFIG } from '../../initializers/config' -import { ACTIVITY_PUB, API_VERSION, CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers/constants' -import { sendDeleteVideo } from '../../lib/activitypub/send' +} from '../../helpers/custom-validators/videos.js' +import { logger } from '../../helpers/logger.js' +import { CONFIG } from '../../initializers/config.js' +import { ACTIVITY_PUB, API_VERSION, CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers/constants.js' +import { sendDeleteVideo } from '../../lib/activitypub/send/index.js' import { MChannel, MChannelAccountDefault, @@ -80,72 +88,72 @@ import { MStreamingPlaylistFilesVideo, MUserAccountId, MUserId, - MVideo, - MVideoAccountLight, - MVideoAccountLightBlacklistAllFiles, MVideoAP, MVideoAPLight, + MVideoAccountLightBlacklistAllFiles, MVideoCaptionLanguageUrl, MVideoDetails, MVideoFileVideo, + MVideoForUser, MVideoFormattable, MVideoFormattableDetails, - MVideoForUser, MVideoFullLight, MVideoId, MVideoImmutable, MVideoThumbnail, MVideoThumbnailBlacklist, MVideoWithAllFiles, - MVideoWithFile -} from '../../types/models' -import { MThumbnail } from '../../types/models/video/thumbnail' -import { MVideoFile, MVideoFileStreamingPlaylistVideo } from '../../types/models/video/video-file' -import { VideoAbuseModel } from '../abuse/video-abuse' -import { AccountModel } from '../account/account' -import { AccountVideoRateModel } from '../account/account-video-rate' -import { ActorModel } from '../actor/actor' -import { ActorImageModel } from '../actor/actor-image' -import { VideoRedundancyModel } from '../redundancy/video-redundancy' -import { ServerModel } from '../server/server' -import { TrackerModel } from '../server/tracker' -import { VideoTrackerModel } from '../server/video-tracker' -import { buildTrigramSearchIndex, buildWhereIdOrUUID, getVideoSort, isOutdated, setAsUpdated, throwIfNotValid } from '../shared' -import { UserModel } from '../user/user' -import { UserVideoHistoryModel } from '../user/user-video-history' -import { VideoViewModel } from '../view/video-view' -import { videoModelToActivityPubObject } from './formatter/video-activity-pub-format' + MVideoWithFile, + type MVideo, + type MVideoAccountLight +} from '../../types/models/index.js' +import { MThumbnail } from '../../types/models/video/thumbnail.js' +import { MVideoFile, MVideoFileStreamingPlaylistVideo } from '../../types/models/video/video-file.js' +import { VideoAbuseModel } from '../abuse/video-abuse.js' +import { AccountVideoRateModel } from '../account/account-video-rate.js' +import { AccountModel } from '../account/account.js' +import { ActorImageModel } from '../actor/actor-image.js' +import { ActorModel } from '../actor/actor.js' +import { VideoRedundancyModel } from '../redundancy/video-redundancy.js' +import { ServerModel } from '../server/server.js' +import { TrackerModel } from '../server/tracker.js' +import { VideoTrackerModel } from '../server/video-tracker.js' +import { buildTrigramSearchIndex, buildWhereIdOrUUID, getVideoSort, isOutdated, setAsUpdated, throwIfNotValid } from '../shared/index.js' +import { UserVideoHistoryModel } from '../user/user-video-history.js' +import { UserModel } from '../user/user.js' +import { VideoViewModel } from '../view/video-view.js' +import { videoModelToActivityPubObject } from './formatter/video-activity-pub-format.js' import { - videoFilesModelToFormattedJSON, VideoFormattingJSONOptions, + videoFilesModelToFormattedJSON, videoModelToFormattedDetailsJSON, videoModelToFormattedJSON -} from './formatter/video-api-format' -import { ScheduleVideoUpdateModel } from './schedule-video-update' +} from './formatter/video-api-format.js' +import { ScheduleVideoUpdateModel } from './schedule-video-update.js' import { BuildVideosListQueryOptions, DisplayOnlyForFollowerOptions, VideoModelGetQueryBuilder, VideosIdListQueryBuilder, VideosModelListQueryBuilder -} from './sql/video' -import { StoryboardModel } from './storyboard' -import { TagModel } from './tag' -import { ThumbnailModel } from './thumbnail' -import { VideoBlacklistModel } from './video-blacklist' -import { VideoCaptionModel } from './video-caption' -import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from './video-channel' -import { VideoCommentModel } from './video-comment' -import { VideoFileModel } from './video-file' -import { VideoImportModel } from './video-import' -import { VideoJobInfoModel } from './video-job-info' -import { VideoLiveModel } from './video-live' -import { VideoPasswordModel } from './video-password' -import { VideoPlaylistElementModel } from './video-playlist-element' -import { VideoShareModel } from './video-share' -import { VideoSourceModel } from './video-source' -import { VideoStreamingPlaylistModel } from './video-streaming-playlist' -import { VideoTagModel } from './video-tag' +} from './sql/video/index.js' +import { StoryboardModel } from './storyboard.js' +import { TagModel } from './tag.js' +import { ThumbnailModel } from './thumbnail.js' +import { VideoBlacklistModel } from './video-blacklist.js' +import { VideoCaptionModel } from './video-caption.js' +import { SummaryOptions, VideoChannelModel, ScopeNames as VideoChannelScopeNames } from './video-channel.js' +import { VideoCommentModel } from './video-comment.js' +import { VideoFileModel } from './video-file.js' +import { VideoImportModel } from './video-import.js' +import { VideoJobInfoModel } from './video-job-info.js' +import { VideoLiveModel } from './video-live.js' +import { VideoPasswordModel } from './video-password.js' +import { VideoPlaylistElementModel } from './video-playlist-element.js' +import { VideoShareModel } from './video-share.js' +import { VideoSourceModel } from './video-source.js' +import { VideoStreamingPlaylistModel } from './video-streaming-playlist.js' +import { VideoTagModel } from './video-tag.js' export enum ScopeNames { FOR_API = 'FOR_API', @@ -468,8 +476,8 @@ export class VideoModel extends Model>> { @AllowNull(false) @Is('VideoPrivacy', value => throwIfNotValid(value, isVideoPrivacyValid, 'privacy')) - @Column - privacy: VideoPrivacy + @Column(DataType.INTEGER) + privacy: VideoPrivacyType @AllowNull(false) @Is('VideoNSFW', value => throwIfNotValid(value, isBooleanValid, 'NSFW boolean')) @@ -544,7 +552,7 @@ export class VideoModel extends Model>> { @Default(null) @Is('VideoState', value => throwIfNotValid(value, isVideoStateValid, 'state')) @Column - state: VideoState + state: VideoStateType // We already have the information in videoSource table for local videos, but we prefer to normalize it for performance // And also to store the info from remote instances @@ -578,21 +586,21 @@ export class VideoModel extends Model>> { }, onDelete: 'cascade' }) - VideoChannel: VideoChannelModel + VideoChannel: Awaited @BelongsToMany(() => TagModel, { foreignKey: 'videoId', through: () => VideoTagModel, onDelete: 'CASCADE' }) - Tags: TagModel[] + Tags: Awaited[] @BelongsToMany(() => TrackerModel, { foreignKey: 'videoId', through: () => VideoTrackerModel, onDelete: 'CASCADE' }) - Trackers: TrackerModel[] + Trackers: Awaited[] @HasMany(() => ThumbnailModel, { foreignKey: { @@ -602,7 +610,7 @@ export class VideoModel extends Model>> { hooks: true, onDelete: 'cascade' }) - Thumbnails: ThumbnailModel[] + Thumbnails: Awaited[] @HasMany(() => VideoPlaylistElementModel, { foreignKey: { @@ -611,7 +619,7 @@ export class VideoModel extends Model>> { }, onDelete: 'set null' }) - VideoPlaylistElements: VideoPlaylistElementModel[] + VideoPlaylistElements: Awaited[] @HasOne(() => VideoSourceModel, { foreignKey: { @@ -620,7 +628,7 @@ export class VideoModel extends Model>> { }, onDelete: 'CASCADE' }) - VideoSource: VideoSourceModel + VideoSource: Awaited @HasMany(() => VideoAbuseModel, { foreignKey: { @@ -629,7 +637,7 @@ export class VideoModel extends Model>> { }, onDelete: 'set null' }) - VideoAbuses: VideoAbuseModel[] + VideoAbuses: Awaited[] @HasMany(() => VideoFileModel, { foreignKey: { @@ -639,7 +647,7 @@ export class VideoModel extends Model>> { hooks: true, onDelete: 'cascade' }) - VideoFiles: VideoFileModel[] + VideoFiles: Awaited[] @HasMany(() => VideoStreamingPlaylistModel, { foreignKey: { @@ -649,7 +657,7 @@ export class VideoModel extends Model>> { hooks: true, onDelete: 'cascade' }) - VideoStreamingPlaylists: VideoStreamingPlaylistModel[] + VideoStreamingPlaylists: Awaited[] @HasMany(() => VideoShareModel, { foreignKey: { @@ -658,7 +666,7 @@ export class VideoModel extends Model>> { }, onDelete: 'cascade' }) - VideoShares: VideoShareModel[] + VideoShares: Awaited[] @HasMany(() => AccountVideoRateModel, { foreignKey: { @@ -667,7 +675,7 @@ export class VideoModel extends Model>> { }, onDelete: 'cascade' }) - AccountVideoRates: AccountVideoRateModel[] + AccountVideoRates: Awaited[] @HasMany(() => VideoCommentModel, { foreignKey: { @@ -677,7 +685,7 @@ export class VideoModel extends Model>> { onDelete: 'cascade', hooks: true }) - VideoComments: VideoCommentModel[] + VideoComments: Awaited[] @HasMany(() => VideoViewModel, { foreignKey: { @@ -686,7 +694,7 @@ export class VideoModel extends Model>> { }, onDelete: 'cascade' }) - VideoViews: VideoViewModel[] + VideoViews: Awaited[] @HasMany(() => UserVideoHistoryModel, { foreignKey: { @@ -695,7 +703,7 @@ export class VideoModel extends Model>> { }, onDelete: 'cascade' }) - UserVideoHistories: UserVideoHistoryModel[] + UserVideoHistories: Awaited[] @HasOne(() => ScheduleVideoUpdateModel, { foreignKey: { @@ -704,7 +712,7 @@ export class VideoModel extends Model>> { }, onDelete: 'cascade' }) - ScheduleVideoUpdate: ScheduleVideoUpdateModel + ScheduleVideoUpdate: Awaited @HasOne(() => VideoBlacklistModel, { foreignKey: { @@ -713,7 +721,7 @@ export class VideoModel extends Model>> { }, onDelete: 'cascade' }) - VideoBlacklist: VideoBlacklistModel + VideoBlacklist: Awaited @HasOne(() => VideoLiveModel, { foreignKey: { @@ -723,7 +731,7 @@ export class VideoModel extends Model>> { hooks: true, onDelete: 'cascade' }) - VideoLive: VideoLiveModel + VideoLive: Awaited @HasOne(() => VideoImportModel, { foreignKey: { @@ -732,7 +740,7 @@ export class VideoModel extends Model>> { }, onDelete: 'set null' }) - VideoImport: VideoImportModel + VideoImport: Awaited @HasMany(() => VideoCaptionModel, { foreignKey: { @@ -743,7 +751,7 @@ export class VideoModel extends Model>> { hooks: true, ['separate' as any]: true }) - VideoCaptions: VideoCaptionModel[] + VideoCaptions: Awaited[] @HasMany(() => VideoPasswordModel, { foreignKey: { @@ -752,7 +760,7 @@ export class VideoModel extends Model>> { }, onDelete: 'cascade' }) - VideoPasswords: VideoPasswordModel[] + VideoPasswords: Awaited[] @HasOne(() => VideoJobInfoModel, { foreignKey: { @@ -761,7 +769,7 @@ export class VideoModel extends Model>> { }, onDelete: 'cascade' }) - VideoJobInfo: VideoJobInfoModel + VideoJobInfo: Awaited @HasOne(() => StoryboardModel, { foreignKey: { @@ -771,7 +779,7 @@ export class VideoModel extends Model>> { onDelete: 'cascade', hooks: true }) - Storyboard: StoryboardModel + Storyboard: Awaited @AfterCreate static notifyCreate (video: MVideo) { @@ -1110,7 +1118,7 @@ export class VideoModel extends Model>> { nsfw: boolean isLive?: boolean isLocal?: boolean - include?: VideoInclude + include?: VideoIncludeType hasFiles?: boolean // default false @@ -1124,7 +1132,7 @@ export class VideoModel extends Model>> { languageOneOf?: string[] tagsOneOf?: string[] tagsAllOf?: string[] - privacyOneOf?: VideoPrivacy[] + privacyOneOf?: VideoPrivacyType[] accountId?: number videoChannelId?: number @@ -1202,14 +1210,14 @@ export class VideoModel extends Model>> { nsfw?: boolean isLive?: boolean isLocal?: boolean - include?: VideoInclude + include?: VideoIncludeType categoryOneOf?: number[] licenceOneOf?: number[] languageOneOf?: string[] tagsOneOf?: string[] tagsAllOf?: string[] - privacyOneOf?: VideoPrivacy[] + privacyOneOf?: VideoPrivacyType[] displayOnlyForFollower: DisplayOnlyForFollowerOptions | null @@ -1637,19 +1645,19 @@ export class VideoModel extends Model>> { } } - private static throwIfPrivateIncludeWithoutUser (include: VideoInclude, user: MUserAccountId) { + private static throwIfPrivateIncludeWithoutUser (include: VideoIncludeType, user: MUserAccountId) { if (VideoModel.isPrivateInclude(include) && !user?.hasRight(UserRight.SEE_ALL_VIDEOS)) { throw new Error('Try to include protected videos but user cannot see all videos') } } - private static throwIfPrivacyOneOfWithoutUser (privacyOneOf: VideoPrivacy[], user: MUserAccountId) { + private static throwIfPrivacyOneOfWithoutUser (privacyOneOf: VideoPrivacyType[], user: MUserAccountId) { if (privacyOneOf && !user?.hasRight(UserRight.SEE_ALL_VIDEOS)) { throw new Error('Try to choose video privacies but user cannot see all videos') } } - private static isPrivateInclude (include: VideoInclude) { + private static isPrivateInclude (include: VideoIncludeType) { return include & VideoInclude.BLACKLISTED || include & VideoInclude.BLOCKED_OWNER || include & VideoInclude.NOT_PUBLISHED_STATE @@ -1975,7 +1983,7 @@ export class VideoModel extends Model>> { return isStateForFederation(this.state) } - isNewVideo (newPrivacy: VideoPrivacy) { + isNewVideo (newPrivacy: VideoPrivacyType) { return this.hasPrivacyForFederation() === false && isPrivacyForFederation(newPrivacy) === true } @@ -2016,7 +2024,7 @@ export class VideoModel extends Model>> { // --------------------------------------------------------------------------- - async setNewState (newState: VideoState, isNewVideo: boolean, transaction: Transaction) { + async setNewState (newState: VideoStateType, isNewVideo: boolean, transaction: Transaction) { if (this.state === newState) throw new Error('Cannot use same state ' + newState) this.state = newState diff --git a/server/models/view/local-video-viewer-watch-section.ts b/server/server/models/view/local-video-viewer-watch-section.ts similarity index 87% rename from server/models/view/local-video-viewer-watch-section.ts rename to server/server/models/view/local-video-viewer-watch-section.ts index e29bb7847..b04dcf4bd 100644 --- a/server/models/view/local-video-viewer-watch-section.ts +++ b/server/server/models/view/local-video-viewer-watch-section.ts @@ -1,8 +1,8 @@ import { Transaction } from 'sequelize' import { AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, Model, Table } from 'sequelize-typescript' -import { MLocalVideoViewerWatchSection } from '@server/types/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { LocalVideoViewerModel } from './local-video-viewer' +import { MLocalVideoViewerWatchSection } from '@server/types/models/index.js' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { LocalVideoViewerModel } from './local-video-viewer.js' @Table({ tableName: 'localVideoViewerWatchSection', @@ -35,7 +35,7 @@ export class LocalVideoViewerWatchSectionModel extends Model static async bulkCreateSections (options: { localVideoViewerId: number diff --git a/server/models/view/local-video-viewer.ts b/server/server/models/view/local-video-viewer.ts similarity index 96% rename from server/models/view/local-video-viewer.ts rename to server/server/models/view/local-video-viewer.ts index c7ac51a03..b3d1ada79 100644 --- a/server/models/view/local-video-viewer.ts +++ b/server/server/models/view/local-video-viewer.ts @@ -1,12 +1,18 @@ import { QueryTypes } from 'sequelize' import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, HasMany, IsUUID, Model, Table } from 'sequelize-typescript' -import { getActivityStreamDuration } from '@server/lib/activitypub/activity' -import { buildGroupByAndBoundaries } from '@server/lib/timeserie' -import { MLocalVideoViewer, MLocalVideoViewerWithWatchSections, MVideo } from '@server/types/models' -import { VideoStatsOverall, VideoStatsRetention, VideoStatsTimeserie, VideoStatsTimeserieMetric, WatchActionObject } from '@shared/models' -import { AttributesOnly } from '@shared/typescript-utils' -import { VideoModel } from '../video/video' -import { LocalVideoViewerWatchSectionModel } from './local-video-viewer-watch-section' +import { getActivityStreamDuration } from '@server/lib/activitypub/activity.js' +import { buildGroupByAndBoundaries } from '@server/lib/timeserie.js' +import { MLocalVideoViewer, MLocalVideoViewerWithWatchSections, MVideo } from '@server/types/models/index.js' +import { + VideoStatsOverall, + VideoStatsRetention, + VideoStatsTimeserie, + VideoStatsTimeserieMetric, + WatchActionObject +} from '@peertube/peertube-models' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { VideoModel } from '../video/video.js' +import { LocalVideoViewerWatchSectionModel } from './local-video-viewer-watch-section.js' /** * @@ -68,7 +74,7 @@ export class LocalVideoViewerModel extends Model @HasMany(() => LocalVideoViewerWatchSectionModel, { foreignKey: { @@ -76,7 +82,7 @@ export class LocalVideoViewerModel extends Model[] static loadByUrl (url: string): Promise { return this.findOne({ diff --git a/server/models/view/video-view.ts b/server/server/models/view/video-view.ts similarity index 89% rename from server/models/view/video-view.ts rename to server/server/models/view/video-view.ts index 1504a364e..a7aaccf26 100644 --- a/server/models/view/video-view.ts +++ b/server/server/models/view/video-view.ts @@ -1,7 +1,7 @@ import { literal, Op } from 'sequelize' import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Model, Table } from 'sequelize-typescript' -import { AttributesOnly } from '@shared/typescript-utils' -import { VideoModel } from '../video/video' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' +import { VideoModel } from '../video/video.js' /** * @@ -48,7 +48,7 @@ export class VideoViewModel extends Model }, onDelete: 'CASCADE' }) - Video: VideoModel + Video: Awaited static removeOldRemoteViewsHistory (beforeDate: string) { const query = { diff --git a/server/static/dnt-policy/dnt-policy-1.0.txt b/server/server/static/dnt-policy/dnt-policy-1.0.txt similarity index 100% rename from server/static/dnt-policy/dnt-policy-1.0.txt rename to server/server/static/dnt-policy/dnt-policy-1.0.txt diff --git a/server/types/activitypub-processor.model.ts b/server/server/types/activitypub-processor.model.ts similarity index 55% rename from server/types/activitypub-processor.model.ts rename to server/server/types/activitypub-processor.model.ts index 7ed3a65b1..0cb429770 100644 --- a/server/types/activitypub-processor.model.ts +++ b/server/server/types/activitypub-processor.model.ts @@ -1,5 +1,5 @@ -import { Activity } from '../../shared/models/activitypub' -import { MActorDefault, MActorSignature } from './models' +import { Activity } from '@peertube/peertube-models' +import { MActorDefault, MActorSignature } from './models/index.js' export type APProcessorOptions = { activity: T diff --git a/server/types/express-handler.ts b/server/server/types/express-handler.ts similarity index 100% rename from server/types/express-handler.ts rename to server/server/types/express-handler.ts diff --git a/server/types/express.d.ts b/server/server/types/express.d.ts similarity index 93% rename from server/types/express.d.ts rename to server/server/types/express.d.ts index 4729c4534..3ead23b40 100644 --- a/server/types/express.d.ts +++ b/server/server/types/express.d.ts @@ -1,6 +1,7 @@ import { OutgoingHttpHeaders } from 'http' import { Writable } from 'stream' -import { RegisterServerAuthExternalOptions } from '@server/types' +import { HttpMethodType, PeerTubeProblemDocumentData, ServerErrorCode, VideoCreate } from '@peertube/peertube-models' +import { RegisterServerAuthExternalOptions } from '@server/types/index.js' import { MAbuseMessage, MAbuseReporter, @@ -21,15 +22,14 @@ import { MVideoPassword, MVideoPlaylistFull, MVideoPlaylistFullSummary -} from '@server/types/models' -import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token' -import { MPlugin, MServer, MServerBlocklist } from '@server/types/models/server' -import { MVideoImportDefault } from '@server/types/models/video/video-import' -import { MVideoPlaylistElement, MVideoPlaylistElementVideoUrlPlaylistPrivacy } from '@server/types/models/video/video-playlist-element' -import { MAccountVideoRateAccountVideo } from '@server/types/models/video/video-rate' -import { HttpMethod, PeerTubeProblemDocumentData, ServerErrorCode, VideoCreate } from '@shared/models' +} from '@server/types/models/index.js' +import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token.js' +import { MPlugin, MServer, MServerBlocklist } from '@server/types/models/server.js' +import { MVideoImportDefault } from '@server/types/models/video/video-import.js' +import { MVideoPlaylistElement, MVideoPlaylistElementVideoUrlPlaylistPrivacy } from '@server/types/models/video/video-playlist-element.js' +import { MAccountVideoRateAccountVideo } from '@server/types/models/video/video-rate.js' import { File as UploadXFile, Metadata } from '@uploadx/core' -import { RegisteredPlugin } from '../../lib/plugins/plugin-manager' +import { RegisteredPlugin } from '../../lib/plugins/plugin-manager.js' import { MAccountDefault, MActorAccountChannelId, @@ -44,14 +44,14 @@ import { MVideoRedundancyVideo, MVideoShareActor, MVideoThumbnail -} from './models' -import { MRunner, MRunnerJobRunner, MRunnerRegistrationToken } from './models/runners' -import { MVideoSource } from './models/video/video-source' +} from './models/index.js' +import { MRunner, MRunnerJobRunner, MRunnerRegistrationToken } from './models/runners/index.js' +import { MVideoSource } from './models/video/video-source.js' declare module 'express' { export interface Request { query: any - method: HttpMethod + method: HttpMethodType } // Upload using multer or uploadx middleware diff --git a/server/server/types/index.ts b/server/server/types/index.ts new file mode 100644 index 000000000..4afef90a8 --- /dev/null +++ b/server/server/types/index.ts @@ -0,0 +1,3 @@ +export * from './plugins/index.js' +export * from './activitypub-processor.model.js' +export * from './sequelize.js' diff --git a/server/types/lib.d.ts b/server/server/types/lib.d.ts similarity index 100% rename from server/types/lib.d.ts rename to server/server/types/lib.d.ts diff --git a/server/types/models/abuse/abuse-message.ts b/server/server/types/models/abuse/abuse-message.ts similarity index 75% rename from server/types/models/abuse/abuse-message.ts rename to server/server/types/models/abuse/abuse-message.ts index 2d7d09316..85ea028d2 100644 --- a/server/types/models/abuse/abuse-message.ts +++ b/server/server/types/models/abuse/abuse-message.ts @@ -1,7 +1,7 @@ -import { AbuseMessageModel } from '@server/models/abuse/abuse-message' -import { PickWith } from '@shared/typescript-utils' -import { AbuseModel } from '../../../models/abuse/abuse' -import { MAccountFormattable } from '../account' +import { AbuseMessageModel } from '@server/models/abuse/abuse-message.js' +import { PickWith } from '@peertube/peertube-typescript-utils' +import { AbuseModel } from '../../../models/abuse/abuse.js' +import { MAccountFormattable } from '../account/index.js' type Use = PickWith diff --git a/server/types/models/abuse/abuse.ts b/server/server/types/models/abuse/abuse.ts similarity index 94% rename from server/types/models/abuse/abuse.ts rename to server/server/types/models/abuse/abuse.ts index 1b45b3879..bf6680470 100644 --- a/server/types/models/abuse/abuse.ts +++ b/server/server/types/models/abuse/abuse.ts @@ -1,11 +1,11 @@ -import { VideoAbuseModel } from '@server/models/abuse/video-abuse' -import { VideoCommentAbuseModel } from '@server/models/abuse/video-comment-abuse' -import { VideoCommentModel } from '@server/models/video/video-comment' -import { PickWith } from '@shared/typescript-utils' -import { AbuseModel } from '../../../models/abuse/abuse' -import { MAccountDefault, MAccountFormattable, MAccountLight, MAccountUrl } from '../account' -import { MComment, MCommentOwner, MCommentUrl, MCommentVideo, MVideoUrl } from '../video' -import { MVideo, MVideoAccountLightBlacklistAllFiles } from '../video/video' +import { VideoAbuseModel } from '@server/models/abuse/video-abuse.js' +import { VideoCommentAbuseModel } from '@server/models/abuse/video-comment-abuse.js' +import { VideoCommentModel } from '@server/models/video/video-comment.js' +import { PickWith } from '@peertube/peertube-typescript-utils' +import { AbuseModel } from '../../../models/abuse/abuse.js' +import { MAccountDefault, MAccountFormattable, MAccountLight, MAccountUrl } from '../account/index.js' +import { MComment, MCommentOwner, MCommentUrl, MCommentVideo, MVideoUrl } from '../video/index.js' +import { MVideo, MVideoAccountLightBlacklistAllFiles } from '../video/video.js' type Use = PickWith type UseVideoAbuse = PickWith diff --git a/server/server/types/models/abuse/index.ts b/server/server/types/models/abuse/index.ts new file mode 100644 index 000000000..fe6b95af3 --- /dev/null +++ b/server/server/types/models/abuse/index.ts @@ -0,0 +1,2 @@ +export * from './abuse.js' +export * from './abuse-message.js' diff --git a/server/types/models/account/account-blocklist.ts b/server/server/types/models/account/account-blocklist.ts similarity index 85% rename from server/types/models/account/account-blocklist.ts rename to server/server/types/models/account/account-blocklist.ts index 9dae10915..d761b2de4 100644 --- a/server/types/models/account/account-blocklist.ts +++ b/server/server/types/models/account/account-blocklist.ts @@ -1,6 +1,6 @@ -import { AccountBlocklistModel } from '../../../models/account/account-blocklist' -import { PickWith } from '@shared/typescript-utils' -import { MAccountDefault, MAccountFormattable } from './account' +import { AccountBlocklistModel } from '../../../models/account/account-blocklist.js' +import { PickWith } from '@peertube/peertube-typescript-utils' +import { MAccountDefault, MAccountFormattable } from './account.js' type Use = PickWith diff --git a/server/types/models/account/account.ts b/server/server/types/models/account/account.ts similarity index 89% rename from server/types/models/account/account.ts rename to server/server/types/models/account/account.ts index d10b904ab..4a5e80725 100644 --- a/server/types/models/account/account.ts +++ b/server/server/types/models/account/account.ts @@ -1,5 +1,5 @@ -import { FunctionProperties, PickWith } from '@shared/typescript-utils' -import { AccountModel } from '../../../models/account/account' +import { FunctionProperties, PickWith } from '@peertube/peertube-typescript-utils' +import { AccountModel } from '../../../models/account/account.js' import { MActor, MActorAPAccount, @@ -13,9 +13,9 @@ import { MActorSummary, MActorSummaryFormattable, MActorUrl -} from '../actor' -import { MChannelDefault } from '../video/video-channels' -import { MAccountBlocklistId } from './account-blocklist' +} from '../actor/index.js' +import { MChannelDefault } from '../video/video-channels.js' +import { MAccountBlocklistId } from './account-blocklist.js' type Use = PickWith diff --git a/server/types/models/account/actor-custom-page.ts b/server/server/types/models/account/actor-custom-page.ts similarity index 86% rename from server/types/models/account/actor-custom-page.ts rename to server/server/types/models/account/actor-custom-page.ts index fcd8069be..de2cfd41e 100644 --- a/server/types/models/account/actor-custom-page.ts +++ b/server/server/types/models/account/actor-custom-page.ts @@ -1,3 +1,3 @@ -import { ActorCustomPageModel } from '../../../models/account/actor-custom-page' +import { ActorCustomPageModel } from '../../../models/account/actor-custom-page.js' export type MActorCustomPage = Omit diff --git a/server/server/types/models/account/index.ts b/server/server/types/models/account/index.ts new file mode 100644 index 000000000..e00026a6f --- /dev/null +++ b/server/server/types/models/account/index.ts @@ -0,0 +1,3 @@ +export * from './account.js' +export * from './actor-custom-page.js' +export * from './account-blocklist.js' diff --git a/server/types/models/actor/actor-follow.ts b/server/server/types/models/actor/actor-follow.ts similarity index 95% rename from server/types/models/actor/actor-follow.ts rename to server/server/types/models/actor/actor-follow.ts index 84042e228..a130751f9 100644 --- a/server/types/models/actor/actor-follow.ts +++ b/server/server/types/models/actor/actor-follow.ts @@ -1,5 +1,5 @@ -import { PickWith } from '@shared/typescript-utils' -import { ActorFollowModel } from '../../../models/actor/actor-follow' +import { PickWith } from '@peertube/peertube-typescript-utils' +import { ActorFollowModel } from '../../../models/actor/actor-follow.js' import { MActor, MActorChannelAccountActor, @@ -9,7 +9,7 @@ import { MActorFormattable, MActorHostOnly, MActorUsername -} from './actor' +} from './actor.js' type Use = PickWith diff --git a/server/types/models/actor/actor-image.ts b/server/server/types/models/actor/actor-image.ts similarity index 81% rename from server/types/models/actor/actor-image.ts rename to server/server/types/models/actor/actor-image.ts index e8f32b71e..de8a62216 100644 --- a/server/types/models/actor/actor-image.ts +++ b/server/server/types/models/actor/actor-image.ts @@ -1,5 +1,5 @@ -import { FunctionProperties } from '@shared/typescript-utils' -import { ActorImageModel } from '../../../models/actor/actor-image' +import { FunctionProperties } from '@peertube/peertube-typescript-utils' +import { ActorImageModel } from '../../../models/actor/actor-image.js' export type MActorImage = ActorImageModel diff --git a/server/types/models/actor/actor.ts b/server/server/types/models/actor/actor.ts similarity index 94% rename from server/types/models/actor/actor.ts rename to server/server/types/models/actor/actor.ts index 47e7b7091..0d594545f 100644 --- a/server/types/models/actor/actor.ts +++ b/server/server/types/models/actor/actor.ts @@ -1,9 +1,9 @@ -import { FunctionProperties, PickWith, PickWithOpt } from '@shared/typescript-utils' -import { ActorModel } from '../../../models/actor/actor' -import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from '../account' -import { MServer, MServerHost, MServerHostBlocks, MServerRedundancyAllowed } from '../server' -import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video' -import { MActorImage, MActorImageFormattable } from './actor-image' +import { FunctionProperties, PickWith, PickWithOpt } from '@peertube/peertube-typescript-utils' +import { ActorModel } from '../../../models/actor/actor.js' +import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from '../account/index.js' +import { MServer, MServerHost, MServerHostBlocks, MServerRedundancyAllowed } from '../server/index.js' +import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video/index.js' +import { MActorImage, MActorImageFormattable } from './actor-image.js' type Use = PickWith type UseOpt = PickWithOpt diff --git a/server/server/types/models/actor/index.ts b/server/server/types/models/actor/index.ts new file mode 100644 index 000000000..f7724f54a --- /dev/null +++ b/server/server/types/models/actor/index.ts @@ -0,0 +1,3 @@ +export * from './actor-follow.js' +export * from './actor-image.js' +export * from './actor.js' diff --git a/server/types/models/application/application.ts b/server/server/types/models/application/application.ts similarity index 94% rename from server/types/models/application/application.ts rename to server/server/types/models/application/application.ts index 9afb9ad70..bffd6d718 100644 --- a/server/types/models/application/application.ts +++ b/server/server/types/models/application/application.ts @@ -1,4 +1,4 @@ -import { ApplicationModel } from '@server/models/application/application' +import { ApplicationModel } from '@server/models/application/application.js' // ############################################################################ diff --git a/server/server/types/models/application/index.ts b/server/server/types/models/application/index.ts new file mode 100644 index 000000000..fbbab9760 --- /dev/null +++ b/server/server/types/models/application/index.ts @@ -0,0 +1 @@ +export * from './application.js' diff --git a/server/server/types/models/index.ts b/server/server/types/models/index.ts new file mode 100644 index 000000000..8c90db53c --- /dev/null +++ b/server/server/types/models/index.ts @@ -0,0 +1,8 @@ +export * from './abuse/index.js' +export * from './account/index.js' +export * from './actor/index.js' +export * from './application/index.js' +export * from './oauth/index.js' +export * from './server/index.js' +export * from './user/index.js' +export * from './video/index.js' diff --git a/server/server/types/models/oauth/index.ts b/server/server/types/models/oauth/index.ts new file mode 100644 index 000000000..c9bbaa53d --- /dev/null +++ b/server/server/types/models/oauth/index.ts @@ -0,0 +1,2 @@ +export * from './oauth-client.js' +export * from './oauth-token.js' diff --git a/server/types/models/oauth/oauth-client.ts b/server/server/types/models/oauth/oauth-client.ts similarity index 94% rename from server/types/models/oauth/oauth-client.ts rename to server/server/types/models/oauth/oauth-client.ts index 904a07863..589a69d16 100644 --- a/server/types/models/oauth/oauth-client.ts +++ b/server/server/types/models/oauth/oauth-client.ts @@ -1,3 +1,3 @@ -import { OAuthClientModel } from '@server/models/oauth/oauth-client' +import { OAuthClientModel } from '@server/models/oauth/oauth-client.js' export type MOAuthClient = Omit diff --git a/server/types/models/oauth/oauth-token.ts b/server/server/types/models/oauth/oauth-token.ts similarity index 77% rename from server/types/models/oauth/oauth-token.ts rename to server/server/types/models/oauth/oauth-token.ts index 6af087e3c..cf4412938 100644 --- a/server/types/models/oauth/oauth-token.ts +++ b/server/server/types/models/oauth/oauth-token.ts @@ -1,6 +1,6 @@ -import { OAuthTokenModel } from '@server/models/oauth/oauth-token' -import { PickWith } from '@shared/typescript-utils' -import { MUserAccountUrl } from '../user/user' +import { OAuthTokenModel } from '@server/models/oauth/oauth-token.js' +import { PickWith } from '@peertube/peertube-typescript-utils' +import { MUserAccountUrl } from '../user/user.js' type Use = PickWith diff --git a/server/server/types/models/runners/index.ts b/server/server/types/models/runners/index.ts new file mode 100644 index 000000000..94f33a47a --- /dev/null +++ b/server/server/types/models/runners/index.ts @@ -0,0 +1,3 @@ +export * from './runner.js' +export * from './runner-job.js' +export * from './runner-registration-token.js' diff --git a/server/types/models/runners/runner-job.ts b/server/server/types/models/runners/runner-job.ts similarity index 84% rename from server/types/models/runners/runner-job.ts rename to server/server/types/models/runners/runner-job.ts index ec983ba32..4fa024f57 100644 --- a/server/types/models/runners/runner-job.ts +++ b/server/server/types/models/runners/runner-job.ts @@ -1,6 +1,6 @@ -import { RunnerJobModel } from '@server/models/runner/runner-job' -import { PickWith } from '@shared/typescript-utils' -import { MRunner } from './runner' +import { RunnerJobModel } from '@server/models/runner/runner-job.js' +import { PickWith } from '@peertube/peertube-typescript-utils' +import { MRunner } from './runner.js' type Use = PickWith diff --git a/server/types/models/runners/runner-registration-token.ts b/server/server/types/models/runners/runner-registration-token.ts similarity index 87% rename from server/types/models/runners/runner-registration-token.ts rename to server/server/types/models/runners/runner-registration-token.ts index 83b8614ad..5dd18a338 100644 --- a/server/types/models/runners/runner-registration-token.ts +++ b/server/server/types/models/runners/runner-registration-token.ts @@ -1,4 +1,4 @@ -import { RunnerRegistrationTokenModel } from '@server/models/runner/runner-registration-token' +import { RunnerRegistrationTokenModel } from '@server/models/runner/runner-registration-token.js' // ############################################################################ diff --git a/server/types/models/runners/runner.ts b/server/server/types/models/runners/runner.ts similarity index 70% rename from server/types/models/runners/runner.ts rename to server/server/types/models/runners/runner.ts index d35356378..bde83145e 100644 --- a/server/types/models/runners/runner.ts +++ b/server/server/types/models/runners/runner.ts @@ -1,4 +1,4 @@ -import { RunnerModel } from '@server/models/runner/runner' +import { RunnerModel } from '@server/models/runner/runner.js' // ############################################################################ diff --git a/server/server/types/models/server/index.ts b/server/server/types/models/server/index.ts new file mode 100644 index 000000000..ed5482b70 --- /dev/null +++ b/server/server/types/models/server/index.ts @@ -0,0 +1,3 @@ +export * from './plugin.js' +export * from './server.js' +export * from './server-blocklist.js' diff --git a/server/types/models/server/plugin.ts b/server/server/types/models/server/plugin.ts similarity index 85% rename from server/types/models/server/plugin.ts rename to server/server/types/models/server/plugin.ts index 83eb83794..0d5a8fb02 100644 --- a/server/types/models/server/plugin.ts +++ b/server/server/types/models/server/plugin.ts @@ -1,4 +1,4 @@ -import { PluginModel } from '@server/models/server/plugin' +import { PluginModel } from '@server/models/server/plugin.js' export type MPlugin = PluginModel diff --git a/server/types/models/server/server-blocklist.ts b/server/server/types/models/server/server-blocklist.ts similarity index 85% rename from server/types/models/server/server-blocklist.ts rename to server/server/types/models/server/server-blocklist.ts index 71a4ea963..e944e7328 100644 --- a/server/types/models/server/server-blocklist.ts +++ b/server/server/types/models/server/server-blocklist.ts @@ -1,7 +1,7 @@ -import { ServerBlocklistModel } from '@server/models/server/server-blocklist' -import { PickWith } from '@shared/typescript-utils' -import { MAccountDefault, MAccountFormattable } from '../account/account' -import { MServer, MServerFormattable } from './server' +import { ServerBlocklistModel } from '@server/models/server/server-blocklist.js' +import { PickWith } from '@peertube/peertube-typescript-utils' +import { MAccountDefault, MAccountFormattable } from '../account/account.js' +import { MServer, MServerFormattable } from './server.js' type Use = PickWith diff --git a/server/types/models/server/server.ts b/server/server/types/models/server/server.ts similarity index 78% rename from server/types/models/server/server.ts rename to server/server/types/models/server/server.ts index 0b16186cd..fe3d362b5 100644 --- a/server/types/models/server/server.ts +++ b/server/server/types/models/server/server.ts @@ -1,6 +1,6 @@ -import { FunctionProperties, PickWith } from '@shared/typescript-utils' -import { ServerModel } from '../../../models/server/server' -import { MAccountBlocklistId } from '../account' +import { FunctionProperties, PickWith } from '@peertube/peertube-typescript-utils' +import { ServerModel } from '../../../models/server/server.js' +import { MAccountBlocklistId } from '../account/index.js' type Use = PickWith diff --git a/server/types/models/server/tracker.ts b/server/server/types/models/server/tracker.ts similarity index 73% rename from server/types/models/server/tracker.ts rename to server/server/types/models/server/tracker.ts index 5fe03f8c0..adcd3f435 100644 --- a/server/types/models/server/tracker.ts +++ b/server/server/types/models/server/tracker.ts @@ -1,4 +1,4 @@ -import { TrackerModel } from '../../../models/server/tracker' +import { TrackerModel } from '../../../models/server/tracker.js' export type MTracker = Omit diff --git a/server/server/types/models/user/index.ts b/server/server/types/models/user/index.ts new file mode 100644 index 000000000..53db3944d --- /dev/null +++ b/server/server/types/models/user/index.ts @@ -0,0 +1,5 @@ +export * from './user.js' +export * from './user-notification.js' +export * from './user-notification-setting.js' +export * from './user-registration.js' +export * from './user-video-history.js' diff --git a/server/types/models/user/user-notification-setting.ts b/server/server/types/models/user/user-notification-setting.ts similarity index 91% rename from server/types/models/user/user-notification-setting.ts rename to server/server/types/models/user/user-notification-setting.ts index d1db645e7..61f93b6fa 100644 --- a/server/types/models/user/user-notification-setting.ts +++ b/server/server/types/models/user/user-notification-setting.ts @@ -1,4 +1,4 @@ -import { UserNotificationSettingModel } from '@server/models/user/user-notification-setting' +import { UserNotificationSettingModel } from '@server/models/user/user-notification-setting.js' export type MNotificationSetting = Omit diff --git a/server/types/models/user/user-notification.ts b/server/server/types/models/user/user-notification.ts similarity index 89% rename from server/types/models/user/user-notification.ts rename to server/server/types/models/user/user-notification.ts index a732c8aa9..5a0b57e7a 100644 --- a/server/types/models/user/user-notification.ts +++ b/server/server/types/models/user/user-notification.ts @@ -1,21 +1,21 @@ -import { VideoAbuseModel } from '@server/models/abuse/video-abuse' -import { VideoCommentAbuseModel } from '@server/models/abuse/video-comment-abuse' -import { ApplicationModel } from '@server/models/application/application' -import { PluginModel } from '@server/models/server/plugin' -import { UserNotificationModel } from '@server/models/user/user-notification' -import { UserRegistrationModel } from '@server/models/user/user-registration' -import { PickWith, PickWithOpt } from '@shared/typescript-utils' -import { AbuseModel } from '../../../models/abuse/abuse' -import { AccountModel } from '../../../models/account/account' -import { ActorModel } from '../../../models/actor/actor' -import { ActorFollowModel } from '../../../models/actor/actor-follow' -import { ActorImageModel } from '../../../models/actor/actor-image' -import { ServerModel } from '../../../models/server/server' -import { VideoModel } from '../../../models/video/video' -import { VideoBlacklistModel } from '../../../models/video/video-blacklist' -import { VideoChannelModel } from '../../../models/video/video-channel' -import { VideoCommentModel } from '../../../models/video/video-comment' -import { VideoImportModel } from '../../../models/video/video-import' +import { VideoAbuseModel } from '@server/models/abuse/video-abuse.js' +import { VideoCommentAbuseModel } from '@server/models/abuse/video-comment-abuse.js' +import { ApplicationModel } from '@server/models/application/application.js' +import { PluginModel } from '@server/models/server/plugin.js' +import { UserNotificationModel } from '@server/models/user/user-notification.js' +import { UserRegistrationModel } from '@server/models/user/user-registration.js' +import { PickWith, PickWithOpt } from '@peertube/peertube-typescript-utils' +import { AbuseModel } from '../../../models/abuse/abuse.js' +import { AccountModel } from '../../../models/account/account.js' +import { ActorModel } from '../../../models/actor/actor.js' +import { ActorFollowModel } from '../../../models/actor/actor-follow.js' +import { ActorImageModel } from '../../../models/actor/actor-image.js' +import { ServerModel } from '../../../models/server/server.js' +import { VideoModel } from '../../../models/video/video.js' +import { VideoBlacklistModel } from '../../../models/video/video-blacklist.js' +import { VideoChannelModel } from '../../../models/video/video-channel.js' +import { VideoCommentModel } from '../../../models/video/video-comment.js' +import { VideoImportModel } from '../../../models/video/video-import.js' type Use = PickWith diff --git a/server/types/models/user/user-registration.ts b/server/server/types/models/user/user-registration.ts similarity index 80% rename from server/types/models/user/user-registration.ts rename to server/server/types/models/user/user-registration.ts index 216423cc9..bcbe52fbd 100644 --- a/server/types/models/user/user-registration.ts +++ b/server/server/types/models/user/user-registration.ts @@ -1,6 +1,6 @@ -import { UserRegistrationModel } from '@server/models/user/user-registration' -import { PickWith } from '@shared/typescript-utils' -import { MUserId } from './user' +import { UserRegistrationModel } from '@server/models/user/user-registration.js' +import { PickWith } from '@peertube/peertube-typescript-utils' +import { MUserId } from './user.js' type Use = PickWith diff --git a/server/types/models/user/user-video-history.ts b/server/server/types/models/user/user-video-history.ts similarity index 92% rename from server/types/models/user/user-video-history.ts rename to server/server/types/models/user/user-video-history.ts index 34e2930e7..d61742070 100644 --- a/server/types/models/user/user-video-history.ts +++ b/server/server/types/models/user/user-video-history.ts @@ -1,4 +1,4 @@ -import { UserVideoHistoryModel } from '../../../models/user/user-video-history' +import { UserVideoHistoryModel } from '../../../models/user/user-video-history.js' export type MUserVideoHistory = Omit diff --git a/server/types/models/user/user.ts b/server/server/types/models/user/user.ts similarity index 85% rename from server/types/models/user/user.ts rename to server/server/types/models/user/user.ts index 89092c242..4a655c792 100644 --- a/server/types/models/user/user.ts +++ b/server/server/types/models/user/user.ts @@ -1,7 +1,7 @@ -import { AccountModel } from '@server/models/account/account' -import { UserModel } from '@server/models/user/user' -import { MVideoPlaylist } from '@server/types/models' -import { PickWith, PickWithOpt } from '@shared/typescript-utils' +import { AccountModel } from '@server/models/account/account.js' +import { UserModel } from '@server/models/user/user.js' +import { MVideoPlaylist } from '@server/types/models/index.js' +import { PickWith, PickWithOpt } from '@peertube/peertube-typescript-utils' import { MAccount, MAccountDefault, @@ -10,9 +10,9 @@ import { MAccountId, MAccountIdActorId, MAccountUrl -} from '../account' -import { MChannelFormattable } from '../video/video-channels' -import { MNotificationSetting, MNotificationSettingFormattable } from './user-notification-setting' +} from '../account/index.js' +import { MChannelFormattable } from '../video/video-channels.js' +import { MNotificationSetting, MNotificationSettingFormattable } from './user-notification-setting.js' type Use = PickWith diff --git a/server/server/types/models/video/index.ts b/server/server/types/models/video/index.ts new file mode 100644 index 000000000..f88198b67 --- /dev/null +++ b/server/server/types/models/video/index.ts @@ -0,0 +1,26 @@ +export * from './local-video-viewer-watch-section.js' +export * from './local-video-viewer-watch-section.js' +export * from './local-video-viewer.js' +export * from './storyboard.js' +export * from './schedule-video-update.js' +export * from './tag.js' +export * from './thumbnail.js' +export * from './video.js' +export * from './video-blacklist.js' +export * from './video-caption.js' +export * from './video-change-ownership.js' +export * from './video-channel-sync.js' +export * from './video-channels.js' +export * from './video-comment.js' +export * from './video-file.js' +export * from './video-import.js' +export * from './video-live-replay-setting.js' +export * from './video-live-session.js' +export * from './video-live.js' +export * from './video-password.js' +export * from './video-playlist.js' +export * from './video-playlist-element.js' +export * from './video-rate.js' +export * from './video-redundancy.js' +export * from './video-share.js' +export * from './video-streaming-playlist.js' diff --git a/server/types/models/video/local-video-viewer-watch-section.ts b/server/server/types/models/video/local-video-viewer-watch-section.ts similarity index 85% rename from server/types/models/video/local-video-viewer-watch-section.ts rename to server/server/types/models/video/local-video-viewer-watch-section.ts index be7a3bba0..c621dd1cc 100644 --- a/server/types/models/video/local-video-viewer-watch-section.ts +++ b/server/server/types/models/video/local-video-viewer-watch-section.ts @@ -1,4 +1,4 @@ -import { LocalVideoViewerWatchSectionModel } from '@server/models/view/local-video-viewer-watch-section' +import { LocalVideoViewerWatchSectionModel } from '@server/models/view/local-video-viewer-watch-section.js' // ############################################################################ diff --git a/server/types/models/video/local-video-viewer.ts b/server/server/types/models/video/local-video-viewer.ts similarity index 81% rename from server/types/models/video/local-video-viewer.ts rename to server/server/types/models/video/local-video-viewer.ts index b78ef5507..90535dac0 100644 --- a/server/types/models/video/local-video-viewer.ts +++ b/server/server/types/models/video/local-video-viewer.ts @@ -1,7 +1,7 @@ -import { LocalVideoViewerModel } from '@server/models/view/local-video-viewer' -import { PickWith } from '@shared/typescript-utils' -import { MLocalVideoViewerWatchSection } from './local-video-viewer-watch-section' -import { MVideo } from './video' +import { LocalVideoViewerModel } from '@server/models/view/local-video-viewer.js' +import { PickWith } from '@peertube/peertube-typescript-utils' +import { MLocalVideoViewerWatchSection } from './local-video-viewer-watch-section.js' +import { MVideo } from './video.js' type Use = PickWith diff --git a/server/types/models/video/schedule-video-update.ts b/server/server/types/models/video/schedule-video-update.ts similarity index 94% rename from server/types/models/video/schedule-video-update.ts rename to server/server/types/models/video/schedule-video-update.ts index 39fd73501..7bf998b49 100644 --- a/server/types/models/video/schedule-video-update.ts +++ b/server/server/types/models/video/schedule-video-update.ts @@ -1,4 +1,4 @@ -import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' +import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update.js' // ############################################################################ diff --git a/server/types/models/video/storyboard.ts b/server/server/types/models/video/storyboard.ts similarity index 80% rename from server/types/models/video/storyboard.ts rename to server/server/types/models/video/storyboard.ts index a0403d4f0..d8a0e39ea 100644 --- a/server/types/models/video/storyboard.ts +++ b/server/server/types/models/video/storyboard.ts @@ -1,6 +1,6 @@ -import { StoryboardModel } from '@server/models/video/storyboard' -import { PickWith } from '@shared/typescript-utils' -import { MVideo } from './video' +import { StoryboardModel } from '@server/models/video/storyboard.js' +import { PickWith } from '@peertube/peertube-typescript-utils' +import { MVideo } from './video.js' type Use = PickWith diff --git a/server/server/types/models/video/tag.ts b/server/server/types/models/video/tag.ts new file mode 100644 index 000000000..23fdf89e0 --- /dev/null +++ b/server/server/types/models/video/tag.ts @@ -0,0 +1,3 @@ +import { TagModel } from '../../../models/video/tag.js' + +export type MTag = Omit diff --git a/server/types/models/video/thumbnail.ts b/server/server/types/models/video/thumbnail.ts similarity index 69% rename from server/types/models/video/thumbnail.ts rename to server/server/types/models/video/thumbnail.ts index c3b27681f..b952c06a0 100644 --- a/server/types/models/video/thumbnail.ts +++ b/server/server/types/models/video/thumbnail.ts @@ -1,6 +1,6 @@ -import { PickWith } from '@shared/typescript-utils' -import { ThumbnailModel } from '../../../models/video/thumbnail' -import { MVideo } from './video' +import { PickWith } from '@peertube/peertube-typescript-utils' +import { ThumbnailModel } from '../../../models/video/thumbnail.js' +import { MVideo } from './video.js' type Use = PickWith diff --git a/server/types/models/video/video-blacklist.ts b/server/server/types/models/video/video-blacklist.ts similarity index 87% rename from server/types/models/video/video-blacklist.ts rename to server/server/types/models/video/video-blacklist.ts index 048b63bd2..b202e9261 100644 --- a/server/types/models/video/video-blacklist.ts +++ b/server/server/types/models/video/video-blacklist.ts @@ -1,6 +1,6 @@ -import { PickWith } from '@shared/typescript-utils' -import { VideoBlacklistModel } from '../../../models/video/video-blacklist' -import { MVideo, MVideoFormattable } from './video' +import { PickWith } from '@peertube/peertube-typescript-utils' +import { VideoBlacklistModel } from '../../../models/video/video-blacklist.js' +import { MVideo, MVideoFormattable } from './video.js' type Use = PickWith diff --git a/server/types/models/video/video-caption.ts b/server/server/types/models/video/video-caption.ts similarity index 88% rename from server/types/models/video/video-caption.ts rename to server/server/types/models/video/video-caption.ts index d3adec362..8e8393d92 100644 --- a/server/types/models/video/video-caption.ts +++ b/server/server/types/models/video/video-caption.ts @@ -1,6 +1,6 @@ -import { PickWith } from '@shared/typescript-utils' -import { VideoCaptionModel } from '../../../models/video/video-caption' -import { MVideo, MVideoUUID } from './video' +import { PickWith } from '@peertube/peertube-typescript-utils' +import { VideoCaptionModel } from '../../../models/video/video-caption.js' +import { MVideo, MVideoUUID } from './video.js' type Use = PickWith diff --git a/server/types/models/video/video-change-ownership.ts b/server/server/types/models/video/video-change-ownership.ts similarity index 84% rename from server/types/models/video/video-change-ownership.ts rename to server/server/types/models/video/video-change-ownership.ts index d99f25071..70753e30b 100644 --- a/server/types/models/video/video-change-ownership.ts +++ b/server/server/types/models/video/video-change-ownership.ts @@ -1,7 +1,7 @@ -import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership' -import { PickWith } from '@shared/typescript-utils' -import { MAccountDefault, MAccountFormattable } from '../account/account' -import { MVideoFormattable, MVideoWithAllFiles } from './video' +import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership.js' +import { PickWith } from '@peertube/peertube-typescript-utils' +import { MAccountDefault, MAccountFormattable } from '../account/account.js' +import { MVideoFormattable, MVideoWithAllFiles } from './video.js' type Use = PickWith diff --git a/server/types/models/video/video-channel-sync.ts b/server/server/types/models/video/video-channel-sync.ts similarity index 82% rename from server/types/models/video/video-channel-sync.ts rename to server/server/types/models/video/video-channel-sync.ts index 429ab70b0..2b3a3930f 100644 --- a/server/types/models/video/video-channel-sync.ts +++ b/server/server/types/models/video/video-channel-sync.ts @@ -1,6 +1,6 @@ -import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync' -import { FunctionProperties, PickWith } from '@shared/typescript-utils' -import { MChannelAccountDefault, MChannelFormattable } from './video-channels' +import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync.js' +import { FunctionProperties, PickWith } from '@peertube/peertube-typescript-utils' +import { MChannelAccountDefault, MChannelFormattable } from './video-channels.js' type Use = PickWith diff --git a/server/types/models/video/video-channels.ts b/server/server/types/models/video/video-channels.ts similarity index 94% rename from server/types/models/video/video-channels.ts rename to server/server/types/models/video/video-channels.ts index 57e991494..e8cb9cb26 100644 --- a/server/types/models/video/video-channels.ts +++ b/server/server/types/models/video/video-channels.ts @@ -1,5 +1,5 @@ -import { FunctionProperties, PickWith, PickWithOpt } from '@shared/typescript-utils' -import { VideoChannelModel } from '../../../models/video/video-channel' +import { FunctionProperties, PickWith, PickWithOpt } from '@peertube/peertube-typescript-utils' +import { VideoChannelModel } from '../../../models/video/video-channel.js' import { MAccountActor, MAccountAPI, @@ -10,7 +10,7 @@ import { MAccountSummaryFormattable, MAccountUrl, MAccountUserId -} from '../account' +} from '../account/index.js' import { MActor, MActorAccountChannelId, @@ -26,8 +26,8 @@ import { MActorSummary, MActorSummaryFormattable, MActorUrl -} from '../actor' -import { MVideo } from './video' +} from '../actor/index.js' +import { MVideo } from './video.js' type Use = PickWith diff --git a/server/types/models/video/video-comment.ts b/server/server/types/models/video/video-comment.ts similarity index 93% rename from server/types/models/video/video-comment.ts rename to server/server/types/models/video/video-comment.ts index b66de064f..d4fd34f7c 100644 --- a/server/types/models/video/video-comment.ts +++ b/server/server/types/models/video/video-comment.ts @@ -1,7 +1,7 @@ -import { PickWith, PickWithOpt } from '@shared/typescript-utils' -import { VideoCommentModel } from '../../../models/video/video-comment' -import { MAccountDefault, MAccountFormattable, MAccountUrl } from '../account' -import { MVideo, MVideoAccountLight, MVideoFeed, MVideoIdUrl, MVideoUrl } from './video' +import { PickWith, PickWithOpt } from '@peertube/peertube-typescript-utils' +import { VideoCommentModel } from '../../../models/video/video-comment.js' +import { MAccountDefault, MAccountFormattable, MAccountUrl } from '../account/index.js' +import { MVideo, MVideoAccountLight, MVideoFeed, MVideoIdUrl, MVideoUrl } from './video.js' type Use = PickWith diff --git a/server/types/models/video/video-file.ts b/server/server/types/models/video/video-file.ts similarity index 88% rename from server/types/models/video/video-file.ts rename to server/server/types/models/video/video-file.ts index 68106788d..8431b6f5a 100644 --- a/server/types/models/video/video-file.ts +++ b/server/server/types/models/video/video-file.ts @@ -1,8 +1,8 @@ -import { PickWith, PickWithOpt } from '@shared/typescript-utils' -import { VideoFileModel } from '../../../models/video/video-file' -import { MVideo, MVideoUUID } from './video' -import { MVideoRedundancy, MVideoRedundancyFileUrl } from './video-redundancy' -import { MStreamingPlaylist, MStreamingPlaylistVideo } from './video-streaming-playlist' +import { PickWith, PickWithOpt } from '@peertube/peertube-typescript-utils' +import { VideoFileModel } from '../../../models/video/video-file.js' +import { MVideo, MVideoUUID } from './video.js' +import { MVideoRedundancy, MVideoRedundancyFileUrl } from './video-redundancy.js' +import { MStreamingPlaylist, MStreamingPlaylistVideo } from './video-streaming-playlist.js' type Use = PickWith diff --git a/server/types/models/video/video-import.ts b/server/server/types/models/video/video-import.ts similarity index 85% rename from server/types/models/video/video-import.ts rename to server/server/types/models/video/video-import.ts index 650c293f7..4920dfac3 100644 --- a/server/types/models/video/video-import.ts +++ b/server/server/types/models/video/video-import.ts @@ -1,7 +1,7 @@ -import { VideoImportModel } from '@server/models/video/video-import' -import { PickWith, PickWithOpt } from '@shared/typescript-utils' -import { MUser } from '../user/user' -import { MVideo, MVideoAccountLight, MVideoFormattable, MVideoTag, MVideoThumbnail, MVideoWithFile } from './video' +import { VideoImportModel } from '@server/models/video/video-import.js' +import { PickWith, PickWithOpt } from '@peertube/peertube-typescript-utils' +import { MUser } from '../user/user.js' +import { MVideo, MVideoAccountLight, MVideoFormattable, MVideoTag, MVideoThumbnail, MVideoWithFile } from './video.js' type Use = PickWith diff --git a/server/types/models/video/video-live-replay-setting.ts b/server/server/types/models/video/video-live-replay-setting.ts similarity index 83% rename from server/types/models/video/video-live-replay-setting.ts rename to server/server/types/models/video/video-live-replay-setting.ts index c5a5adf54..a7e1be8e4 100644 --- a/server/types/models/video/video-live-replay-setting.ts +++ b/server/server/types/models/video/video-live-replay-setting.ts @@ -1,3 +1,3 @@ -import { VideoLiveReplaySettingModel } from '@server/models/video/video-live-replay-setting' +import { VideoLiveReplaySettingModel } from '@server/models/video/video-live-replay-setting.js' export type MLiveReplaySetting = Omit diff --git a/server/types/models/video/video-live-session.ts b/server/server/types/models/video/video-live-session.ts similarity index 74% rename from server/types/models/video/video-live-session.ts rename to server/server/types/models/video/video-live-session.ts index 852e2c24b..994726244 100644 --- a/server/types/models/video/video-live-session.ts +++ b/server/server/types/models/video/video-live-session.ts @@ -1,7 +1,7 @@ -import { VideoLiveSessionModel } from '@server/models/video/video-live-session' -import { PickWith } from '@shared/typescript-utils' -import { MVideo } from './video' -import { MLiveReplaySetting } from './video-live-replay-setting' +import { VideoLiveSessionModel } from '@server/models/video/video-live-session.js' +import { PickWith } from '@peertube/peertube-typescript-utils' +import { MVideo } from './video.js' +import { MLiveReplaySetting } from './video-live-replay-setting.js' type Use = PickWith diff --git a/server/types/models/video/video-live.ts b/server/server/types/models/video/video-live.ts similarity index 70% rename from server/types/models/video/video-live.ts rename to server/server/types/models/video/video-live.ts index a899edfa6..6a3ca8f49 100644 --- a/server/types/models/video/video-live.ts +++ b/server/server/types/models/video/video-live.ts @@ -1,7 +1,7 @@ -import { VideoLiveModel } from '@server/models/video/video-live' -import { PickWith } from '@shared/typescript-utils' -import { MVideo } from './video' -import { MLiveReplaySetting } from './video-live-replay-setting' +import { VideoLiveModel } from '@server/models/video/video-live.js' +import { PickWith } from '@peertube/peertube-typescript-utils' +import { MVideo } from './video.js' +import { MLiveReplaySetting } from './video-live-replay-setting.js' type Use = PickWith diff --git a/server/types/models/video/video-password.ts b/server/server/types/models/video/video-password.ts similarity index 91% rename from server/types/models/video/video-password.ts rename to server/server/types/models/video/video-password.ts index 313cc3e0c..6e0e1a5e7 100644 --- a/server/types/models/video/video-password.ts +++ b/server/server/types/models/video/video-password.ts @@ -1,3 +1,3 @@ -import { VideoPasswordModel } from '@server/models/video/video-password' +import { VideoPasswordModel } from '@server/models/video/video-password.js' export type MVideoPassword = Omit diff --git a/server/types/models/video/video-playlist-element.ts b/server/server/types/models/video/video-playlist-element.ts similarity index 89% rename from server/types/models/video/video-playlist-element.ts rename to server/server/types/models/video/video-playlist-element.ts index eae676096..bf8ff6daf 100644 --- a/server/types/models/video/video-playlist-element.ts +++ b/server/server/types/models/video/video-playlist-element.ts @@ -1,7 +1,7 @@ -import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element' -import { PickWith } from '@shared/typescript-utils' -import { MVideoFormattable, MVideoThumbnail, MVideoUrl } from './video' -import { MVideoPlaylistPrivacy } from './video-playlist' +import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element.js' +import { PickWith } from '@peertube/peertube-typescript-utils' +import { MVideoFormattable, MVideoThumbnail, MVideoUrl } from './video.js' +import { MVideoPlaylistPrivacy } from './video-playlist.js' type Use = PickWith diff --git a/server/types/models/video/video-playlist.ts b/server/server/types/models/video/video-playlist.ts similarity index 92% rename from server/types/models/video/video-playlist.ts rename to server/server/types/models/video/video-playlist.ts index 40f0dfc14..3d99bf4e5 100644 --- a/server/types/models/video/video-playlist.ts +++ b/server/server/types/models/video/video-playlist.ts @@ -1,9 +1,9 @@ -import { MVideoPlaylistElementLight } from '@server/types/models/video/video-playlist-element' -import { PickWith } from '@shared/typescript-utils' -import { VideoPlaylistModel } from '../../../models/video/video-playlist' -import { MAccount, MAccountDefault, MAccountSummary, MAccountSummaryFormattable } from '../account' -import { MThumbnail } from './thumbnail' -import { MChannelDefault, MChannelSummary, MChannelSummaryFormattable, MChannelUrl } from './video-channels' +import { MVideoPlaylistElementLight } from '@server/types/models/video/video-playlist-element.js' +import { PickWith } from '@peertube/peertube-typescript-utils' +import { VideoPlaylistModel } from '../../../models/video/video-playlist.js' +import { MAccount, MAccountDefault, MAccountSummary, MAccountSummaryFormattable } from '../account/index.js' +import { MThumbnail } from './thumbnail.js' +import { MChannelDefault, MChannelSummary, MChannelSummaryFormattable, MChannelUrl } from './video-channels.js' type Use = PickWith diff --git a/server/types/models/video/video-rate.ts b/server/server/types/models/video/video-rate.ts similarity index 85% rename from server/types/models/video/video-rate.ts rename to server/server/types/models/video/video-rate.ts index 0dbdf3c41..873b289e6 100644 --- a/server/types/models/video/video-rate.ts +++ b/server/server/types/models/video/video-rate.ts @@ -1,7 +1,7 @@ -import { AccountVideoRateModel } from '@server/models/account/account-video-rate' -import { PickWith } from '@shared/typescript-utils' -import { MAccountAudience, MAccountUrl } from '../account/account' -import { MVideo, MVideoFormattable } from './video' +import { AccountVideoRateModel } from '@server/models/account/account-video-rate.js' +import { PickWith } from '@peertube/peertube-typescript-utils' +import { MAccountAudience, MAccountUrl } from '../account/account.js' +import { MVideo, MVideoFormattable } from './video.js' type Use = PickWith diff --git a/server/types/models/video/video-redundancy.ts b/server/server/types/models/video/video-redundancy.ts similarity index 83% rename from server/types/models/video/video-redundancy.ts rename to server/server/types/models/video/video-redundancy.ts index e2a9beb93..55014cdf6 100644 --- a/server/types/models/video/video-redundancy.ts +++ b/server/server/types/models/video/video-redundancy.ts @@ -1,10 +1,10 @@ -import { VideoFileModel } from '@server/models/video/video-file' -import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' -import { PickWith, PickWithOpt } from '@shared/typescript-utils' -import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy' -import { MVideoUrl } from './video' -import { MVideoFile, MVideoFileVideo } from './video-file' -import { MStreamingPlaylistVideo } from './video-streaming-playlist' +import { VideoFileModel } from '@server/models/video/video-file.js' +import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist.js' +import { PickWith, PickWithOpt } from '@peertube/peertube-typescript-utils' +import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy.js' +import { MVideoUrl } from './video.js' +import { MVideoFile, MVideoFileVideo } from './video-file.js' +import { MStreamingPlaylistVideo } from './video-streaming-playlist.js' type Use = PickWith diff --git a/server/types/models/video/video-share.ts b/server/server/types/models/video/video-share.ts similarity index 75% rename from server/types/models/video/video-share.ts rename to server/server/types/models/video/video-share.ts index ffc0edad6..52e98d8ec 100644 --- a/server/types/models/video/video-share.ts +++ b/server/server/types/models/video/video-share.ts @@ -1,7 +1,7 @@ -import { PickWith } from '@shared/typescript-utils' -import { VideoShareModel } from '../../../models/video/video-share' -import { MActorDefault } from '../actor' -import { MVideo } from './video' +import { PickWith } from '@peertube/peertube-typescript-utils' +import { VideoShareModel } from '../../../models/video/video-share.js' +import { MActorDefault } from '../actor/index.js' +import { MVideo } from './video.js' type Use = PickWith diff --git a/server/types/models/video/video-source.ts b/server/server/types/models/video/video-source.ts similarity index 93% rename from server/types/models/video/video-source.ts rename to server/server/types/models/video/video-source.ts index 0948f3b2e..e29feec14 100644 --- a/server/types/models/video/video-source.ts +++ b/server/server/types/models/video/video-source.ts @@ -1,3 +1,3 @@ -import { VideoSourceModel } from '@server/models/video/video-source' +import { VideoSourceModel } from '@server/models/video/video-source.js' export type MVideoSource = Omit diff --git a/server/types/models/video/video-streaming-playlist.ts b/server/server/types/models/video/video-streaming-playlist.ts similarity index 87% rename from server/types/models/video/video-streaming-playlist.ts rename to server/server/types/models/video/video-streaming-playlist.ts index 1c2f83489..a41646969 100644 --- a/server/types/models/video/video-streaming-playlist.ts +++ b/server/server/types/models/video/video-streaming-playlist.ts @@ -1,8 +1,8 @@ -import { PickWith, PickWithOpt } from '@shared/typescript-utils' -import { VideoStreamingPlaylistModel } from '../../../models/video/video-streaming-playlist' -import { MVideo } from './video' -import { MVideoFile } from './video-file' -import { MVideoRedundancy, MVideoRedundancyFileUrl } from './video-redundancy' +import { PickWith, PickWithOpt } from '@peertube/peertube-typescript-utils' +import { VideoStreamingPlaylistModel } from '../../../models/video/video-streaming-playlist.js' +import { MVideo } from './video.js' +import { MVideoFile } from './video-file.js' +import { MVideoRedundancy, MVideoRedundancyFileUrl } from './video-redundancy.js' type Use = PickWith diff --git a/server/types/models/video/video.ts b/server/server/types/models/video/video.ts similarity index 92% rename from server/types/models/video/video.ts rename to server/server/types/models/video/video.ts index 53ee94269..b7f8652be 100644 --- a/server/types/models/video/video.ts +++ b/server/server/types/models/video/video.ts @@ -1,13 +1,13 @@ -import { PickWith, PickWithOpt } from '@shared/typescript-utils' -import { VideoModel } from '../../../models/video/video' -import { MTrackerUrl } from '../server/tracker' -import { MUserVideoHistoryTime } from '../user/user-video-history' -import { MScheduleVideoUpdate } from './schedule-video-update' -import { MStoryboard } from './storyboard' -import { MTag } from './tag' -import { MThumbnail } from './thumbnail' -import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist' -import { MVideoCaptionLanguage, MVideoCaptionLanguageUrl } from './video-caption' +import { PickWith, PickWithOpt } from '@peertube/peertube-typescript-utils' +import { VideoModel } from '../../../models/video/video.js' +import { MTrackerUrl } from '../server/tracker.js' +import { MUserVideoHistoryTime } from '../user/user-video-history.js' +import { MScheduleVideoUpdate } from './schedule-video-update.js' +import { MStoryboard } from './storyboard.js' +import { MTag } from './tag.js' +import { MThumbnail } from './thumbnail.js' +import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist.js' +import { MVideoCaptionLanguage, MVideoCaptionLanguageUrl } from './video-caption.js' import { MChannelAccountDefault, MChannelAccountLight, @@ -16,15 +16,15 @@ import { MChannelFormattable, MChannelHostOnly, MChannelUserId -} from './video-channels' -import { MVideoFile, MVideoFileRedundanciesAll, MVideoFileRedundanciesOpt } from './video-file' -import { MVideoLive } from './video-live' +} from './video-channels.js' +import { MVideoFile, MVideoFileRedundanciesAll, MVideoFileRedundanciesOpt } from './video-file.js' +import { MVideoLive } from './video-live.js' import { MStreamingPlaylistFiles, MStreamingPlaylistRedundancies, MStreamingPlaylistRedundanciesAll, MStreamingPlaylistRedundanciesOpt -} from './video-streaming-playlist' +} from './video-streaming-playlist.js' type Use = PickWith diff --git a/server/server/types/plugins/index.ts b/server/server/types/plugins/index.ts new file mode 100644 index 000000000..f50ac6fe9 --- /dev/null +++ b/server/server/types/plugins/index.ts @@ -0,0 +1,4 @@ +export * from './plugin-library.model.js' +export * from './register-server-auth.model.js' +export * from './register-server-option.model.js' +export * from './register-server-websocket-route.model.js' diff --git a/server/types/plugins/plugin-library.model.ts b/server/server/types/plugins/plugin-library.model.ts similarity index 95% rename from server/types/plugins/plugin-library.model.ts rename to server/server/types/plugins/plugin-library.model.ts index 5b517ee9f..e8992ce85 100644 --- a/server/types/plugins/plugin-library.model.ts +++ b/server/server/types/plugins/plugin-library.model.ts @@ -1,4 +1,4 @@ -import { RegisterServerOptions } from './register-server-option.model' +import { RegisterServerOptions } from './register-server-option.model.js' export interface PluginLibrary { register: (options: RegisterServerOptions) => Promise diff --git a/server/types/plugins/register-server-auth.model.ts b/server/server/types/plugins/register-server-auth.model.ts similarity index 92% rename from server/types/plugins/register-server-auth.model.ts rename to server/server/types/plugins/register-server-auth.model.ts index e10968c20..377682af6 100644 --- a/server/types/plugins/register-server-auth.model.ts +++ b/server/server/types/plugins/register-server-auth.model.ts @@ -1,6 +1,6 @@ import express from 'express' -import { UserAdminFlag, UserRole } from '@shared/models' -import { MOAuthToken, MUser } from '../models' +import { UserAdminFlagType, UserRoleType } from '@peertube/peertube-models' +import { MOAuthToken, MUser } from '../models/index.js' export type RegisterServerAuthOptions = RegisterServerAuthPassOptions | RegisterServerAuthExternalOptions @@ -18,11 +18,11 @@ export interface RegisterServerAuthenticatedResult { username: string email: string - role?: UserRole + role?: UserRoleType displayName?: string // PeerTube >= 5.1 - adminFlags?: UserAdminFlag + adminFlags?: UserAdminFlagType // PeerTube >= 5.1 videoQuota?: number diff --git a/server/types/plugins/register-server-option.model.ts b/server/server/types/plugins/register-server-option.model.ts similarity index 94% rename from server/types/plugins/register-server-option.model.ts rename to server/server/types/plugins/register-server-option.model.ts index 103ef234b..e31aca1b8 100644 --- a/server/types/plugins/register-server-option.model.ts +++ b/server/server/types/plugins/register-server-option.model.ts @@ -1,7 +1,6 @@ import { Response, Router } from 'express' import { Server } from 'http' import { Logger } from 'winston' -import { ActorModel } from '@server/models/actor/actor' import { PluginPlaylistPrivacyManager, PluginSettingsManager, @@ -14,16 +13,17 @@ import { RegisterServerHookOptions, RegisterServerSettingOptions, ServerConfig, - ThumbnailType, + ThumbnailType_Type, VideoBlacklistCreate -} from '@shared/models' -import { MUserDefault, MVideo, MVideoThumbnail, UserNotificationModelForApi } from '../models' +} from '@peertube/peertube-models' +import { ActorModel } from '@server/models/actor/actor.js' +import { MUserDefault, MVideo, MVideoThumbnail, UserNotificationModelForApi } from '../models/index.js' import { RegisterServerAuthExternalOptions, RegisterServerAuthExternalResult, RegisterServerAuthPassOptions -} from './register-server-auth.model' -import { RegisterServerWebSocketRouteOptions } from './register-server-websocket-route.model' +} from './register-server-auth.model.js' +import { RegisterServerWebSocketRouteOptions } from './register-server-websocket-route.model.js' export type PeerTubeHelpers = { logger: Logger @@ -72,7 +72,7 @@ export type PeerTubeHelpers = { } thumbnails: { - type: ThumbnailType + type: ThumbnailType_Type path: string }[] }> diff --git a/server/types/plugins/register-server-websocket-route.model.ts b/server/server/types/plugins/register-server-websocket-route.model.ts similarity index 100% rename from server/types/plugins/register-server-websocket-route.model.ts rename to server/server/types/plugins/register-server-websocket-route.model.ts diff --git a/server/types/sequelize.ts b/server/server/types/sequelize.ts similarity index 90% rename from server/types/sequelize.ts rename to server/server/types/sequelize.ts index e399c3d5d..cf0d040ae 100644 --- a/server/types/sequelize.ts +++ b/server/server/types/sequelize.ts @@ -1,4 +1,4 @@ -import { AttributesOnly } from '@shared/typescript-utils' +import { AttributesOnly } from '@peertube/peertube-typescript-utils' import { Model } from 'sequelize' // Thanks to sequelize-typescript: https://github.com/RobinBuschmann/sequelize-typescript diff --git a/server/tests/api/activitypub/index.ts b/server/tests/api/activitypub/index.ts deleted file mode 100644 index 324b444e4..000000000 --- a/server/tests/api/activitypub/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -import './cleaner' -import './client' -import './fetch' -import './refresher' -import './helpers' -import './security' diff --git a/server/tests/api/check-params/index.ts b/server/tests/api/check-params/index.ts deleted file mode 100644 index c2a7ccd78..000000000 --- a/server/tests/api/check-params/index.ts +++ /dev/null @@ -1,45 +0,0 @@ -import './abuses' -import './accounts' -import './blocklist' -import './bulk' -import './channel-import-videos' -import './config' -import './contact-form' -import './custom-pages' -import './debug' -import './follows' -import './jobs' -import './live' -import './logs' -import './metrics' -import './my-user' -import './plugins' -import './redundancy' -import './registrations' -import './runners' -import './search' -import './services' -import './transcoding' -import './two-factor' -import './upload-quota' -import './user-notifications' -import './user-subscriptions' -import './users-admin' -import './users-emails' -import './video-blacklist' -import './video-captions' -import './video-channel-syncs' -import './video-channels' -import './video-comments' -import './video-files' -import './video-imports' -import './video-playlists' -import './video-storyboards' -import './video-source' -import './video-studio' -import './video-token' -import './videos-common-filters' -import './videos-history' -import './videos-overviews' -import './videos' -import './views' diff --git a/server/tests/api/index.ts b/server/tests/api/index.ts deleted file mode 100644 index ef0c83294..000000000 --- a/server/tests/api/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -// Order of the tests we want to execute -import './activitypub' -import './check-params' -import './moderation' -import './object-storage' -import './notifications' -import './redundancy' -import './runners' -import './search' -import './server' -import './transcoding' -import './users' -import './videos' diff --git a/server/tests/api/live/index.ts b/server/tests/api/live/index.ts deleted file mode 100644 index c88943f65..000000000 --- a/server/tests/api/live/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -import './live-constraints' -import './live-fast-restream' -import './live-socket-messages' -import './live-permanent' -import './live-rtmps' -import './live-save-replay' -import './live' diff --git a/server/tests/api/moderation/index.ts b/server/tests/api/moderation/index.ts deleted file mode 100644 index 874be03d5..000000000 --- a/server/tests/api/moderation/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './abuses' -export * from './blocklist-notification' -export * from './blocklist' -export * from './video-blacklist' diff --git a/server/tests/api/notifications/index.ts b/server/tests/api/notifications/index.ts deleted file mode 100644 index c0216b74f..000000000 --- a/server/tests/api/notifications/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -import './admin-notifications' -import './comments-notifications' -import './moderation-notifications' -import './notifications-api' -import './registrations-notifications' -import './user-notifications' diff --git a/server/tests/api/object-storage/index.ts b/server/tests/api/object-storage/index.ts deleted file mode 100644 index 1f4489fa3..000000000 --- a/server/tests/api/object-storage/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './live' -export * from './video-imports' -export * from './video-static-file-privacy' -export * from './videos' diff --git a/server/tests/api/redundancy/index.ts b/server/tests/api/redundancy/index.ts deleted file mode 100644 index 37dc3f88c..000000000 --- a/server/tests/api/redundancy/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import './redundancy-constraints' -import './redundancy' -import './manage-redundancy' diff --git a/server/tests/api/runners/index.ts b/server/tests/api/runners/index.ts deleted file mode 100644 index 642a3a96d..000000000 --- a/server/tests/api/runners/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './runner-common' -export * from './runner-live-transcoding' -export * from './runner-socket' -export * from './runner-studio-transcoding' -export * from './runner-vod-transcoding' diff --git a/server/tests/api/search/index.ts b/server/tests/api/search/index.ts deleted file mode 100644 index a976d210d..000000000 --- a/server/tests/api/search/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -import './search-activitypub-video-playlists' -import './search-activitypub-video-channels' -import './search-activitypub-videos' -import './search-channels' -import './search-index' -import './search-playlists' -import './search-videos' diff --git a/server/tests/api/server/index.ts b/server/tests/api/server/index.ts deleted file mode 100644 index 78522c246..000000000 --- a/server/tests/api/server/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -import './auto-follows' -import './bulk' -import './config-defaults' -import './config' -import './contact-form' -import './email' -import './follow-constraints' -import './follows' -import './follows-moderation' -import './homepage' -import './handle-down' -import './jobs' -import './logs' -import './reverse-proxy' -import './services' -import './slow-follows' -import './stats' -import './tracker' -import './no-client' -import './open-telemetry' -import './plugins' -import './proxy' diff --git a/server/tests/api/transcoding/index.ts b/server/tests/api/transcoding/index.ts deleted file mode 100644 index 9866418d6..000000000 --- a/server/tests/api/transcoding/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './audio-only' -export * from './create-transcoding' -export * from './hls' -export * from './transcoder' -export * from './update-while-transcoding' -export * from './video-studio' diff --git a/server/tests/api/users/index.ts b/server/tests/api/users/index.ts deleted file mode 100644 index a4443a8ec..000000000 --- a/server/tests/api/users/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -import './oauth' -import './registrations`' -import './two-factor' -import './user-subscriptions' -import './user-videos' -import './users' -import './users-multiple-servers' -import './users-email-verification' diff --git a/server/tests/api/videos/index.ts b/server/tests/api/videos/index.ts deleted file mode 100644 index 01d0c5852..000000000 --- a/server/tests/api/videos/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -import './multiple-servers' -import './resumable-upload' -import './single-server' -import './video-captions' -import './video-change-ownership' -import './video-channels' -import './channel-import-videos' -import './video-channel-syncs' -import './video-comments' -import './video-description' -import './video-files' -import './video-imports' -import './video-nsfw' -import './video-playlists' -import './video-playlist-thumbnails' -import './video-source' -import './video-privacy' -import './video-schedule-update' -import './videos-common-filters' -import './videos-history' -import './videos-overview' -import './video-static-file-privacy' -import './video-storyboard' diff --git a/server/tests/api/views/index.ts b/server/tests/api/views/index.ts deleted file mode 100644 index 5e06b31fb..000000000 --- a/server/tests/api/views/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './video-views-counter' -export * from './video-views-overall-stats' -export * from './video-views-retention-stats' -export * from './video-views-timeserie-stats' -export * from './videos-views-cleaner' diff --git a/server/tests/helpers/comment-model.ts b/server/tests/helpers/comment-model.ts deleted file mode 100644 index e39cae442..000000000 --- a/server/tests/helpers/comment-model.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ - -import { expect } from 'chai' -import { VideoCommentModel } from '../../models/video/video-comment' - -class CommentMock { - text: string - - extractMentions = VideoCommentModel.prototype.extractMentions - - isOwned = () => true -} - -describe('Comment model', function () { - it('Should correctly extract mentions', async function () { - const comment = new CommentMock() - - comment.text = '@florian @jean@localhost:9000 @flo @another@localhost:9000 @flo2@jean.com hello ' + - 'email@localhost:9000 coucou.com no? @chocobozzz @chocobozzz @end' - const result = comment.extractMentions().sort((a, b) => a.localeCompare(b)) - - expect(result).to.deep.equal([ 'another', 'chocobozzz', 'end', 'flo', 'florian', 'jean' ]) - }) -}) diff --git a/server/tests/helpers/index.ts b/server/tests/helpers/index.ts deleted file mode 100644 index 073ae6455..000000000 --- a/server/tests/helpers/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -import './comment-model' -import './core-utils' -import './crypto' -import './dns' -import './image' -import './markdown' -import './request' -import './validator' -import './version' diff --git a/server/tests/index.ts b/server/tests/index.ts deleted file mode 100644 index 4ec1ebe67..000000000 --- a/server/tests/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -// Order of the tests we want to execute -import './client' -import './misc-endpoints' -import './feeds/' -import './cli/' -import './api/' -import './peertube-runner/' -import './plugins/' -import './helpers/' -import './lib/' diff --git a/server/tests/lib/index.ts b/server/tests/lib/index.ts deleted file mode 100644 index a40df35fd..000000000 --- a/server/tests/lib/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './video-constant-registry-factory' diff --git a/server/tests/peertube-runner/index.ts b/server/tests/peertube-runner/index.ts deleted file mode 100644 index 470316417..000000000 --- a/server/tests/peertube-runner/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './client-cli' -export * from './live-transcoding' -export * from './studio-transcoding' -export * from './vod-transcoding' diff --git a/server/tests/shared/index.ts b/server/tests/shared/index.ts deleted file mode 100644 index eda24adb5..000000000 --- a/server/tests/shared/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -export * from './mock-servers' -export * from './actors' -export * from './captions' -export * from './checks' -export * from './directories' -export * from './generate' -export * from './live' -export * from './notifications' -export * from './peertube-runner-process' -export * from './video-playlists' -export * from './plugins' -export * from './requests' -export * from './sql-command' -export * from './streaming-playlists' -export * from './tests' -export * from './tracker' -export * from './videos' -export * from './views' -export * from './webtorrent' diff --git a/server/tests/shared/mock-servers/index.ts b/server/tests/shared/mock-servers/index.ts deleted file mode 100644 index 1fa983116..000000000 --- a/server/tests/shared/mock-servers/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from './mock-429' -export * from './mock-email' -export * from './mock-http' -export * from './mock-instances-index' -export * from './mock-joinpeertube-versions' -export * from './mock-object-storage' -export * from './mock-plugin-blocklist' -export * from './mock-proxy' diff --git a/server/tools/README.md b/server/tools/README.md deleted file mode 100644 index d7ecd4004..000000000 --- a/server/tools/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# PeerTube CLI - -See https://docs.joinpeertube.org/maintain/tools#remote-tools diff --git a/server/tools/package.json b/server/tools/package.json deleted file mode 100644 index b20f38244..000000000 --- a/server/tools/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "@peertube/cli", - "version": "1.0.0", - "private": true, - "dependencies": { - "application-config": "^2.0.0", - "cli-table3": "^0.6.0", - "netrc-parser": "^3.1.6" - }, - "devDependencies": {} -} diff --git a/server/tools/peertube-auth.ts b/server/tools/peertube-auth.ts deleted file mode 100644 index c853469c2..000000000 --- a/server/tools/peertube-auth.ts +++ /dev/null @@ -1,171 +0,0 @@ -import CliTable3 from 'cli-table3' -import { OptionValues, program } from 'commander' -import { isUserUsernameValid } from '../helpers/custom-validators/users' -import { assignToken, buildServer, getNetrc, getSettings, writeSettings } from './shared' - -import prompt = require('prompt') - -async function delInstance (url: string) { - const [ settings, netrc ] = await Promise.all([ getSettings(), getNetrc() ]) - - const index = settings.remotes.indexOf(url) - settings.remotes.splice(index) - - if (settings.default === index) settings.default = -1 - - await writeSettings(settings) - - delete netrc.machines[url] - - await netrc.save() -} - -async function setInstance (url: string, username: string, password: string, isDefault: boolean) { - const [ settings, netrc ] = await Promise.all([ getSettings(), getNetrc() ]) - - if (settings.remotes.includes(url) === false) { - settings.remotes.push(url) - } - - if (isDefault || settings.remotes.length === 1) { - settings.default = settings.remotes.length - 1 - } - - await writeSettings(settings) - - netrc.machines[url] = { login: username, password } - await netrc.save() -} - -function isURLaPeerTubeInstance (url: string) { - return url.startsWith('http://') || url.startsWith('https://') -} - -function stripExtraneousFromPeerTubeUrl (url: string) { - // Get everything before the 3rd /. - const urlLength = url.includes('/', 8) - ? url.indexOf('/', 8) - : url.length - - return url.substring(0, urlLength) -} - -program - .name('auth') - .usage('[command] [options]') - -program - .command('add') - .description('remember your accounts on remote instances for easier use') - .option('-u, --url ', 'Server url') - .option('-U, --username ', 'Username') - .option('-p, --password ', 'Password') - .option('--default', 'add the entry as the new default') - .action((options: OptionValues) => { - /* eslint-disable no-import-assign */ - prompt.override = options - prompt.start() - prompt.get({ - properties: { - url: { - description: 'instance url', - conform: (value) => isURLaPeerTubeInstance(value), - message: 'It should be an URL (https://peertube.example.com)', - required: true - }, - username: { - conform: (value) => isUserUsernameValid(value), - message: 'Name must be only letters, spaces, or dashes', - required: true - }, - password: { - hidden: true, - replace: '*', - required: true - } - } - }, async (_, result) => { - - // Check credentials - try { - // Strip out everything after the domain:port. - // See https://github.com/Chocobozzz/PeerTube/issues/3520 - result.url = stripExtraneousFromPeerTubeUrl(result.url) - - const server = buildServer(result.url) - await assignToken(server, result.username, result.password) - } catch (err) { - console.error(err.message) - process.exit(-1) - } - - await setInstance(result.url, result.username, result.password, options.default) - - process.exit(0) - }) - }) - -program - .command('del ') - .description('unregisters a remote instance') - .action(async url => { - await delInstance(url) - - process.exit(0) - }) - -program - .command('list') - .description('lists registered remote instances') - .action(async () => { - const [ settings, netrc ] = await Promise.all([ getSettings(), getNetrc() ]) - - const table = new CliTable3({ - head: [ 'instance', 'login' ], - colWidths: [ 30, 30 ] - }) as any - - settings.remotes.forEach(element => { - if (!netrc.machines[element]) return - - table.push([ - element, - netrc.machines[element].login - ]) - }) - - console.log(table.toString()) - - process.exit(0) - }) - -program - .command('set-default ') - .description('set an existing entry as default') - .action(async url => { - const settings = await getSettings() - const instanceExists = settings.remotes.includes(url) - - if (instanceExists) { - settings.default = settings.remotes.indexOf(url) - await writeSettings(settings) - - process.exit(0) - } else { - console.log(' is not a registered instance.') - process.exit(-1) - } - }) - -program.addHelpText('after', '\n\n Examples:\n\n' + - ' $ peertube auth add -u https://peertube.cpy.re -U "PEERTUBE_USER" --password "PEERTUBE_PASSWORD"\n' + - ' $ peertube auth add -u https://peertube.cpy.re -U root\n' + - ' $ peertube auth list\n' + - ' $ peertube auth del https://peertube.cpy.re\n' -) - -if (!process.argv.slice(2).length) { - program.outputHelp() -} - -program.parse(process.argv) diff --git a/server/tools/peertube-get-access-token.ts b/server/tools/peertube-get-access-token.ts deleted file mode 100644 index 71a4826e8..000000000 --- a/server/tools/peertube-get-access-token.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { program } from 'commander' -import { assignToken, buildServer } from './shared' - -program - .option('-u, --url ', 'Server url') - .option('-n, --username ', 'Username') - .option('-p, --password ', 'Password') - .parse(process.argv) - -const options = program.opts() - -if ( - !options.url || - !options.username || - !options.password -) { - if (!options.url) console.error('--url field is required.') - if (!options.username) console.error('--username field is required.') - if (!options.password) console.error('--password field is required.') - - process.exit(-1) -} - -const server = buildServer(options.url) - -assignToken(server, options.username, options.password) - .then(() => { - console.log(server.accessToken) - process.exit(0) - }) - .catch(err => { - console.error(err) - process.exit(-1) - }) diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts deleted file mode 100644 index bbdaa09c0..000000000 --- a/server/tools/peertube-import-videos.ts +++ /dev/null @@ -1,351 +0,0 @@ -import { program } from 'commander' -import { accessSync, constants } from 'fs' -import { remove } from 'fs-extra' -import { join } from 'path' -import { YoutubeDLCLI, YoutubeDLInfo, YoutubeDLInfoBuilder } from '@server/helpers/youtube-dl' -import { wait } from '@shared/core-utils' -import { sha256 } from '@shared/extra-utils' -import { doRequestAndSaveToFile } from '../helpers/requests' -import { - assignToken, - buildCommonVideoOptions, - buildServer, - buildVideoAttributesFromCommander, - getLogger, - getServerCredentials -} from './shared' - -import prompt = require('prompt') - -const processOptions = { - maxBuffer: Infinity -} - -let command = program - .name('import-videos') - -command = buildCommonVideoOptions(command) - -command - .option('-u, --url ', 'Server url') - .option('-U, --username ', 'Username') - .option('-p, --password ', 'Password') - .option('--target-url ', 'Video target URL') - .option('--since ', 'Publication date (inclusive) since which the videos can be imported (YYYY-MM-DD)', parseDate) - .option('--until ', 'Publication date (inclusive) until which the videos can be imported (YYYY-MM-DD)', parseDate) - .option('--first ', 'Process first n elements of returned playlist') - .option('--last ', 'Process last n elements of returned playlist') - .option('--wait-interval ', 'Duration between two video imports (in seconds)', convertIntoMs) - .option('-T, --tmpdir ', 'Working directory', __dirname) - .usage('[global options] [ -- youtube-dl options]') - .parse(process.argv) - -const options = command.opts() - -const log = getLogger(options.verbose) - -getServerCredentials(command) - .then(({ url, username, password }) => { - if (!options.targetUrl) { - exitError('--target-url field is required.') - } - - try { - accessSync(options.tmpdir, constants.R_OK | constants.W_OK) - } catch (e) { - exitError('--tmpdir %s: directory does not exist or is not accessible', options.tmpdir) - } - - url = normalizeTargetUrl(url) - options.targetUrl = normalizeTargetUrl(options.targetUrl) - - run(url, username, password) - .catch(err => exitError(err)) - }) - .catch(err => console.error(err)) - -async function run (url: string, username: string, password: string) { - if (!password) password = await promptPassword() - - const youtubeDLBinary = await YoutubeDLCLI.safeGet() - - let info = await getYoutubeDLInfo(youtubeDLBinary, options.targetUrl, command.args) - - if (!Array.isArray(info)) info = [ info ] - - // Try to fix youtube channels upload - const uploadsObject = info.find(i => !i.ie_key && !i.duration && i.title === 'Uploads') - - if (uploadsObject) { - console.log('Fixing URL to %s.', uploadsObject.url) - - info = await getYoutubeDLInfo(youtubeDLBinary, uploadsObject.url, command.args) - } - - let infoArray: any[] - - infoArray = [].concat(info) - if (options.first) { - infoArray = infoArray.slice(0, options.first) - } else if (options.last) { - infoArray = infoArray.slice(-options.last) - } - - log.info('Will download and upload %d videos.\n', infoArray.length) - - let skipInterval = true - for (const [ index, info ] of infoArray.entries()) { - try { - if (index > 0 && options.waitInterval && !skipInterval) { - log.info('Wait for %d seconds before continuing.', options.waitInterval / 1000) - await wait(options.waitInterval) - } - - skipInterval = await processVideo({ - cwd: options.tmpdir, - url, - username, - password, - youtubeInfo: info - }) - } catch (err) { - console.error('Cannot process video.', { info, url, err }) - } - } - - log.info('Video/s for user %s imported: %s', username, options.targetUrl) - process.exit(0) -} - -async function processVideo (parameters: { - cwd: string - url: string - username: string - password: string - youtubeInfo: any -}) { - const { youtubeInfo, cwd, url, username, password } = parameters - - log.debug('Fetching object.', youtubeInfo) - - const videoInfo = await fetchObject(youtubeInfo) - log.debug('Fetched object.', videoInfo) - - if ( - options.since && - videoInfo.originallyPublishedAtWithoutTime && - videoInfo.originallyPublishedAtWithoutTime.getTime() < options.since.getTime() - ) { - log.info('Video "%s" has been published before "%s", don\'t upload it.\n', videoInfo.name, formatDate(options.since)) - return true - } - - if ( - options.until && - videoInfo.originallyPublishedAtWithoutTime && - videoInfo.originallyPublishedAtWithoutTime.getTime() > options.until.getTime() - ) { - log.info('Video "%s" has been published after "%s", don\'t upload it.\n', videoInfo.name, formatDate(options.until)) - return true - } - - const server = buildServer(url) - const { data } = await server.search.advancedVideoSearch({ - search: { - search: videoInfo.name, - sort: '-match', - searchTarget: 'local' - } - }) - - log.info('############################################################\n') - - if (data.find(v => v.name === videoInfo.name)) { - log.info('Video "%s" already exists, don\'t reupload it.\n', videoInfo.name) - return true - } - - const path = join(cwd, sha256(videoInfo.url) + '.mp4') - - log.info('Downloading video "%s"...', videoInfo.name) - - try { - const youtubeDLBinary = await YoutubeDLCLI.safeGet() - const output = await youtubeDLBinary.download({ - url: videoInfo.url, - format: YoutubeDLCLI.getYoutubeDLVideoFormat([], false), - output: path, - additionalYoutubeDLArgs: command.args, - processOptions - }) - - log.info(output.join('\n')) - await uploadVideoOnPeerTube({ - cwd, - url, - username, - password, - videoInfo, - videoPath: path - }) - } catch (err) { - log.error(err.message) - } - - return false -} - -async function uploadVideoOnPeerTube (parameters: { - videoInfo: YoutubeDLInfo - videoPath: string - cwd: string - url: string - username: string - password: string -}) { - const { videoInfo, videoPath, cwd, url, username, password } = parameters - - const server = buildServer(url) - await assignToken(server, username, password) - - let thumbnailfile: string - if (videoInfo.thumbnailUrl) { - thumbnailfile = join(cwd, sha256(videoInfo.thumbnailUrl) + '.jpg') - - await doRequestAndSaveToFile(videoInfo.thumbnailUrl, thumbnailfile) - } - - const baseAttributes = await buildVideoAttributesFromCommander(server, program, videoInfo) - - const attributes = { - ...baseAttributes, - - originallyPublishedAtWithoutTime: videoInfo.originallyPublishedAtWithoutTime - ? videoInfo.originallyPublishedAtWithoutTime.toISOString() - : null, - - thumbnailfile, - previewfile: thumbnailfile, - fixture: videoPath - } - - log.info('\nUploading on PeerTube video "%s".', attributes.name) - - try { - await server.videos.upload({ attributes }) - } catch (err) { - if (err.message.indexOf('401') !== -1) { - log.info('Got 401 Unauthorized, token may have expired, renewing token and retry.') - - server.accessToken = await server.login.getAccessToken(username, password) - - await server.videos.upload({ attributes }) - } else { - exitError(err.message) - } - } - - await remove(videoPath) - if (thumbnailfile) await remove(thumbnailfile) - - log.info('Uploaded video "%s"!\n', attributes.name) -} - -/* ---------------------------------------------------------- */ - -async function fetchObject (info: any) { - const url = buildUrl(info) - - const youtubeDLCLI = await YoutubeDLCLI.safeGet() - const result = await youtubeDLCLI.getInfo({ - url, - format: YoutubeDLCLI.getYoutubeDLVideoFormat([], false), - processOptions - }) - - const builder = new YoutubeDLInfoBuilder(result) - - const videoInfo = builder.getInfo() - - return { ...videoInfo, url } -} - -function buildUrl (info: any) { - const webpageUrl = info.webpage_url as string - if (webpageUrl?.match(/^https?:\/\//)) return webpageUrl - - const url = info.url as string - if (url?.match(/^https?:\/\//)) return url - - // It seems youtube-dl does not return the video url - return 'https://www.youtube.com/watch?v=' + info.id -} - -function normalizeTargetUrl (url: string) { - let normalizedUrl = url.replace(/\/+$/, '') - - if (!normalizedUrl.startsWith('http://') && !normalizedUrl.startsWith('https://')) { - normalizedUrl = 'https://' + normalizedUrl - } - - return normalizedUrl -} - -async function promptPassword () { - return new Promise((res, rej) => { - prompt.start() - const schema = { - properties: { - password: { - hidden: true, - required: true - } - } - } - prompt.get(schema, function (err, result) { - if (err) { - return rej(err) - } - return res(result.password) - }) - }) -} - -function parseDate (dateAsStr: string): Date { - if (!/\d{4}-\d{2}-\d{2}/.test(dateAsStr)) { - exitError(`Invalid date passed: ${dateAsStr}. Expected format: YYYY-MM-DD. See help for usage.`) - } - const date = new Date(dateAsStr) - date.setHours(0, 0, 0) - if (isNaN(date.getTime())) { - exitError(`Invalid date passed: ${dateAsStr}. See help for usage.`) - } - return date -} - -function formatDate (date: Date): string { - return date.toISOString().split('T')[0] -} - -function convertIntoMs (secondsAsStr: string): number { - const seconds = parseInt(secondsAsStr, 10) - if (seconds <= 0) { - exitError(`Invalid duration passed: ${seconds}. Expected duration to be strictly positive and in seconds`) - } - return Math.round(seconds * 1000) -} - -function exitError (message: string, ...meta: any[]) { - // use console.error instead of log.error here - console.error(message, ...meta) - process.exit(-1) -} - -function getYoutubeDLInfo (youtubeDLCLI: YoutubeDLCLI, url: string, args: string[]) { - return youtubeDLCLI.getInfo({ - url, - format: YoutubeDLCLI.getYoutubeDLVideoFormat([], false), - additionalYoutubeDLArgs: [ '-j', '--flat-playlist', '--playlist-reverse', ...args ], - processOptions - }) -} diff --git a/server/tools/peertube-plugins.ts b/server/tools/peertube-plugins.ts deleted file mode 100644 index 0660c855f..000000000 --- a/server/tools/peertube-plugins.ts +++ /dev/null @@ -1,165 +0,0 @@ -import CliTable3 from 'cli-table3' -import { Command, OptionValues, program } from 'commander' -import { isAbsolute } from 'path' -import { PluginType } from '../../shared/models' -import { assignToken, buildServer, getServerCredentials } from './shared' - -program - .name('plugins') - .usage('[command] [options]') - -program - .command('list') - .description('List installed plugins') - .option('-u, --url ', 'Server url') - .option('-U, --username ', 'Username') - .option('-p, --password ', 'Password') - .option('-t, --only-themes', 'List themes only') - .option('-P, --only-plugins', 'List plugins only') - .action((options, command) => pluginsListCLI(command, options)) - -program - .command('install') - .description('Install a plugin or a theme') - .option('-u, --url ', 'Server url') - .option('-U, --username ', 'Username') - .option('-p, --password ', 'Password') - .option('-P --path ', 'Install from a path') - .option('-n, --npm-name ', 'Install from npm') - .option('--plugin-version ', 'Specify the plugin version to install (only available when installing from npm)') - .action((options, command) => installPluginCLI(command, options)) - -program - .command('update') - .description('Update a plugin or a theme') - .option('-u, --url ', 'Server url') - .option('-U, --username ', 'Username') - .option('-p, --password ', 'Password') - .option('-P --path ', 'Update from a path') - .option('-n, --npm-name ', 'Update from npm') - .action((options, command) => updatePluginCLI(command, options)) - -program - .command('uninstall') - .description('Uninstall a plugin or a theme') - .option('-u, --url ', 'Server url') - .option('-U, --username ', 'Username') - .option('-p, --password ', 'Password') - .option('-n, --npm-name ', 'NPM plugin/theme name') - .action((options, command) => uninstallPluginCLI(command, options)) - -if (!process.argv.slice(2).length) { - program.outputHelp() -} - -program.parse(process.argv) - -// ---------------------------------------------------------------------------- - -async function pluginsListCLI (command: Command, options: OptionValues) { - const { url, username, password } = await getServerCredentials(command) - const server = buildServer(url) - await assignToken(server, username, password) - - let pluginType: PluginType - if (options.onlyThemes) pluginType = PluginType.THEME - if (options.onlyPlugins) pluginType = PluginType.PLUGIN - - const { data } = await server.plugins.list({ start: 0, count: 100, sort: 'name', pluginType }) - - const table = new CliTable3({ - head: [ 'name', 'version', 'homepage' ], - colWidths: [ 50, 20, 50 ] - }) as any - - for (const plugin of data) { - const npmName = plugin.type === PluginType.PLUGIN - ? 'peertube-plugin-' + plugin.name - : 'peertube-theme-' + plugin.name - - table.push([ - npmName, - plugin.version, - plugin.homepage - ]) - } - - console.log(table.toString()) - process.exit(0) -} - -async function installPluginCLI (command: Command, options: OptionValues) { - if (!options.path && !options.npmName) { - console.error('You need to specify the npm name or the path of the plugin you want to install.\n') - program.outputHelp() - process.exit(-1) - } - - if (options.path && !isAbsolute(options.path)) { - console.error('Path should be absolute.') - process.exit(-1) - } - - const { url, username, password } = await getServerCredentials(command) - const server = buildServer(url) - await assignToken(server, username, password) - - try { - await server.plugins.install({ npmName: options.npmName, path: options.path, pluginVersion: options.pluginVersion }) - } catch (err) { - console.error('Cannot install plugin.', err) - process.exit(-1) - } - - console.log('Plugin installed.') - process.exit(0) -} - -async function updatePluginCLI (command: Command, options: OptionValues) { - if (!options.path && !options.npmName) { - console.error('You need to specify the npm name or the path of the plugin you want to update.\n') - program.outputHelp() - process.exit(-1) - } - - if (options.path && !isAbsolute(options.path)) { - console.error('Path should be absolute.') - process.exit(-1) - } - - const { url, username, password } = await getServerCredentials(command) - const server = buildServer(url) - await assignToken(server, username, password) - - try { - await server.plugins.update({ npmName: options.npmName, path: options.path }) - } catch (err) { - console.error('Cannot update plugin.', err) - process.exit(-1) - } - - console.log('Plugin updated.') - process.exit(0) -} - -async function uninstallPluginCLI (command: Command, options: OptionValues) { - if (!options.npmName) { - console.error('You need to specify the npm name of the plugin/theme you want to uninstall.\n') - program.outputHelp() - process.exit(-1) - } - - const { url, username, password } = await getServerCredentials(command) - const server = buildServer(url) - await assignToken(server, username, password) - - try { - await server.plugins.uninstall({ npmName: options.npmName }) - } catch (err) { - console.error('Cannot uninstall plugin.', err) - process.exit(-1) - } - - console.log('Plugin uninstalled.') - process.exit(0) -} diff --git a/server/tools/peertube-redundancy.ts b/server/tools/peertube-redundancy.ts deleted file mode 100644 index c24eb5233..000000000 --- a/server/tools/peertube-redundancy.ts +++ /dev/null @@ -1,172 +0,0 @@ -import CliTable3 from 'cli-table3' -import { Command, program } from 'commander' -import { URL } from 'url' -import validator from 'validator' -import { forceNumber, uniqify } from '@shared/core-utils' -import { HttpStatusCode, VideoRedundanciesTarget } from '@shared/models' -import { assignToken, buildServer, getServerCredentials } from './shared' - -import bytes = require('bytes') -program - .name('redundancy') - .usage('[command] [options]') - -program - .command('list-remote-redundancies') - .description('List remote redundancies on your videos') - .option('-u, --url ', 'Server url') - .option('-U, --username ', 'Username') - .option('-p, --password ', 'Password') - .action(() => listRedundanciesCLI('my-videos')) - -program - .command('list-my-redundancies') - .description('List your redundancies of remote videos') - .option('-u, --url ', 'Server url') - .option('-U, --username ', 'Username') - .option('-p, --password ', 'Password') - .action(() => listRedundanciesCLI('remote-videos')) - -program - .command('add') - .description('Duplicate a video in your redundancy system') - .option('-u, --url ', 'Server url') - .option('-U, --username ', 'Username') - .option('-p, --password ', 'Password') - .option('-v, --video ', 'Video id to duplicate') - .action((options, command) => addRedundancyCLI(options, command)) - -program - .command('remove') - .description('Remove a video from your redundancies') - .option('-u, --url ', 'Server url') - .option('-U, --username ', 'Username') - .option('-p, --password ', 'Password') - .option('-v, --video ', 'Video id to remove from redundancies') - .action((options, command) => removeRedundancyCLI(options, command)) - -if (!process.argv.slice(2).length) { - program.outputHelp() -} - -program.parse(process.argv) - -// ---------------------------------------------------------------------------- - -async function listRedundanciesCLI (target: VideoRedundanciesTarget) { - const { url, username, password } = await getServerCredentials(program) - const server = buildServer(url) - await assignToken(server, username, password) - - const { data } = await server.redundancy.listVideos({ start: 0, count: 100, sort: 'name', target }) - - const table = new CliTable3({ - head: [ 'video id', 'video name', 'video url', 'files', 'playlists', 'by instances', 'total size' ] - }) as any - - for (const redundancy of data) { - const webVideoFiles = redundancy.redundancies.files - const streamingPlaylists = redundancy.redundancies.streamingPlaylists - - let totalSize = '' - if (target === 'remote-videos') { - const tmp = webVideoFiles.concat(streamingPlaylists) - .reduce((a, b) => a + b.size, 0) - - totalSize = bytes(tmp) - } - - const instances = uniqify( - webVideoFiles.concat(streamingPlaylists) - .map(r => r.fileUrl) - .map(u => new URL(u).host) - ) - - table.push([ - redundancy.id.toString(), - redundancy.name, - redundancy.url, - webVideoFiles.length, - streamingPlaylists.length, - instances.join('\n'), - totalSize - ]) - } - - console.log(table.toString()) - process.exit(0) -} - -async function addRedundancyCLI (options: { video: number }, command: Command) { - const { url, username, password } = await getServerCredentials(command) - const server = buildServer(url) - await assignToken(server, username, password) - - if (!options.video || validator.isInt('' + options.video) === false) { - console.error('You need to specify the video id to duplicate and it should be a number.\n') - command.outputHelp() - process.exit(-1) - } - - try { - await server.redundancy.addVideo({ videoId: options.video }) - - console.log('Video will be duplicated by your instance!') - - process.exit(0) - } catch (err) { - if (err.message.includes(HttpStatusCode.CONFLICT_409)) { - console.error('This video is already duplicated by your instance.') - } else if (err.message.includes(HttpStatusCode.NOT_FOUND_404)) { - console.error('This video id does not exist.') - } else { - console.error(err) - } - - process.exit(-1) - } -} - -async function removeRedundancyCLI (options: { video: number }, command: Command) { - const { url, username, password } = await getServerCredentials(command) - const server = buildServer(url) - await assignToken(server, username, password) - - if (!options.video || validator.isInt('' + options.video) === false) { - console.error('You need to specify the video id to remove from your redundancies.\n') - command.outputHelp() - process.exit(-1) - } - - const videoId = forceNumber(options.video) - - const myVideoRedundancies = await server.redundancy.listVideos({ target: 'my-videos' }) - let videoRedundancy = myVideoRedundancies.data.find(r => videoId === r.id) - - if (!videoRedundancy) { - const remoteVideoRedundancies = await server.redundancy.listVideos({ target: 'remote-videos' }) - videoRedundancy = remoteVideoRedundancies.data.find(r => videoId === r.id) - } - - if (!videoRedundancy) { - console.error('Video redundancy not found.') - process.exit(-1) - } - - try { - const ids = videoRedundancy.redundancies.files - .concat(videoRedundancy.redundancies.streamingPlaylists) - .map(r => r.id) - - for (const id of ids) { - await server.redundancy.removeVideo({ redundancyId: id }) - } - - console.log('Video redundancy removed!') - - process.exit(0) - } catch (err) { - console.error(err) - process.exit(-1) - } -} diff --git a/server/tools/peertube-upload.ts b/server/tools/peertube-upload.ts deleted file mode 100644 index 87da55005..000000000 --- a/server/tools/peertube-upload.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { program } from 'commander' -import { access, constants } from 'fs-extra' -import { isAbsolute } from 'path' -import { assignToken, buildCommonVideoOptions, buildServer, buildVideoAttributesFromCommander, getServerCredentials } from './shared' - -let command = program - .name('upload') - -command = buildCommonVideoOptions(command) - -command - .option('-u, --url ', 'Server url') - .option('-U, --username ', 'Username') - .option('-p, --password ', 'Password') - .option('-b, --thumbnail ', 'Thumbnail path') - .option('-v, --preview ', 'Preview path') - .option('-f, --file ', 'Video absolute file path') - .parse(process.argv) - -const options = command.opts() - -getServerCredentials(command) - .then(({ url, username, password }) => { - if (!options.videoName || !options.file) { - if (!options.videoName) console.error('--video-name is required.') - if (!options.file) console.error('--file is required.') - - process.exit(-1) - } - - if (isAbsolute(options.file) === false) { - console.error('File path should be absolute.') - process.exit(-1) - } - - run(url, username, password).catch(err => { - console.error(err) - process.exit(-1) - }) - }) - .catch(err => console.error(err)) - -async function run (url: string, username: string, password: string) { - const server = buildServer(url) - await assignToken(server, username, password) - - await access(options.file, constants.F_OK) - - console.log('Uploading %s video...', options.videoName) - - const baseAttributes = await buildVideoAttributesFromCommander(server, program) - - const attributes = { - ...baseAttributes, - - fixture: options.file, - thumbnailfile: options.thumbnail, - previewfile: options.preview - } - - try { - await server.videos.upload({ attributes }) - console.log(`Video ${options.videoName} uploaded.`) - process.exit(0) - } catch (err) { - const message = err.message || '' - if (message.includes('413')) { - console.error('Aborted: user quota is exceeded or video file is too big for this PeerTube instance.') - } else { - console.error(require('util').inspect(err)) - } - - process.exit(-1) - } -} - -// ---------------------------------------------------------------------------- diff --git a/server/tools/shared/index.ts b/server/tools/shared/index.ts deleted file mode 100644 index 8a3f31e2f..000000000 --- a/server/tools/shared/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './cli' diff --git a/server/tools/tsconfig.json b/server/tools/tsconfig.json deleted file mode 100644 index 39f8e74e4..000000000 --- a/server/tools/tsconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "outDir": "../../dist/server/tools" - }, - "include": [ ".", "../typings" ], - "references": [ - { "path": "../" } - ], - "files": [], - "exclude": [ ] // Overwrite exclude property -} diff --git a/server/tsconfig.json b/server/tsconfig.json index 240bd3bfe..2b799749f 100644 --- a/server/tsconfig.json +++ b/server/tsconfig.json @@ -1,13 +1,22 @@ { "extends": "../tsconfig.base.json", "compilerOptions": { - "outDir": "../dist/server" + "outDir": "../dist", + "baseUrl": "../", + "rootDir": ".", + "tsBuildInfoFile": "../dist/.tsbuildinfo", + "paths": { + "@server/*": [ "server/server/*" ] + } }, "references": [ - { "path": "../shared" } + { "path": "../packages/core-utils" }, + { "path": "../packages/ffmpeg" }, + { "path": "../packages/models" }, + { "path": "../packages/node-utils" }, + { "path": "../packages/typescript-utils" } ], - "exclude": [ - "tools/", - "tests/fixtures" + "include": [ + "./**/*.ts" ] } diff --git a/server/tsconfig.lib.json b/server/tsconfig.lib.json new file mode 100644 index 000000000..dfc83c0ec --- /dev/null +++ b/server/tsconfig.lib.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./dist", + "tsBuildInfoFile": "./dist/.tsbuildinfo", + "baseUrl": "../", + "rootDir": ".", + "paths": { + "@server/*": [ "server/server/*" ] + } + } +} diff --git a/server/tsconfig.types.json b/server/tsconfig.types.json index da6b572ea..696fe7059 100644 --- a/server/tsconfig.types.json +++ b/server/tsconfig.types.json @@ -1,16 +1,21 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../packages/types/dist/server", + "outDir": "../packages/types-generator/dist/server", + "tsBuildInfoFile": "../packages/types-generator/dist/server/.tsbuildinfo", "stripInternal": true, "removeComments": false, "emitDeclarationOnly": true }, "references": [ - { "path": "../shared/tsconfig.types.json" } + { "path": "../packages/core-utils" }, + { "path": "../packages/ffmpeg" }, + { "path": "../packages/models" }, + { "path": "../packages/node-utils" }, + { "path": "../packages/server-commands" }, + { "path": "../packages/typescript-utils" } ], "exclude": [ - "tools/", "tests/" ] } diff --git a/server/types/index.ts b/server/types/index.ts deleted file mode 100644 index 18d3827a5..000000000 --- a/server/types/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './plugins' -export * from './activitypub-processor.model' -export * from './sequelize' diff --git a/server/types/models/abuse/index.ts b/server/types/models/abuse/index.ts deleted file mode 100644 index 1ed91b249..000000000 --- a/server/types/models/abuse/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './abuse' -export * from './abuse-message' diff --git a/server/types/models/account/index.ts b/server/types/models/account/index.ts deleted file mode 100644 index 9679c01e4..000000000 --- a/server/types/models/account/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './account' -export * from './actor-custom-page' -export * from './account-blocklist' diff --git a/server/types/models/actor/index.ts b/server/types/models/actor/index.ts deleted file mode 100644 index b27815255..000000000 --- a/server/types/models/actor/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './actor-follow' -export * from './actor-image' -export * from './actor' diff --git a/server/types/models/application/index.ts b/server/types/models/application/index.ts deleted file mode 100644 index 26e4b031f..000000000 --- a/server/types/models/application/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './application' diff --git a/server/types/models/index.ts b/server/types/models/index.ts deleted file mode 100644 index 704cb9844..000000000 --- a/server/types/models/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from './abuse' -export * from './account' -export * from './actor' -export * from './application' -export * from './oauth' -export * from './server' -export * from './user' -export * from './video' diff --git a/server/types/models/oauth/index.ts b/server/types/models/oauth/index.ts deleted file mode 100644 index 36b7ea8ca..000000000 --- a/server/types/models/oauth/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './oauth-client' -export * from './oauth-token' diff --git a/server/types/models/runners/index.ts b/server/types/models/runners/index.ts deleted file mode 100644 index e94d4794e..000000000 --- a/server/types/models/runners/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './runner' -export * from './runner-job' -export * from './runner-registration-token' diff --git a/server/types/models/server/index.ts b/server/types/models/server/index.ts deleted file mode 100644 index c853795ad..000000000 --- a/server/types/models/server/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './plugin' -export * from './server' -export * from './server-blocklist' diff --git a/server/types/models/user/index.ts b/server/types/models/user/index.ts deleted file mode 100644 index 5738f4107..000000000 --- a/server/types/models/user/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './user' -export * from './user-notification' -export * from './user-notification-setting' -export * from './user-registration' -export * from './user-video-history' diff --git a/server/types/models/video/index.ts b/server/types/models/video/index.ts deleted file mode 100644 index 7f05db666..000000000 --- a/server/types/models/video/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -export * from './local-video-viewer-watch-section' -export * from './local-video-viewer-watch-section' -export * from './local-video-viewer' -export * from './storyboard' -export * from './schedule-video-update' -export * from './tag' -export * from './thumbnail' -export * from './video' -export * from './video-blacklist' -export * from './video-caption' -export * from './video-change-ownership' -export * from './video-channel-sync' -export * from './video-channels' -export * from './video-comment' -export * from './video-file' -export * from './video-import' -export * from './video-live-replay-setting' -export * from './video-live-session' -export * from './video-live' -export * from './video-password' -export * from './video-playlist' -export * from './video-playlist-element' -export * from './video-rate' -export * from './video-redundancy' -export * from './video-share' -export * from './video-streaming-playlist' diff --git a/server/types/models/video/tag.ts b/server/types/models/video/tag.ts deleted file mode 100644 index 64a68873e..000000000 --- a/server/types/models/video/tag.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { TagModel } from '../../../models/video/tag' - -export type MTag = Omit diff --git a/server/types/plugins/index.ts b/server/types/plugins/index.ts deleted file mode 100644 index bf9c35d49..000000000 --- a/server/types/plugins/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './plugin-library.model' -export * from './register-server-auth.model' -export * from './register-server-option.model' -export * from './register-server-websocket-route.model' diff --git a/shared/core-utils/abuse/index.ts b/shared/core-utils/abuse/index.ts deleted file mode 100644 index 244b83cff..000000000 --- a/shared/core-utils/abuse/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './abuse-predefined-reasons' diff --git a/shared/core-utils/common/index.ts b/shared/core-utils/common/index.ts deleted file mode 100644 index 8d63ee1b2..000000000 --- a/shared/core-utils/common/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -export * from './array' -export * from './random' -export * from './date' -export * from './env' -export * from './number' -export * from './object' -export * from './path' -export * from './regexp' -export * from './time' -export * from './promises' -export * from './url' -export * from './version' diff --git a/shared/core-utils/common/path.ts b/shared/core-utils/common/path.ts deleted file mode 100644 index 006505316..000000000 --- a/shared/core-utils/common/path.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { basename, extname, isAbsolute, join, resolve } from 'path' - -let rootPath: string - -function root () { - if (rootPath) return rootPath - - rootPath = __dirname - - if (basename(rootPath) === 'tools') rootPath = resolve(rootPath, '..') - if (basename(rootPath) === 'scripts') rootPath = resolve(rootPath, '..') - if (basename(rootPath) === 'common') rootPath = resolve(rootPath, '..') - if (basename(rootPath) === 'core-utils') rootPath = resolve(rootPath, '..') - if (basename(rootPath) === 'shared') rootPath = resolve(rootPath, '..') - if (basename(rootPath) === 'server') rootPath = resolve(rootPath, '..') - if (basename(rootPath) === 'dist') rootPath = resolve(rootPath, '..') - - return rootPath -} - -function buildPath (path: string) { - if (isAbsolute(path)) return path - - return join(root(), path) -} - -function getLowercaseExtension (filename: string) { - const ext = extname(filename) || '' - - return ext.toLowerCase() -} - -function buildAbsoluteFixturePath (path: string, customCIPath = false) { - if (isAbsolute(path)) return path - - if (customCIPath && process.env.GITHUB_WORKSPACE) { - return join(process.env.GITHUB_WORKSPACE, 'fixtures', path) - } - - return join(root(), 'server', 'tests', 'fixtures', path) -} - -export { - root, - buildPath, - buildAbsoluteFixturePath, - getLowercaseExtension -} diff --git a/shared/core-utils/i18n/index.ts b/shared/core-utils/i18n/index.ts deleted file mode 100644 index 8f7cbe2c7..000000000 --- a/shared/core-utils/i18n/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './i18n' diff --git a/shared/core-utils/index.ts b/shared/core-utils/index.ts deleted file mode 100644 index 8daaa2d04..000000000 --- a/shared/core-utils/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from './abuse' -export * from './common' -export * from './i18n' -export * from './plugins' -export * from './renderer' -export * from './users' -export * from './videos' diff --git a/shared/core-utils/plugins/index.ts b/shared/core-utils/plugins/index.ts deleted file mode 100644 index fc78d3512..000000000 --- a/shared/core-utils/plugins/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './hooks' diff --git a/shared/core-utils/renderer/index.ts b/shared/core-utils/renderer/index.ts deleted file mode 100644 index 0ad29d782..000000000 --- a/shared/core-utils/renderer/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './markdown' -export * from './html' diff --git a/shared/core-utils/users/index.ts b/shared/core-utils/users/index.ts deleted file mode 100644 index 1cbf0af1b..000000000 --- a/shared/core-utils/users/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './user-role' diff --git a/shared/core-utils/videos/index.ts b/shared/core-utils/videos/index.ts deleted file mode 100644 index 2cf319395..000000000 --- a/shared/core-utils/videos/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './bitrate' -export * from './common' diff --git a/shared/extra-utils/index.ts b/shared/extra-utils/index.ts deleted file mode 100644 index d4cfcbec8..000000000 --- a/shared/extra-utils/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './crypto' -export * from './file' -export * from './uuid' diff --git a/shared/ffmpeg/index.ts b/shared/ffmpeg/index.ts deleted file mode 100644 index 1dab292da..000000000 --- a/shared/ffmpeg/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -export * from './ffmpeg-command-wrapper' -export * from './ffmpeg-default-transcoding-profile' -export * from './ffmpeg-edition' -export * from './ffmpeg-images' -export * from './ffmpeg-live' -export * from './ffmpeg-utils' -export * from './ffmpeg-version' -export * from './ffmpeg-vod' -export * from './ffprobe' diff --git a/shared/ffmpeg/shared/index.ts b/shared/ffmpeg/shared/index.ts deleted file mode 100644 index 51de0316f..000000000 --- a/shared/ffmpeg/shared/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './encoder-options' -export * from './presets' diff --git a/shared/models/activitypub/index.ts b/shared/models/activitypub/index.ts deleted file mode 100644 index fa07b6a64..000000000 --- a/shared/models/activitypub/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -export * from './objects' -export * from './activity' -export * from './activitypub-actor' -export * from './activitypub-collection' -export * from './activitypub-ordered-collection' -export * from './activitypub-root' -export * from './activitypub-signature' -export * from './context' -export * from './webfinger' diff --git a/shared/models/activitypub/objects/activitypub-object.ts b/shared/models/activitypub/objects/activitypub-object.ts deleted file mode 100644 index faeac2618..000000000 --- a/shared/models/activitypub/objects/activitypub-object.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { AbuseObject } from './abuse-object' -import { CacheFileObject } from './cache-file-object' -import { PlaylistObject } from './playlist-object' -import { VideoCommentObject } from './video-comment-object' -import { VideoObject } from './video-object' -import { WatchActionObject } from './watch-action-object' - -export type ActivityObject = - VideoObject | - AbuseObject | - VideoCommentObject | - CacheFileObject | - PlaylistObject | - WatchActionObject | - string - -export type APObjectId = string | { id: string } diff --git a/shared/models/activitypub/objects/index.ts b/shared/models/activitypub/objects/index.ts deleted file mode 100644 index 753e02003..000000000 --- a/shared/models/activitypub/objects/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -export * from './abuse-object' -export * from './activitypub-object' -export * from './cache-file-object' -export * from './common-objects' -export * from './playlist-element-object' -export * from './playlist-object' -export * from './video-comment-object' -export * from './video-object' -export * from './watch-action-object' diff --git a/shared/models/actors/actor-image.type.ts b/shared/models/actors/actor-image.type.ts deleted file mode 100644 index ac8eb6bf2..000000000 --- a/shared/models/actors/actor-image.type.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const enum ActorImageType { - AVATAR = 1, - BANNER = 2 -} diff --git a/shared/models/actors/index.ts b/shared/models/actors/index.ts deleted file mode 100644 index e03f168cd..000000000 --- a/shared/models/actors/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './account.model' -export * from './actor-image.model' -export * from './actor-image.type' -export * from './actor.model' -export * from './custom-page.model' -export * from './follow.model' diff --git a/shared/models/bulk/index.ts b/shared/models/bulk/index.ts deleted file mode 100644 index 168c8cd48..000000000 --- a/shared/models/bulk/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './bulk-remove-comments-of-body.model' diff --git a/shared/models/common/index.ts b/shared/models/common/index.ts deleted file mode 100644 index 4db85eff2..000000000 --- a/shared/models/common/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './result-list.model' diff --git a/shared/models/custom-markup/index.ts b/shared/models/custom-markup/index.ts deleted file mode 100644 index 2898dfa90..000000000 --- a/shared/models/custom-markup/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './custom-markup-data.model' diff --git a/shared/models/feeds/feed-format.enum.ts b/shared/models/feeds/feed-format.enum.ts deleted file mode 100644 index d3d574331..000000000 --- a/shared/models/feeds/feed-format.enum.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const enum FeedFormat { - RSS = 'xml', - ATOM = 'atom', - JSON = 'json' -} diff --git a/shared/models/feeds/index.ts b/shared/models/feeds/index.ts deleted file mode 100644 index d56c8458c..000000000 --- a/shared/models/feeds/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './feed-format.enum' diff --git a/shared/models/http/index.ts b/shared/models/http/index.ts deleted file mode 100644 index ec991afe0..000000000 --- a/shared/models/http/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './http-error-codes' -export * from './http-methods' diff --git a/shared/models/index.ts b/shared/models/index.ts deleted file mode 100644 index 78f6e73e3..000000000 --- a/shared/models/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -export * from './activitypub' -export * from './actors' -export * from './bulk' -export * from './common' -export * from './custom-markup' -export * from './feeds' -export * from './http' -export * from './joinpeertube' -export * from './metrics' -export * from './moderation' -export * from './overviews' -export * from './plugins' -export * from './redundancy' -export * from './runners' -export * from './search' -export * from './server' -export * from './tokens' -export * from './users' -export * from './videos' diff --git a/shared/models/joinpeertube/index.ts b/shared/models/joinpeertube/index.ts deleted file mode 100644 index 9681c35ad..000000000 --- a/shared/models/joinpeertube/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './versions.model' diff --git a/shared/models/metrics/index.ts b/shared/models/metrics/index.ts deleted file mode 100644 index 24194cce3..000000000 --- a/shared/models/metrics/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './playback-metric-create.model' diff --git a/shared/models/moderation/abuse/abuse-reason.model.ts b/shared/models/moderation/abuse/abuse-reason.model.ts deleted file mode 100644 index 57359aef6..000000000 --- a/shared/models/moderation/abuse/abuse-reason.model.ts +++ /dev/null @@ -1,20 +0,0 @@ -export const enum AbusePredefinedReasons { - VIOLENT_OR_REPULSIVE = 1, - HATEFUL_OR_ABUSIVE, - SPAM_OR_MISLEADING, - PRIVACY, - RIGHTS, - SERVER_RULES, - THUMBNAILS, - CAPTIONS -} - -export type AbusePredefinedReasonsString = - 'violentOrRepulsive' | - 'hatefulOrAbusive' | - 'spamOrMisleading' | - 'privacy' | - 'rights' | - 'serverRules' | - 'thumbnails' | - 'captions' diff --git a/shared/models/moderation/abuse/abuse-state.model.ts b/shared/models/moderation/abuse/abuse-state.model.ts deleted file mode 100644 index 8ef6fdada..000000000 --- a/shared/models/moderation/abuse/abuse-state.model.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const enum AbuseState { - PENDING = 1, - REJECTED = 2, - ACCEPTED = 3 -} diff --git a/shared/models/moderation/abuse/abuse-update.model.ts b/shared/models/moderation/abuse/abuse-update.model.ts deleted file mode 100644 index 4360fe7ac..000000000 --- a/shared/models/moderation/abuse/abuse-update.model.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { AbuseState } from './abuse-state.model' - -export interface AbuseUpdate { - moderationComment?: string - - state?: AbuseState -} diff --git a/shared/models/moderation/abuse/index.ts b/shared/models/moderation/abuse/index.ts deleted file mode 100644 index b518517a6..000000000 --- a/shared/models/moderation/abuse/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from './abuse-create.model' -export * from './abuse-filter.type' -export * from './abuse-message.model' -export * from './abuse-reason.model' -export * from './abuse-state.model' -export * from './abuse-update.model' -export * from './abuse-video-is.type' -export * from './abuse.model' diff --git a/shared/models/moderation/index.ts b/shared/models/moderation/index.ts deleted file mode 100644 index f8e6d351c..000000000 --- a/shared/models/moderation/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './abuse' -export * from './block-status.model' -export * from './account-block.model' -export * from './server-block.model' diff --git a/shared/models/nodeinfo/index.ts b/shared/models/nodeinfo/index.ts deleted file mode 100644 index faa64302a..000000000 --- a/shared/models/nodeinfo/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './nodeinfo.model' diff --git a/shared/models/overviews/index.ts b/shared/models/overviews/index.ts deleted file mode 100644 index 468507c6b..000000000 --- a/shared/models/overviews/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './videos-overview.model' diff --git a/shared/models/plugins/client/index.ts b/shared/models/plugins/client/index.ts deleted file mode 100644 index f3e3fcbcf..000000000 --- a/shared/models/plugins/client/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from './client-hook.model' -export * from './plugin-client-scope.type' -export * from './plugin-element-placeholder.type' -export * from './plugin-selector-id.type' -export * from './register-client-form-field.model' -export * from './register-client-hook.model' -export * from './register-client-route.model' -export * from './register-client-settings-script.model' diff --git a/shared/models/plugins/hook-type.enum.ts b/shared/models/plugins/hook-type.enum.ts deleted file mode 100644 index a96c943f1..000000000 --- a/shared/models/plugins/hook-type.enum.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const enum HookType { - STATIC = 1, - ACTION = 2, - FILTER = 3 -} diff --git a/shared/models/plugins/index.ts b/shared/models/plugins/index.ts deleted file mode 100644 index cbbe4916e..000000000 --- a/shared/models/plugins/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './client' -export * from './plugin-index' -export * from './server' -export * from './hook-type.enum' -export * from './plugin-package-json.model' -export * from './plugin.type' diff --git a/shared/models/plugins/plugin-index/index.ts b/shared/models/plugins/plugin-index/index.ts deleted file mode 100644 index 913846638..000000000 --- a/shared/models/plugins/plugin-index/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './peertube-plugin-index-list.model' -export * from './peertube-plugin-index.model' -export * from './peertube-plugin-latest-version.model' diff --git a/shared/models/plugins/plugin.type.ts b/shared/models/plugins/plugin.type.ts deleted file mode 100644 index 016219ceb..000000000 --- a/shared/models/plugins/plugin.type.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const enum PluginType { - PLUGIN = 1, - THEME = 2 -} diff --git a/shared/models/plugins/server/api/index.ts b/shared/models/plugins/server/api/index.ts deleted file mode 100644 index eb59a03f0..000000000 --- a/shared/models/plugins/server/api/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './install-plugin.model' -export * from './manage-plugin.model' -export * from './peertube-plugin.model' diff --git a/shared/models/plugins/server/index.ts b/shared/models/plugins/server/index.ts deleted file mode 100644 index d3ff49d3b..000000000 --- a/shared/models/plugins/server/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './api' -export * from './managers' -export * from './settings' -export * from './plugin-translation.model' -export * from './register-server-hook.model' -export * from './server-hook.model' diff --git a/shared/models/plugins/server/managers/index.ts b/shared/models/plugins/server/managers/index.ts deleted file mode 100644 index 49365a854..000000000 --- a/shared/models/plugins/server/managers/index.ts +++ /dev/null @@ -1,9 +0,0 @@ - -export * from './plugin-playlist-privacy-manager.model' -export * from './plugin-settings-manager.model' -export * from './plugin-storage-manager.model' -export * from './plugin-transcoding-manager.model' -export * from './plugin-video-category-manager.model' -export * from './plugin-video-language-manager.model' -export * from './plugin-video-licence-manager.model' -export * from './plugin-video-privacy-manager.model' diff --git a/shared/models/plugins/server/settings/index.ts b/shared/models/plugins/server/settings/index.ts deleted file mode 100644 index b456de019..000000000 --- a/shared/models/plugins/server/settings/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './public-server.setting' -export * from './register-server-setting.model' diff --git a/shared/models/redundancy/index.ts b/shared/models/redundancy/index.ts deleted file mode 100644 index 641a5d625..000000000 --- a/shared/models/redundancy/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './video-redundancies-filters.model' -export * from './video-redundancy-config-filter.type' -export * from './video-redundancy.model' -export * from './videos-redundancy-strategy.model' diff --git a/shared/models/runners/index.ts b/shared/models/runners/index.ts deleted file mode 100644 index a52b82d2e..000000000 --- a/shared/models/runners/index.ts +++ /dev/null @@ -1,21 +0,0 @@ -export * from './abort-runner-job-body.model' -export * from './accept-runner-job-body.model' -export * from './accept-runner-job-result.model' -export * from './error-runner-job-body.model' -export * from './list-runner-jobs-query.model' -export * from './list-runner-registration-tokens.model' -export * from './list-runners-query.model' -export * from './register-runner-body.model' -export * from './register-runner-result.model' -export * from './request-runner-job-body.model' -export * from './request-runner-job-result.model' -export * from './runner-job-payload.model' -export * from './runner-job-private-payload.model' -export * from './runner-job-state.model' -export * from './runner-job-success-body.model' -export * from './runner-job-type.type' -export * from './runner-job-update-body.model' -export * from './runner-job.model' -export * from './runner-registration-token' -export * from './runner.model' -export * from './unregister-runner-body.model' diff --git a/shared/models/runners/runner-job-state.model.ts b/shared/models/runners/runner-job-state.model.ts deleted file mode 100644 index 7ed34b3bf..000000000 --- a/shared/models/runners/runner-job-state.model.ts +++ /dev/null @@ -1,11 +0,0 @@ -export enum RunnerJobState { - PENDING = 1, - PROCESSING = 2, - COMPLETED = 3, - ERRORED = 4, - WAITING_FOR_PARENT_JOB = 5, - CANCELLED = 6, - PARENT_ERRORED = 7, - PARENT_CANCELLED = 8, - COMPLETING = 9 -} diff --git a/shared/models/search/index.ts b/shared/models/search/index.ts deleted file mode 100644 index 50aeeddc8..000000000 --- a/shared/models/search/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './boolean-both-query.model' -export * from './search-target-query.model' -export * from './videos-common-query.model' -export * from './video-channels-search-query.model' -export * from './video-playlists-search-query.model' -export * from './videos-search-query.model' diff --git a/shared/models/server/index.ts b/shared/models/server/index.ts deleted file mode 100644 index a9136f3d4..000000000 --- a/shared/models/server/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -export * from './about.model' -export * from './broadcast-message-level.type' -export * from './client-log-create.model' -export * from './client-log-level.type' -export * from './contact-form.model' -export * from './custom-config.model' -export * from './debug.model' -export * from './emailer.model' -export * from './job.model' -export * from './peertube-problem-document.model' -export * from './server-config.model' -export * from './server-debug.model' -export * from './server-error-code.enum' -export * from './server-follow-create.model' -export * from './server-log-level.type' -export * from './server-stats.model' diff --git a/shared/models/tokens/index.ts b/shared/models/tokens/index.ts deleted file mode 100644 index fe130f153..000000000 --- a/shared/models/tokens/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './oauth-client-local.model' diff --git a/shared/models/users/index.ts b/shared/models/users/index.ts deleted file mode 100644 index 4a050c870..000000000 --- a/shared/models/users/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -export * from './registration' -export * from './two-factor-enable-result.model' -export * from './user-create-result.model' -export * from './user-create.model' -export * from './user-flag.model' -export * from './user-login.model' -export * from './user-notification-setting.model' -export * from './user-notification.model' -export * from './user-refresh-token.model' -export * from './user-right.enum' -export * from './user-role' -export * from './user-scoped-token' -export * from './user-update-me.model' -export * from './user-update.model' -export * from './user-video-quota.model' -export * from './user.model' diff --git a/shared/models/users/registration/index.ts b/shared/models/users/registration/index.ts deleted file mode 100644 index 593740c4f..000000000 --- a/shared/models/users/registration/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './user-register.model' -export * from './user-registration-request.model' -export * from './user-registration-state.model' -export * from './user-registration-update-state.model' -export * from './user-registration.model' diff --git a/shared/models/users/registration/user-registration-state.model.ts b/shared/models/users/registration/user-registration-state.model.ts deleted file mode 100644 index e4c835f78..000000000 --- a/shared/models/users/registration/user-registration-state.model.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const enum UserRegistrationState { - PENDING = 1, - REJECTED = 2, - ACCEPTED = 3 -} diff --git a/shared/models/users/user-flag.model.ts b/shared/models/users/user-flag.model.ts deleted file mode 100644 index b791a1263..000000000 --- a/shared/models/users/user-flag.model.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const enum UserAdminFlag { - NONE = 0, - BYPASS_VIDEO_AUTO_BLACKLIST = 1 << 0 -} diff --git a/shared/models/users/user-notification-setting.model.ts b/shared/models/users/user-notification-setting.model.ts deleted file mode 100644 index 278a05e7a..000000000 --- a/shared/models/users/user-notification-setting.model.ts +++ /dev/null @@ -1,32 +0,0 @@ -export const enum UserNotificationSettingValue { - NONE = 0, - WEB = 1 << 0, - EMAIL = 1 << 1 -} - -export interface UserNotificationSetting { - abuseAsModerator: UserNotificationSettingValue - videoAutoBlacklistAsModerator: UserNotificationSettingValue - newUserRegistration: UserNotificationSettingValue - - newVideoFromSubscription: UserNotificationSettingValue - - blacklistOnMyVideo: UserNotificationSettingValue - myVideoPublished: UserNotificationSettingValue - myVideoImportFinished: UserNotificationSettingValue - - commentMention: UserNotificationSettingValue - newCommentOnMyVideo: UserNotificationSettingValue - - newFollow: UserNotificationSettingValue - newInstanceFollower: UserNotificationSettingValue - autoInstanceFollowing: UserNotificationSettingValue - - abuseStateChange: UserNotificationSettingValue - abuseNewMessage: UserNotificationSettingValue - - newPeerTubeVersion: UserNotificationSettingValue - newPluginVersion: UserNotificationSettingValue - - myVideoStudioEditionFinished: UserNotificationSettingValue -} diff --git a/shared/models/users/user-right.enum.ts b/shared/models/users/user-right.enum.ts deleted file mode 100644 index a5a770b75..000000000 --- a/shared/models/users/user-right.enum.ts +++ /dev/null @@ -1,51 +0,0 @@ -export const enum UserRight { - ALL = 0, - - MANAGE_USERS = 1, - - MANAGE_SERVER_FOLLOW = 2, - - MANAGE_LOGS = 3, - - MANAGE_DEBUG = 4, - - MANAGE_SERVER_REDUNDANCY = 5, - - MANAGE_ABUSES = 6, - - MANAGE_JOBS = 7, - - MANAGE_CONFIGURATION = 8, - MANAGE_INSTANCE_CUSTOM_PAGE = 9, - - MANAGE_ACCOUNTS_BLOCKLIST = 10, - MANAGE_SERVERS_BLOCKLIST = 11, - - MANAGE_VIDEO_BLACKLIST = 12, - MANAGE_ANY_VIDEO_CHANNEL = 13, - - REMOVE_ANY_VIDEO = 14, - REMOVE_ANY_VIDEO_PLAYLIST = 15, - REMOVE_ANY_VIDEO_COMMENT = 16, - - UPDATE_ANY_VIDEO = 17, - UPDATE_ANY_VIDEO_PLAYLIST = 18, - - GET_ANY_LIVE = 19, - SEE_ALL_VIDEOS = 20, - SEE_ALL_COMMENTS = 21, - CHANGE_VIDEO_OWNERSHIP = 22, - - MANAGE_PLUGINS = 23, - - MANAGE_VIDEOS_REDUNDANCIES = 24, - - MANAGE_VIDEO_FILES = 25, - RUN_VIDEO_TRANSCODING = 26, - - MANAGE_VIDEO_IMPORTS = 27, - - MANAGE_REGISTRATIONS = 28, - - MANAGE_RUNNERS = 29 -} diff --git a/shared/models/users/user-role.ts b/shared/models/users/user-role.ts deleted file mode 100644 index 687a2aa0d..000000000 --- a/shared/models/users/user-role.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Keep the order -export const enum UserRole { - ADMINISTRATOR = 0, - MODERATOR = 1, - USER = 2 -} diff --git a/shared/models/videos/blacklist/index.ts b/shared/models/videos/blacklist/index.ts deleted file mode 100644 index 66082be34..000000000 --- a/shared/models/videos/blacklist/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './video-blacklist.model' -export * from './video-blacklist-create.model' -export * from './video-blacklist-update.model' diff --git a/shared/models/videos/blacklist/video-blacklist.model.ts b/shared/models/videos/blacklist/video-blacklist.model.ts deleted file mode 100644 index 982a34592..000000000 --- a/shared/models/videos/blacklist/video-blacklist.model.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Video } from '../video.model' - -export const enum VideoBlacklistType { - MANUAL = 1, - AUTO_BEFORE_PUBLISHED = 2 -} - -export interface VideoBlacklist { - id: number - unfederated: boolean - reason?: string - type: VideoBlacklistType - - video: Video - - createdAt: Date - updatedAt: Date -} diff --git a/shared/models/videos/caption/index.ts b/shared/models/videos/caption/index.ts deleted file mode 100644 index 2a5ff512d..000000000 --- a/shared/models/videos/caption/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './video-caption.model' -export * from './video-caption-update.model' diff --git a/shared/models/videos/change-ownership/index.ts b/shared/models/videos/change-ownership/index.ts deleted file mode 100644 index a942fb2cd..000000000 --- a/shared/models/videos/change-ownership/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './video-change-ownership-accept.model' -export * from './video-change-ownership-create.model' -export * from './video-change-ownership.model' diff --git a/shared/models/videos/change-ownership/video-change-ownership.model.ts b/shared/models/videos/change-ownership/video-change-ownership.model.ts deleted file mode 100644 index 3d31cad0a..000000000 --- a/shared/models/videos/change-ownership/video-change-ownership.model.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Account } from '../../actors' -import { Video } from '../video.model' - -export interface VideoChangeOwnership { - id: number - status: VideoChangeOwnershipStatus - initiatorAccount: Account - nextOwnerAccount: Account - video: Video - createdAt: Date -} - -export const enum VideoChangeOwnershipStatus { - WAITING = 'WAITING', - ACCEPTED = 'ACCEPTED', - REFUSED = 'REFUSED' -} diff --git a/shared/models/videos/channel-sync/index.ts b/shared/models/videos/channel-sync/index.ts deleted file mode 100644 index 7d25aaac3..000000000 --- a/shared/models/videos/channel-sync/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './video-channel-sync-state.enum' -export * from './video-channel-sync.model' -export * from './video-channel-sync-create.model' diff --git a/shared/models/videos/channel-sync/video-channel-sync-state.enum.ts b/shared/models/videos/channel-sync/video-channel-sync-state.enum.ts deleted file mode 100644 index 3e9f5ddc2..000000000 --- a/shared/models/videos/channel-sync/video-channel-sync-state.enum.ts +++ /dev/null @@ -1,6 +0,0 @@ -export const enum VideoChannelSyncState { - WAITING_FIRST_RUN = 1, - PROCESSING = 2, - SYNCED = 3, - FAILED = 4 -} diff --git a/shared/models/videos/channel/index.ts b/shared/models/videos/channel/index.ts deleted file mode 100644 index 6cdabffbd..000000000 --- a/shared/models/videos/channel/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './video-channel-create-result.model' -export * from './video-channel-create.model' -export * from './video-channel-update.model' -export * from './video-channel.model' diff --git a/shared/models/videos/comment/index.ts b/shared/models/videos/comment/index.ts deleted file mode 100644 index 80c6c0724..000000000 --- a/shared/models/videos/comment/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './video-comment-create.model' -export * from './video-comment.model' diff --git a/shared/models/videos/file/index.ts b/shared/models/videos/file/index.ts deleted file mode 100644 index 78a784a3c..000000000 --- a/shared/models/videos/file/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './video-file-metadata.model' -export * from './video-file.model' -export * from './video-resolution.enum' diff --git a/shared/models/videos/file/video-resolution.enum.ts b/shared/models/videos/file/video-resolution.enum.ts deleted file mode 100644 index 5b48ad353..000000000 --- a/shared/models/videos/file/video-resolution.enum.ts +++ /dev/null @@ -1,11 +0,0 @@ -export const enum VideoResolution { - H_NOVIDEO = 0, - H_144P = 144, - H_240P = 240, - H_360P = 360, - H_480P = 480, - H_720P = 720, - H_1080P = 1080, - H_1440P = 1440, - H_4K = 2160 -} diff --git a/shared/models/videos/import/index.ts b/shared/models/videos/import/index.ts deleted file mode 100644 index b38a67b5f..000000000 --- a/shared/models/videos/import/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './video-import-create.model' -export * from './video-import-state.enum' -export * from './video-import.model' -export * from './videos-import-in-channel-create.model' diff --git a/shared/models/videos/import/video-import-state.enum.ts b/shared/models/videos/import/video-import-state.enum.ts deleted file mode 100644 index ff5c6beff..000000000 --- a/shared/models/videos/import/video-import-state.enum.ts +++ /dev/null @@ -1,8 +0,0 @@ -export const enum VideoImportState { - PENDING = 1, - SUCCESS = 2, - FAILED = 3, - REJECTED = 4, - CANCELLED = 5, - PROCESSING = 6 -} diff --git a/shared/models/videos/index.ts b/shared/models/videos/index.ts deleted file mode 100644 index f8f1ce081..000000000 --- a/shared/models/videos/index.ts +++ /dev/null @@ -1,42 +0,0 @@ -export * from './blacklist' -export * from './caption' -export * from './change-ownership' -export * from './channel' -export * from './comment' -export * from './studio' -export * from './live' -export * from './file' -export * from './import' -export * from './playlist' -export * from './rate' -export * from './stats' -export * from './transcoding' -export * from './channel-sync' - -export * from './nsfw-policy.type' - -export * from './storyboard.model' -export * from './thumbnail.type' - -export * from './video-constant.model' -export * from './video-create.model' - -export * from './video-privacy.enum' -export * from './video-include.enum' -export * from './video-rate.type' - -export * from './video-schedule-update.model' -export * from './video-sort-field.type' -export * from './video-state.enum' -export * from './video-storage.enum' - -export * from './video-streaming-playlist.model' -export * from './video-streaming-playlist.type' - -export * from './video-token.model' - -export * from './video-update.model' -export * from './video-view.model' -export * from './video.model' -export * from './video-create-result.model' -export * from './video-password.model' diff --git a/shared/models/videos/live/index.ts b/shared/models/videos/live/index.ts deleted file mode 100644 index 07b59fe2c..000000000 --- a/shared/models/videos/live/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from './live-video-create.model' -export * from './live-video-error.enum' -export * from './live-video-event-payload.model' -export * from './live-video-event.type' -export * from './live-video-latency-mode.enum' -export * from './live-video-session.model' -export * from './live-video-update.model' -export * from './live-video.model' diff --git a/shared/models/videos/live/live-video-create.model.ts b/shared/models/videos/live/live-video-create.model.ts deleted file mode 100644 index f8ae9e5a9..000000000 --- a/shared/models/videos/live/live-video-create.model.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { VideoCreate } from '../video-create.model' -import { VideoPrivacy } from '../video-privacy.enum' -import { LiveVideoLatencyMode } from './live-video-latency-mode.enum' - -export interface LiveVideoCreate extends VideoCreate { - permanentLive?: boolean - latencyMode?: LiveVideoLatencyMode - - saveReplay?: boolean - replaySettings?: { privacy: VideoPrivacy } -} diff --git a/shared/models/videos/live/live-video-error.enum.ts b/shared/models/videos/live/live-video-error.enum.ts deleted file mode 100644 index a26453505..000000000 --- a/shared/models/videos/live/live-video-error.enum.ts +++ /dev/null @@ -1,9 +0,0 @@ -export const enum LiveVideoError { - BAD_SOCKET_HEALTH = 1, - DURATION_EXCEEDED = 2, - QUOTA_EXCEEDED = 3, - FFMPEG_ERROR = 4, - BLACKLISTED = 5, - RUNNER_JOB_ERROR = 6, - RUNNER_JOB_CANCEL = 7 -} diff --git a/shared/models/videos/live/live-video-event-payload.model.ts b/shared/models/videos/live/live-video-event-payload.model.ts deleted file mode 100644 index 646856ac3..000000000 --- a/shared/models/videos/live/live-video-event-payload.model.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { VideoState } from '../video-state.enum' - -export interface LiveVideoEventPayload { - state?: VideoState - - viewers?: number -} diff --git a/shared/models/videos/live/live-video-latency-mode.enum.ts b/shared/models/videos/live/live-video-latency-mode.enum.ts deleted file mode 100644 index 4285e1d41..000000000 --- a/shared/models/videos/live/live-video-latency-mode.enum.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const enum LiveVideoLatencyMode { - DEFAULT = 1, - HIGH_LATENCY = 2, - SMALL_LATENCY = 3 -} diff --git a/shared/models/videos/live/live-video-update.model.ts b/shared/models/videos/live/live-video-update.model.ts deleted file mode 100644 index d6aa6fb37..000000000 --- a/shared/models/videos/live/live-video-update.model.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { VideoPrivacy } from '../video-privacy.enum' -import { LiveVideoLatencyMode } from './live-video-latency-mode.enum' - -export interface LiveVideoUpdate { - permanentLive?: boolean - saveReplay?: boolean - replaySettings?: { privacy: VideoPrivacy } - latencyMode?: LiveVideoLatencyMode -} diff --git a/shared/models/videos/live/live-video.model.ts b/shared/models/videos/live/live-video.model.ts deleted file mode 100644 index fd8454123..000000000 --- a/shared/models/videos/live/live-video.model.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { VideoPrivacy } from '../video-privacy.enum' -import { LiveVideoLatencyMode } from './live-video-latency-mode.enum' - -export interface LiveVideo { - // If owner - rtmpUrl?: string - rtmpsUrl?: string - streamKey?: string - - saveReplay: boolean - replaySettings?: { privacy: VideoPrivacy } - permanentLive: boolean - latencyMode: LiveVideoLatencyMode -} diff --git a/shared/models/videos/playlist/index.ts b/shared/models/videos/playlist/index.ts deleted file mode 100644 index a9e8ce496..000000000 --- a/shared/models/videos/playlist/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -export * from './video-exist-in-playlist.model' -export * from './video-playlist-create-result.model' -export * from './video-playlist-create.model' -export * from './video-playlist-element-create-result.model' -export * from './video-playlist-element-create.model' -export * from './video-playlist-element-update.model' -export * from './video-playlist-element.model' -export * from './video-playlist-privacy.model' -export * from './video-playlist-reorder.model' -export * from './video-playlist-type.model' -export * from './video-playlist-update.model' -export * from './video-playlist.model' diff --git a/shared/models/videos/playlist/video-playlist-element.model.ts b/shared/models/videos/playlist/video-playlist-element.model.ts deleted file mode 100644 index df9e3b5cf..000000000 --- a/shared/models/videos/playlist/video-playlist-element.model.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Video } from '../video.model' - -export const enum VideoPlaylistElementType { - REGULAR = 0, - DELETED = 1, - PRIVATE = 2, - UNAVAILABLE = 3 // Blacklisted, blocked by the user/instance, NSFW... -} - -export interface VideoPlaylistElement { - id: number - position: number - startTimestamp: number - stopTimestamp: number - - type: VideoPlaylistElementType - - video?: Video -} diff --git a/shared/models/videos/playlist/video-playlist-privacy.model.ts b/shared/models/videos/playlist/video-playlist-privacy.model.ts deleted file mode 100644 index 480e1f104..000000000 --- a/shared/models/videos/playlist/video-playlist-privacy.model.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const enum VideoPlaylistPrivacy { - PUBLIC = 1, - UNLISTED = 2, - PRIVATE = 3 -} diff --git a/shared/models/videos/playlist/video-playlist-type.model.ts b/shared/models/videos/playlist/video-playlist-type.model.ts deleted file mode 100644 index 7f51a6354..000000000 --- a/shared/models/videos/playlist/video-playlist-type.model.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const enum VideoPlaylistType { - REGULAR = 1, - WATCH_LATER = 2 -} diff --git a/shared/models/videos/playlist/video-playlist.model.ts b/shared/models/videos/playlist/video-playlist.model.ts deleted file mode 100644 index b8a9955d9..000000000 --- a/shared/models/videos/playlist/video-playlist.model.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { AccountSummary } from '../../actors/index' -import { VideoChannelSummary, VideoConstant } from '..' -import { VideoPlaylistPrivacy } from './video-playlist-privacy.model' -import { VideoPlaylistType } from './video-playlist-type.model' - -export interface VideoPlaylist { - id: number - uuid: string - shortUUID: string - - isLocal: boolean - - url: string - - displayName: string - description: string - privacy: VideoConstant - - thumbnailPath: string - thumbnailUrl?: string - - videosLength: number - - type: VideoConstant - - embedPath: string - embedUrl?: string - - createdAt: Date | string - updatedAt: Date | string - - ownerAccount: AccountSummary - videoChannel?: VideoChannelSummary -} diff --git a/shared/models/videos/rate/account-video-rate.model.ts b/shared/models/videos/rate/account-video-rate.model.ts deleted file mode 100644 index e789367dc..000000000 --- a/shared/models/videos/rate/account-video-rate.model.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { UserVideoRateType } from './user-video-rate.type' -import { Video } from '../video.model' - -export interface AccountVideoRate { - video: Video - rating: UserVideoRateType -} diff --git a/shared/models/videos/rate/index.ts b/shared/models/videos/rate/index.ts deleted file mode 100644 index 06aa691bd..000000000 --- a/shared/models/videos/rate/index.ts +++ /dev/null @@ -1,5 +0,0 @@ - -export * from './user-video-rate-update.model' -export * from './user-video-rate.model' -export * from './account-video-rate.model' -export * from './user-video-rate.type' diff --git a/shared/models/videos/stats/index.ts b/shared/models/videos/stats/index.ts deleted file mode 100644 index a9b203f58..000000000 --- a/shared/models/videos/stats/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './video-stats-overall-query.model' -export * from './video-stats-overall.model' -export * from './video-stats-retention.model' -export * from './video-stats-timeserie-query.model' -export * from './video-stats-timeserie-metric.type' -export * from './video-stats-timeserie.model' diff --git a/shared/models/videos/studio/index.ts b/shared/models/videos/studio/index.ts deleted file mode 100644 index a1eb98a49..000000000 --- a/shared/models/videos/studio/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './video-studio-create-edit.model' diff --git a/shared/models/videos/thumbnail.type.ts b/shared/models/videos/thumbnail.type.ts deleted file mode 100644 index 6907b2802..000000000 --- a/shared/models/videos/thumbnail.type.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const enum ThumbnailType { - MINIATURE = 1, - PREVIEW = 2 -} diff --git a/shared/models/videos/transcoding/index.ts b/shared/models/videos/transcoding/index.ts deleted file mode 100644 index 14472d900..000000000 --- a/shared/models/videos/transcoding/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './video-transcoding-create.model' -export * from './video-transcoding-fps.model' -export * from './video-transcoding.model' diff --git a/shared/models/videos/video-include.enum.ts b/shared/models/videos/video-include.enum.ts deleted file mode 100644 index 32ee12e86..000000000 --- a/shared/models/videos/video-include.enum.ts +++ /dev/null @@ -1,8 +0,0 @@ -export const enum VideoInclude { - NONE = 0, - NOT_PUBLISHED_STATE = 1 << 0, - BLACKLISTED = 1 << 1, - BLOCKED_OWNER = 1 << 2, - FILES = 1 << 3, - CAPTIONS = 1 << 4 -} diff --git a/shared/models/videos/video-privacy.enum.ts b/shared/models/videos/video-privacy.enum.ts deleted file mode 100644 index 12e1d196f..000000000 --- a/shared/models/videos/video-privacy.enum.ts +++ /dev/null @@ -1,7 +0,0 @@ -export const enum VideoPrivacy { - PUBLIC = 1, - UNLISTED = 2, - PRIVATE = 3, - INTERNAL = 4, - PASSWORD_PROTECTED = 5 -} diff --git a/shared/models/videos/video-schedule-update.model.ts b/shared/models/videos/video-schedule-update.model.ts deleted file mode 100644 index 87d74f654..000000000 --- a/shared/models/videos/video-schedule-update.model.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { VideoPrivacy } from './video-privacy.enum' - -export interface VideoScheduleUpdate { - updateAt: Date | string - privacy?: VideoPrivacy.PUBLIC | VideoPrivacy.UNLISTED | VideoPrivacy.INTERNAL // Cannot schedule an update to PRIVATE -} diff --git a/shared/models/videos/video-state.enum.ts b/shared/models/videos/video-state.enum.ts deleted file mode 100644 index e45e4adc2..000000000 --- a/shared/models/videos/video-state.enum.ts +++ /dev/null @@ -1,11 +0,0 @@ -export const enum VideoState { - PUBLISHED = 1, - TO_TRANSCODE = 2, - TO_IMPORT = 3, - WAITING_FOR_LIVE = 4, - LIVE_ENDED = 5, - TO_MOVE_TO_EXTERNAL_STORAGE = 6, - TRANSCODING_FAILED = 7, - TO_MOVE_TO_EXTERNAL_STORAGE_FAILED = 8, - TO_EDIT = 9 -} diff --git a/shared/models/videos/video-storage.enum.ts b/shared/models/videos/video-storage.enum.ts deleted file mode 100644 index 7c6690db2..000000000 --- a/shared/models/videos/video-storage.enum.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const enum VideoStorage { - FILE_SYSTEM, - OBJECT_STORAGE, -} diff --git a/shared/models/videos/video-streaming-playlist.type.ts b/shared/models/videos/video-streaming-playlist.type.ts deleted file mode 100644 index e2e2b93ea..000000000 --- a/shared/models/videos/video-streaming-playlist.type.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const enum VideoStreamingPlaylistType { - HLS = 1 -} diff --git a/shared/server-commands/bulk/index.ts b/shared/server-commands/bulk/index.ts deleted file mode 100644 index 391597243..000000000 --- a/shared/server-commands/bulk/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './bulk-command' diff --git a/shared/server-commands/cli/index.ts b/shared/server-commands/cli/index.ts deleted file mode 100644 index 91b5abfbe..000000000 --- a/shared/server-commands/cli/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './cli-command' diff --git a/shared/server-commands/custom-pages/index.ts b/shared/server-commands/custom-pages/index.ts deleted file mode 100644 index 58aed04f2..000000000 --- a/shared/server-commands/custom-pages/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './custom-pages-command' diff --git a/shared/server-commands/feeds/index.ts b/shared/server-commands/feeds/index.ts deleted file mode 100644 index 662a22b6f..000000000 --- a/shared/server-commands/feeds/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './feeds-command' diff --git a/shared/server-commands/index.ts b/shared/server-commands/index.ts deleted file mode 100644 index a4581dbc0..000000000 --- a/shared/server-commands/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -export * from './bulk' -export * from './cli' -export * from './custom-pages' -export * from './feeds' -export * from './logs' -export * from './moderation' -export * from './overviews' -export * from './requests' -export * from './runners' -export * from './search' -export * from './server' -export * from './socket' -export * from './users' -export * from './videos' diff --git a/shared/server-commands/logs/index.ts b/shared/server-commands/logs/index.ts deleted file mode 100644 index 69452d7f0..000000000 --- a/shared/server-commands/logs/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './logs-command' diff --git a/shared/server-commands/moderation/index.ts b/shared/server-commands/moderation/index.ts deleted file mode 100644 index b37643956..000000000 --- a/shared/server-commands/moderation/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './abuses-command' diff --git a/shared/server-commands/overviews/index.ts b/shared/server-commands/overviews/index.ts deleted file mode 100644 index e19551907..000000000 --- a/shared/server-commands/overviews/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './overviews-command' diff --git a/shared/server-commands/requests/index.ts b/shared/server-commands/requests/index.ts deleted file mode 100644 index 802982301..000000000 --- a/shared/server-commands/requests/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './requests' diff --git a/shared/server-commands/runners/index.ts b/shared/server-commands/runners/index.ts deleted file mode 100644 index 9e8e1baf2..000000000 --- a/shared/server-commands/runners/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './runner-jobs-command' -export * from './runner-registration-tokens-command' -export * from './runners-command' diff --git a/shared/server-commands/search/index.ts b/shared/server-commands/search/index.ts deleted file mode 100644 index 48dbe8ae9..000000000 --- a/shared/server-commands/search/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './search-command' diff --git a/shared/server-commands/server/index.ts b/shared/server-commands/server/index.ts deleted file mode 100644 index 9a2fbf8d3..000000000 --- a/shared/server-commands/server/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -export * from './config-command' -export * from './contact-form-command' -export * from './debug-command' -export * from './follows-command' -export * from './follows' -export * from './jobs' -export * from './jobs-command' -export * from './metrics-command' -export * from './object-storage-command' -export * from './plugins-command' -export * from './redundancy-command' -export * from './server' -export * from './servers-command' -export * from './servers' -export * from './stats-command' diff --git a/shared/server-commands/shared/index.ts b/shared/server-commands/shared/index.ts deleted file mode 100644 index e807ab4f7..000000000 --- a/shared/server-commands/shared/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './abstract-command' diff --git a/shared/server-commands/socket/index.ts b/shared/server-commands/socket/index.ts deleted file mode 100644 index 594329b2f..000000000 --- a/shared/server-commands/socket/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './socket-io-command' diff --git a/shared/server-commands/users/index.ts b/shared/server-commands/users/index.ts deleted file mode 100644 index 404756539..000000000 --- a/shared/server-commands/users/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -export * from './accounts-command' -export * from './accounts' -export * from './blocklist-command' -export * from './login' -export * from './login-command' -export * from './notifications-command' -export * from './registrations-command' -export * from './subscriptions-command' -export * from './two-factor-command' -export * from './users-command' diff --git a/shared/server-commands/videos/index.ts b/shared/server-commands/videos/index.ts deleted file mode 100644 index 106d80af0..000000000 --- a/shared/server-commands/videos/index.ts +++ /dev/null @@ -1,21 +0,0 @@ -export * from './blacklist-command' -export * from './captions-command' -export * from './change-ownership-command' -export * from './channels' -export * from './channels-command' -export * from './channel-syncs-command' -export * from './comments-command' -export * from './history-command' -export * from './imports-command' -export * from './live-command' -export * from './live' -export * from './playlists-command' -export * from './services-command' -export * from './storyboard-command' -export * from './streaming-playlists-command' -export * from './comments-command' -export * from './video-studio-command' -export * from './video-token-command' -export * from './views-command' -export * from './videos-command' -export * from './video-passwords-command' diff --git a/shared/tsconfig.json b/shared/tsconfig.json deleted file mode 100644 index 95892077b..000000000 --- a/shared/tsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "../dist/shared" - } -} diff --git a/shared/typescript-utils/index.ts b/shared/typescript-utils/index.ts deleted file mode 100644 index c9f6f047d..000000000 --- a/shared/typescript-utils/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './types' diff --git a/support/doc/api/embeds.md b/support/doc/api/embeds.md index fd5507e38..989c8e98e 100644 --- a/support/doc/api/embeds.md +++ b/support/doc/api/embeds.md @@ -20,7 +20,7 @@ yarn add @peertube/embed-api Now just use the `PeerTubePlayer` class exported by the module: ```typescript -import { PeerTubePlayer } from '@peertube/embed-api' +import { PeerTubePlayer } from '@peertube/embed-api.js' ... ``` diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yaml index 0cbc58678..5d54a7a51 100644 --- a/support/doc/api/openapi.yaml +++ b/support/doc/api/openapi.yaml @@ -53,7 +53,7 @@ info: } ``` - We provide error `type` values for [a growing number of cases](https://github.com/Chocobozzz/PeerTube/blob/develop/shared/models/server/server-error-code.enum.ts), + We provide error `type` values for [a growing number of cases](https://github.com/Chocobozzz/PeerTube/blob/develop/packages/models/server/server-error-code.enum.ts), but it is still optional. Types are used to disambiguate errors that bear the same status code and are non-obvious: @@ -8752,7 +8752,7 @@ components: password: $ref: '#/components/schemas/password' UpdateMe: - # see shared/models/users/user-update-me.model.ts: + # see packages/models/users/user-update-me.model.ts: properties: password: $ref: '#/components/schemas/password' diff --git a/support/doc/development/lib.md b/support/doc/development/lib.md index 25fe3068e..1ea09f2bc 100644 --- a/support/doc/development/lib.md +++ b/support/doc/development/lib.md @@ -18,7 +18,7 @@ The complete types package is generated via: ``` npm run generate-types-package 4.x.x -cd packages/types/dist +cd packages/types-generator/dist npm publish --access=public ``` diff --git a/support/doc/development/localization.md b/support/doc/development/localization.md index a38ed6f55..4aca9b18b 100644 --- a/support/doc/development/localization.md +++ b/support/doc/development/localization.md @@ -26,7 +26,7 @@ Nothing to do here, Github will automatically send a webhook to Weblate that wil ## Support a new language - * Add it to [/shared/models/i18n/i18n.ts](/shared/models/i18n/i18n.ts) + * Add it to [/packages/models/i18n/i18n.ts](/packages/models/i18n/i18n.ts) * Add it to [/scripts/build/client.sh](/scripts/build/client.sh) * Add it to [/client/angular.json](/client/angular.json) * Add it to [/scripts/i18n/update.sh](/scripts/i18n/update.sh) diff --git a/support/doc/development/monitoring.md b/support/doc/development/monitoring.md index 93fd1403e..023be9e92 100644 --- a/support/doc/development/monitoring.md +++ b/support/doc/development/monitoring.md @@ -13,11 +13,11 @@ npm run build -- --analyze-bundle && npm run client-report To benchmark the REST API and save result in `benchmark.json`: ``` -node dist/scripts/benchmark.js -o benchmark.json +npm run benchmark-server -- -o benchmark.json ``` You can also grep on a specific test: ``` -node dist/scripts/benchmark.js --grep homepage +npm run benchmark-server -- --grep homepage ``` diff --git a/support/doc/development/server.md b/support/doc/development/server.md index 7a9fa571f..5c83af704 100644 --- a/support/doc/development/server.md +++ b/support/doc/development/server.md @@ -1,11 +1,11 @@ -# Server code + # Server code ## Database model typing Sequelize models contain optional fields corresponding to table joins. For example, `VideoModel` has a `VideoChannel?: VideoChannelModel` field. It can be filled if the SQL query joined with the `videoChannel` table or empty if not. It can be difficult in TypeScript to understand if a function argument expects associations to be filled or not. -To improve clarity and reduce bugs, PeerTube defines multiple versions of a database model depending on its associations in `server/types/models/`. +To improve clarity and reduce bugs, PeerTube defines multiple versions of a database model depending on its associations in `server/server/types/models/`. These models start with `M` and by default do not include any association. `MVideo` for example corresponds to `VideoModel` without any association, where `VideoChannel` attribute doesn't exist. On the other hand, `MVideoWithChannel` is a `MVideo` that has a `VideoChannel` field. This way, a function that accepts `video: MVideoWithChannel` argument expects a video with channel populated. Main PeerTube code should never use `...Model` (`VideoModel`) database type, but always `M...` instead (`MVideo`, `MVideoChannel` etc). ## Add a new feature walkthrough @@ -16,67 +16,67 @@ Some of these may be optional (for example your new endpoint may not need to sen * Configuration: - Add you new configuration key in `config/default.yaml` and `config/production.yaml` - If you configuration needs to be different in dev or tests environments, also update `config/dev.yaml` and `config/test.yaml` - - Load your configuration in `server/initializers/config.ts` - - Check new configuration keys are set in `server/initializers/checker-before-init.ts` - - You can also ensure configuration consistency in `server/initializers/checker-after-init.ts` + - Load your configuration in `server/server/initializers/config.ts` + - Check new configuration keys are set in `server/server/initializers/checker-before-init.ts` + - You can also ensure configuration consistency in `server/server/initializers/checker-after-init.ts` - If you want your configuration to be available in the client: - + Add your field in `shared/models/server/server-config.model.ts` - + Update `server/lib/server-config-manager.ts` to include your new configuration + + Add your field in `packages/models/server/server/server-config.model.ts` + + Update `server/server/lib/server-config-manager.ts` to include your new configuration - If you want your configuration to be updatable by the web admin in the client: - + Add your field in `shared/models/server/custom-config.model.ts` - + Add the configuration to the config object in the `server/controllers/api/config.ts` controller + + Add your field in `packages/models/server/server/custom-config.model.ts` + + Add the configuration to the config object in the `server/server/controllers/api/config.ts` controller * Controllers: - Create the controller file and fill it with your REST API routes - Import and use your controller in the parent controller * Middlewares: - - Create your validator middleware in `server/middlewares/validators` that will be used by your controllers - - Add your new middleware file `server/middlewares/validators/index.ts` so it's easier to import - - Create the entry in `server/types/express.d.ts` to attach the database model loaded by your middleware to the express response + - Create your validator middleware in `server/server/middlewares/validators` that will be used by your controllers + - Add your new middleware file `server/server/middlewares/validators/index.ts` so it's easier to import + - Create the entry in `server/server/types/express.d.ts` to attach the database model loaded by your middleware to the express response * Validators: - - Create your validators that will be used by your middlewares in `server/helpers/custom-validators` + - Create your validators that will be used by your middlewares in `server/server/helpers/custom-validators` * Typescript models: - - Create the API models (request parameters or response) in `shared/models` + - Create the API models (request parameters or response) in `packages/models` - Add your models in `index.ts` of current directory to facilitate the imports * Sequelize model (BDD): - If you need to create a new table: - + Create the Sequelize model in `server/models/`: + + Create the Sequelize model in `server/server/models/`: * Create the `@Column` * Add some indexes if you need * Create static methods to load a specific from the database `loadBy...` * Create static methods to load a list of models from the database `listBy...` * Create the instance method `toFormattedJSON` that creates the JSON to send to the REST API from the model - + Add your new Sequelize model to `server/initializers/database.ts` - + Create a new file in `server/types` to define multiple versions of your Sequelize model depending on database associations - + Add this new file to `server/types/*/index.ts` to facilitate the imports + + Add your new Sequelize model to `server/server/initializers/database.ts` + + Create a new file in `server/server/types` to define multiple versions of your Sequelize model depending on database associations + + Add this new file to `server/server/types/*/index.ts` to facilitate the imports + Create database migrations: - * Create the migration file in `server/initializers/migrations` using raw SQL (copy the same SQL query as at PeerTube startup) - * Update `LAST_MIGRATION_VERSION` in `server/initializers/constants.ts` + * Create the migration file in `server/server/initializers/migrations` using raw SQL (copy the same SQL query as at PeerTube startup) + * Update `LAST_MIGRATION_VERSION` in `server/server/initializers/constants.ts` - If updating database schema (adding/removing/renaming a column): - + Update the sequelize models in `server/models/` + + Update the sequelize models in `server/server/models/` + Add migrations: * Create the migration file in `initializers/migrations` using Sequelize Query Interface (`.addColumn`, `.dropTable`, `.changeColumn`) - * Update `LAST_MIGRATION_VERSION` in `server/initializers/constants.ts` + * Update `LAST_MIGRATION_VERSION` in `server/server/initializers/constants.ts` * Notifications: - - Create the new notification model in `shared/models/users/user-notification.model.ts` - - Create the notification logic in `server/lib/notifier/shared`: + - Create the new notification model in `packages/models/users/user-notification.model.ts` + - Create the notification logic in `server/server/lib/notifier/shared`: + Email subject has a common prefix (defined by the admin in PeerTube configuration) - - Add your notification to `server/lib/notifier/notifier.ts` - - Create the email template in `server/lib/emails`: + - Add your notification to `server/server/lib/notifier/notifier.ts` + - Create the email template in `server/server/lib/emails`: + A text version is automatically generated from the HTML + The template usually extends `../common/grettings` that already says "Hi" and "Cheers". You just have to write the title and the content blocks that will be inserted in the appropriate places in the HTML template - If you need to associate a new table with `userNotification`: + Associate the new table in `UserNotificationModel` (don't forget the index) - + Add the object property in the API model definition (`shared/models/users/user-notification.model.ts`) + + Add the object property in the API model definition (`packages/models/users/user-notification.model.ts`) + Add the object in `UserNotificationModel.toFormattedJSON` + Handle this new notification type in client (`UserNotificationsComponent`) + Handle the new object property in client model (`UserNotification`) * Tests: - - Create your command class in `shared/server-commands/` that will wrap HTTP requests to your new endpoint + - Create your command class in `packages/server-commands/` that will wrap HTTP requests to your new endpoint - Add your command file in `index.ts` of current directory - - Instantiate your command class in `shared/server-commands/server/server.ts` - - Create your test file in `server/tests/api/check-params` to test middleware validators/authentification/user rights (offensive tests) - - Add it to `server/tests/api/check-params/index.ts` - - Create your test file in `server/tests/api` to test your new endpoints + - Instantiate your command class in `packages/server-commands/server/server/server.ts` + - Create your test file in `server/server/tests/api/check-params` to test middleware validators/authentification/user rights (offensive tests) + - Add it to `server/server/tests/api/check-params/index.ts` + - Create your test file in `server/server/tests/api` to test your new endpoints - Add it to `index.ts` of current directory - - Add your notification test in `server/tests/api/notifications` + - Add your notification test in `server/server/tests/api/notifications` * Update REST API documentation in `support/doc/api/openapi.yaml` diff --git a/support/doc/development/tests.md b/support/doc/development/tests.md index 1c2589c8a..2e4c6ff6a 100644 --- a/support/doc/development/tests.md +++ b/support/doc/development/tests.md @@ -8,7 +8,7 @@ Prepare PostgreSQL user so PeerTube can delete/create the test databases: sudo -u postgres createuser you_username --createdb --superuser ``` -Prepare databases: +Prepare the databases: ```bash npm run clean:server:test @@ -45,22 +45,19 @@ sudo apt-get install parallel libimage-exiftool-perl ### Test -To run all test suites: +To run all test suites (can be long!): ```bash npm run test # See scripts/test.sh to run a particular suite ``` -Most of tests can be run using: +To run a specific test: ```bash -TS_NODE_TRANSPILE_ONLY=true npm run mocha -- --timeout 30000 --exit -r ts-node/register -r tsconfig-paths/register --bail server/tests/api/videos/video-transcoder.ts -``` +npm run mocha -- --exit --bail packages/tests/src/your-test.ts -`server/tests/api/activitypub` tests will need different options: - -``` -TS_NODE_FILES=true mocha -- --timeout 30000 --exit -r ts-node/register -r tsconfig-paths/register --bail server/tests/api/activitypub/security.ts +# For example +npm run mocha -- --exit --bail packages/tests/src/api/videos/single-server.ts ``` ### Configuration diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.md index ff08ce8c4..07f484934 100644 --- a/support/doc/plugins/guide.md +++ b/support/doc/plugins/guide.md @@ -387,7 +387,7 @@ function register (...) { displayName: 'User display name', // Custom admin flags (bypass video auto moderation etc.) - // https://github.com/Chocobozzz/PeerTube/blob/develop/shared/models/users/user-flag.model.ts + // https://github.com/Chocobozzz/PeerTube/blob/develop/packages/models/users/user-flag.model.ts // PeerTube >= 5.1 adminFlags: 0, // Quota in bytes @@ -977,7 +977,7 @@ npm install --save-dev @peertube/peertube-types This package exposes *server* definition files by default: ```ts -import { RegisterServerOptions } from '@peertube/peertube-types' +import { RegisterServerOptions } from '@peertube/peertube-types.js' export async function register ({ registerHook }: RegisterServerOptions) { registerHook({ @@ -989,8 +989,8 @@ export async function register ({ registerHook }: RegisterServerOptions) { But it also exposes client types and various models used in __PeerTube__: ```ts -import { Video } from '@peertube/peertube-types'; -import { RegisterClientOptions } from '@peertube/peertube-types/client'; +import { Video } from '@peertube/peertube-types.js'; +import { RegisterClientOptions } from '@peertube/peertube-types/client.js'; function register({ registerHook, peertubeHelpers }: RegisterClientOptions) { registerHook({ @@ -1032,7 +1032,7 @@ If you want to translate strings of your plugin (like labels of your registered } ``` -The key should be one of the locales defined in [i18n.ts](https://github.com/Chocobozzz/PeerTube/blob/develop/shared/models/i18n/i18n.ts). +The key should be one of the locales defined in [i18n.ts](https://github.com/Chocobozzz/PeerTube/blob/develop/packages/models/i18n/i18n.ts). Translation files are just objects, with the english sentence as the key and the translation as the value. `fr.json` could contain for example: @@ -1070,40 +1070,25 @@ You built files are in the `dist/` directory. Check `package.json` to correctly ### Test your plugin/theme -PeerTube dev server (ran with `npm run dev` on `localhost:3000`) can't inject plugin CSS. -It's the reason why we don't use the dev mode but build PeerTube instead. +You need to have a running PeerTube instance with an administrator account. +If you're using dev server on your local computer, test your plugin on `localhost:9000` using `npm run dev` because plugin CSS is not injected in Angular webserver (`localhost:3000`). -You'll need to have a local PeerTube instance: - * Follow the [dev prerequisites](https://github.com/Chocobozzz/PeerTube/blob/develop/.github/CONTRIBUTING.md#prerequisites) - (to clone the repository, install dependencies and prepare the database) - * Build PeerTube: +Install PeerTube CLI (can be installed on another computer/server than the PeerTube instance): -```sh -npm run build +```bash +npm install -g @peertube/peertube-cli ``` - * Build the CLI: +Register the PeerTube instance via the CLI: ```sh -npm run setup:cli +peertube-cli auth add -u 'https://peertube.example.com' -U 'root' --password 'test' ``` - * Run PeerTube (you can access to your instance on `localhost:9000`): +Then, you can install your local plugin/theme by running: ```sh -NODE_ENV=dev npm start -``` - - * Register the instance via the CLI: - -```sh -node ./dist/server/tools/peertube.js auth add -u 'http://localhost:9000' -U 'root' --password 'test' -``` - -Then, you can install or reinstall your local plugin/theme by running: - -```sh -node ./dist/server/tools/peertube.js plugins install --path /your/absolute/plugin-or-theme/path +peertube-cli plugins install --path /your/absolute/plugin-or-theme/path ``` ### Publish diff --git a/support/doc/tools.md b/support/doc/tools.md index 2b3ebf159..40d9ec66a 100644 --- a/support/doc/tools.md +++ b/support/doc/tools.md @@ -4,59 +4,48 @@ ## Remote PeerTube CLI -You need at least 512MB RAM to run the script. -Scripts can be launched directly from a PeerTube server, or from a separate server, even a desktop PC. -You need to follow all the following steps even if you are on a PeerTube server (including cloning the git repository in a different directory than your production installation because the scripts utilize non-production dependencies). - -### Dependencies - -Install the [PeerTube dependencies](/support/doc/dependencies.md) except PostgreSQL and Redis. +`peertube-cli` is a tool that communicates with a PeerTube instance using its [REST API](https://docs.joinpeertube.org/api-rest-reference.html). +It can be launched from a remote server/computer to easily upload videos, manage plugins, redundancies etc. ### Installation -Clone the PeerTube repo to get the latest version (even if you are on your PeerTube server): +Ensure you have `node` installed on your system: ```bash -git clone https://github.com/Chocobozzz/PeerTube.git -CLONE="$(pwd)/PeerTube" -cd ${CLONE} +node --version # Should be >= 16.x ``` -Install dependencies and build CLI tools: +Then install the CLI: ```bash -NOCLIENT=1 yarn install --pure-lockfile -npm run setup:cli +sudo npm install -g @peertube/peertube-cli ``` ### CLI wrapper -The wrapper provides a convenient interface to the following scripts. -You can access it as `peertube` via an alias in your `.bashrc` like `alias peertube="cd /your/peertube/directory/ && node ./dist/server/tools/peertube.js"` (you have to keep the `cd` command): +The wrapper provides a convenient interface to the following sub-commands. ``` - Usage: peertube [command] [options] +Usage: peertube-cli [command] [options] - Options: +Options: + -v, --version output the version number + -h, --help display help for command - -v, --version output the version number - -h, --help output usage information - - Commands: - - auth [action] register your accounts on remote instances to use them with other commands - upload|up upload a video - import-videos|import import a video from a streaming platform - plugins|p [action] manage instance plugins - redundancy|r [action] manage video redundancies - help [cmd] display help for [cmd] +Commands: + auth Register your accounts on remote instances to use them with other commands + upload|up [options] Upload a video on a PeerTube instance + redundancy|r Manage instance redundancies + plugins|p Manage instance plugins/themes + get-access-token|token [options] Get a peertube access token + help [command] display help for command ``` The wrapper can keep track of instances you have an account on. We limit to one account per instance for now. ```bash -peertube auth add -u 'PEERTUBE_URL' -U 'PEERTUBE_USER' --password 'PEERTUBE_PASSWORD' -peertube auth list +peertube-cli auth add -u 'PEERTUBE_URL' -U 'PEERTUBE_USER' --password 'PEERTUBE_PASSWORD' +peertube-cli auth list ┌──────────────────────────────┬──────────────────────────────┐ │ instance │ login │ ├──────────────────────────────┼──────────────────────────────┤ @@ -64,331 +53,80 @@ peertube auth list └──────────────────────────────┴──────────────────────────────┘ ``` -You can now use that account to upload videos without feeding the same parameters again. +You can now use that account to execute sub-commands without feeding the `--url`, `--username` and `--password` parameters: ```bash -peertube up +peertube-cli upload +peertube-cli plugins list +... ``` -To list, install, uninstall dynamically plugins/themes of an instance: +#### peertube-cli upload -```bash -peertube plugins list -peertube plugins install --path /local/plugin/path -peertube plugins install --npm-name peertube-plugin-myplugin -peertube plugins uninstall --npm-name peertube-plugin-myplugin -``` - -#### peertube-import-videos.js - -You can use this script to import videos from all [supported sites of youtube-dl](https://rg3.github.io/youtube-dl/supportedsites.html) into PeerTube. -Be sure you own the videos or have the author's authorization to do so. - -```sh -node dist/server/tools/peertube-import-videos.js \ - -u 'PEERTUBE_URL' \ - -U 'PEERTUBE_USER' \ - --password 'PEERTUBE_PASSWORD' \ - --target-url 'TARGET_URL' -``` - -* `PEERTUBE_URL` : the full URL of your PeerTube server where you want to import, eg: https://peertube.cpy.re -* `PEERTUBE_USER` : your PeerTube account where videos will be uploaded -* `PEERTUBE_PASSWORD` : password of your PeerTube account (if `--password PEERTUBE_PASSWORD` is omitted, you will be prompted for it) -* `TARGET_URL` : the target url you want to import. Examples: - * YouTube: - * Channel: https://www.youtube.com/channel/ChannelId - * User https://www.youtube.com/c/UserName or https://www.youtube.com/user/UserName - * Video https://www.youtube.com/watch?v=blabla - * Vimeo: https://vimeo.com/xxxxxx - * Dailymotion: https://www.dailymotion.com/xxxxx - -The script will get all public videos from Youtube, download them and upload to PeerTube. -Already downloaded videos will not be uploaded twice, so you can run and re-run the script in case of crash, disconnection... - -Videos will be publicly available after transcoding (you can see them before that in your account on the web interface). - -**NB**: If you want to synchronize a Youtube channel to your PeerTube instance (ensure you have the agreement from the author), -you can add a [crontab rule](https://help.ubuntu.com/community/CronHowto) (or an equivalent of your OS) and insert -these rules (ensure to customize them to your needs): - -``` -# Update youtube-dl every day at midnight -0 0 * * * /usr/bin/npm rebuild youtube-dl --prefix /PATH/TO/PEERTUBE/ - -# Synchronize the YT channel every sunday at 22:00 all the videos published since last monday included -0 22 * * 0 /usr/bin/node /PATH/TO/PEERTUBE/dist/server/tools/peertube-import-videos.js -u '__PEERTUBE_URL__' -U '__USER__' --password '__PASSWORD__' --target-url 'https://www.youtube.com/channel/___CHANNEL__' --since $(date --date="-6 days" +\%Y-\%m-\%d) -``` - -Also you may want to subscribe to the PeerTube channel in order to manually check the synchronization is successful. - -#### peertube-upload.js - -You can use this script to import videos directly from the CLI. +You can use this script to upload videos directly from the CLI. Videos will be publicly available after transcoding (you can see them before that in your account on the web interface). ```bash cd ${CLONE} -node dist/server/tools/peertube-upload.js --help +peertube-cli upload --help ``` -#### peertube-plugins.js +#### peertube-cli plugins Install/update/uninstall or list local or NPM PeerTube plugins: ```bash cd ${CLONE} -node dist/server/tools/peertube-plugins.js --help -node dist/server/tools/peertube-plugins.js list --help -node dist/server/tools/peertube-plugins.js install --help -node dist/server/tools/peertube-plugins.js update --help -node dist/server/tools/peertube-plugins.js uninstall --help +peertube-cli plugins --help +peertube-cli plugins list --help +peertube-cli plugins install --help +peertube-cli plugins update --help +peertube-cli plugins uninstall --help -node dist/server/tools/peertube-plugins.js install --path /my/plugin/path -node dist/server/tools/peertube-plugins.js install --npm-name peertube-theme-example +peertube-cli plugins install --path /my/plugin/path +peertube-cli plugins install --npm-name peertube-theme-example ``` -#### peertube-redundancy.js +#### peertube-cli redundancy Manage (list/add/remove) video redundancies: To list your videos that are duplicated by remote instances: ```bash -node dist/server/tools/peertube.js redundancy list-remote-redundancies +peertube-cli redundancy list-remote-redundancies ``` To list remote videos that your instance duplicated: ```bash -node dist/server/tools/peertube.js redundancy list-my-redundancies +peertube-cli redundancy list-my-redundancies ``` To duplicate a specific video in your redundancy system: ```bash -node dist/server/tools/peertube.js redundancy add --video 823 +peertube-cli redundancy add --video 823 ``` To remove a video redundancy: ```bash -node dist/server/tools/peertube.js redundancy remove --video 823 +peertube-cli redundancy remove --video 823 ``` -## Server tools - -These scripts should be run on the server, in `peertube-latest` directory. - -### parse-log - -To parse PeerTube last log file: - -```bash -# Basic installation -cd /var/www/peertube/peertube-latest -sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run parse-log -- --level info - -# Docker installation -cd /var/www/peertube-docker -docker-compose exec -u peertube peertube npm run parse-log -- --level info -``` - -`--level` is optional and could be `info`/`warn`/`error` - -You can also remove SQL or HTTP logs using `--not-tags` (PeerTube >= 3.2): - -```bash -# Basic installation -cd /var/www/peertube/peertube-latest -sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run parse-log -- --level debug --not-tags http sql - -# Docker installation -cd /var/www/peertube-docker -docker-compose exec -u peertube peertube npm run parse-log -- --level debug --not-tags http sql -``` - -### regenerate-thumbnails.js - -**PeerTube >= 3.2** - -Regenerating local video thumbnails could be useful because new PeerTube releases may increase thumbnail sizes: - -```bash -# Basic installation -cd /var/www/peertube/peertube-latest -sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run regenerate-thumbnails - -# Docker installation -cd /var/www/peertube-docker -docker-compose exec -u peertube peertube npm run regenerate-thumbnails -``` - -### create-import-video-file-job.js - -You can use this script to import a video file to replace an already uploaded file or to add a new web compatible resolution to a video. PeerTube needs to be running. -You can then create a transcoding job using the web interface if you need to optimize your file or create an HLS version of it. - -```bash -# Basic installation -cd /var/www/peertube/peertube-latest -sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-import-video-file-job -- -v [videoUUID] -i [videoFile] - -# Docker installation -cd /var/www/peertube-docker -docker-compose exec -u peertube peertube npm run create-import-video-file-job -- -v [videoUUID] -i [videoFile] -``` - -### create-move-video-storage-job.js - -**PeerTube >= 4.0** - -Use this script to move all video files or a specific video file to object storage. - -```bash -# Basic installation -cd /var/www/peertube/peertube-latest -sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-move-video-storage-job -- --to-object-storage -v [videoUUID] - -# Docker installation -cd /var/www/peertube-docker -docker-compose exec -u peertube peertube npm run create-move-video-storage-job -- --to-object-storage -v [videoUUID] -``` - -The script can also move all video files that are not already in object storage: - -```bash -# Basic installation -cd /var/www/peertube/peertube-latest -sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-move-video-storage-job -- --to-object-storage --all-videos - -# Docker installation -cd /var/www/peertube-docker -docker-compose exec -u peertube peertube npm run create-move-video-storage-job -- --to-object-storage --all-videos -``` - - - -### prune-storage.js - -Some transcoded videos or shutdown at a bad time can leave some unused files on your storage. -Stop PeerTube and delete these files (a confirmation will be demanded first): - -```bash -cd /var/www/peertube/peertube-latest -sudo systemctl stop peertube && sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run prune-storage -``` - - -### update-host.js - -**Changing the hostname is unsupported and may be a risky operation, especially if you have already federated.** -If you started PeerTube with a domain, and then changed it you will have -invalid torrent files and invalid URLs in your database. To fix this, you have -to run the command below (keep in mind your follower instances will NOT update their URLs). - -```bash -# Basic installation -cd /var/www/peertube/peertube-latest -sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run update-host - -# Docker installation -cd /var/www/peertube-docker -docker-compose exec -u peertube peertube npm run update-host -``` - -### reset-password.js - -To reset a user password from CLI, run: - -```bash -# Basic installation -cd /var/www/peertube/peertube-latest -sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run reset-password -- -u target_username - -# Docker installation -cd /var/www/peertube-docker -docker-compose exec -u peertube peertube npm run reset-password -- -u target_username -``` - - -### plugin install/uninstall - -The difference with `peertube plugins` CLI is that these scripts can be used even if PeerTube is not running. -If PeerTube is running, you need to restart it for the changes to take effect (whereas with `peertube plugins` CLI, plugins/themes are dynamically loaded on the server). - -To install/update a plugin or a theme from the disk: - -```bash -cd /var/www/peertube/peertube-latest -sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run plugin:install -- --plugin-path /local/plugin/path - -# Docker installation -cd /var/www/peertube-docker -docker-compose exec -u peertube peertube npm run plugin:install -- --plugin-path /local/plugin/path -``` - -From NPM: - -```bash -cd /var/www/peertube/peertube-latest -sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run plugin:install -- --npm-name peertube-plugin-myplugin - -# Docker installation -cd /var/www/peertube-docker -docker-compose exec -u peertube peertube npm run plugin:install -- --npm-name peertube-plugin-myplugin -``` - -To uninstall a plugin or a theme: - -```bash -cd /var/www/peertube/peertube-latest -sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run plugin:uninstall -- --npm-name peertube-plugin-myplugin - -# Docker installation -cd /var/www/peertube-docker -docker-compose exec -u peertube peertube npm run plugin:uninstall -- --npm-name peertube-plugin-myplugin -``` ## PeerTube runner PeerTube >= 5.2 supports VOD or Live transcoding by a remote PeerTube runner. - ### Installation -Ensure you have `ffmpeg` and `ffprobe` installed on your system: +Ensure you have `node`, `ffmpeg` and `ffprobe` installed on your system: ```bash +node --version # Should be >= 16.x ffprobe -version # Should be >= 4.3 ffmpeg -version # Should be >= 4.3 ``` @@ -444,3 +182,201 @@ peertube-runner unregister --url http://peertube.example.com --runner-name my-ru ```bash peertube-runner list-registered ``` + +## Server tools + +Server tools are scripts that interect directly with the code of your PeerTube instance. +They must be run on the server, in `peertube-latest` directory. + +### Parse logs + +To parse PeerTube last log file: + +```bash +# Basic installation +cd /var/www/peertube/peertube-latest +sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run parse-log -- --level info + +# Docker installation +cd /var/www/peertube-docker +docker-compose exec -u peertube peertube npm run parse-log -- --level info +``` + +`--level` is optional and could be `info`/`warn`/`error` + +You can also remove SQL or HTTP logs using `--not-tags` (PeerTube >= 3.2): + +```bash +# Basic installation +cd /var/www/peertube/peertube-latest +sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run parse-log -- --level debug --not-tags http sql + +# Docker installation +cd /var/www/peertube-docker +docker-compose exec -u peertube peertube npm run parse-log -- --level debug --not-tags http sql +``` + +### Regenerate video thumbnails + +Regenerating local video thumbnails could be useful because new PeerTube releases may increase thumbnail sizes: + +```bash +# Basic installation +cd /var/www/peertube/peertube-latest +sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run regenerate-thumbnails + +# Docker installation +cd /var/www/peertube-docker +docker-compose exec -u peertube peertube npm run regenerate-thumbnails +``` + +### Add or replace specific video file + +You can use this script to import a video file to replace an already uploaded file or to add a new web compatible resolution to a video. PeerTube needs to be running. +You can then create a transcoding job using the web interface if you need to optimize your file or create an HLS version of it. + +```bash +# Basic installation +cd /var/www/peertube/peertube-latest +sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-import-video-file-job -- -v [videoUUID] -i [videoFile] + +# Docker installation +cd /var/www/peertube-docker +docker-compose exec -u peertube peertube npm run create-import-video-file-job -- -v [videoUUID] -i [videoFile] +``` + +### Move video files to object storage + +Use this script to move all video files or a specific video file to object storage. + +```bash +# Basic installation +cd /var/www/peertube/peertube-latest +sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-move-video-storage-job -- --to-object-storage -v [videoUUID] + +# Docker installation +cd /var/www/peertube-docker +docker-compose exec -u peertube peertube npm run create-move-video-storage-job -- --to-object-storage -v [videoUUID] +``` + +The script can also move all video files that are not already in object storage: + +```bash +# Basic installation +cd /var/www/peertube/peertube-latest +sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-move-video-storage-job -- --to-object-storage --all-videos + +# Docker installation +cd /var/www/peertube-docker +docker-compose exec -u peertube peertube npm run create-move-video-storage-job -- --to-object-storage --all-videos +``` + + + +### Prune filesystem storage + +Some transcoded videos or shutdown at a bad time can leave some unused files on your storage. +Stop PeerTube and delete these files (a confirmation will be demanded first): + +```bash +cd /var/www/peertube/peertube-latest +sudo systemctl stop peertube && sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run prune-storage +``` + +### Update PeerTube instance domain name + +**Changing the hostname is unsupported and may be a risky operation, especially if you have already federated.** +If you started PeerTube with a domain, and then changed it you will have +invalid torrent files and invalid URLs in your database. To fix this, you have +to run the command below (keep in mind your follower instances will NOT update their URLs). + +```bash +# Basic installation +cd /var/www/peertube/peertube-latest +sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run update-host + +# Docker installation +cd /var/www/peertube-docker +docker-compose exec -u peertube peertube npm run update-host +``` + +### Reset user password + +To reset a user password from CLI, run: + +```bash +# Basic installation +cd /var/www/peertube/peertube-latest +sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run reset-password -- -u target_username + +# Docker installation +cd /var/www/peertube-docker +docker-compose exec -u peertube peertube npm run reset-password -- -u target_username +``` + + +### Install or uninstall plugins + +The difference with `peertube plugins` CLI is that these scripts can be used even if PeerTube is not running. +If PeerTube is running, you need to restart it for the changes to take effect (whereas with `peertube plugins` CLI, plugins/themes are dynamically loaded on the server). + +To install/update a plugin or a theme from the disk: + +```bash +cd /var/www/peertube/peertube-latest +sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run plugin:install -- --plugin-path /local/plugin/path + +# Docker installation +cd /var/www/peertube-docker +docker-compose exec -u peertube peertube npm run plugin:install -- --plugin-path /local/plugin/path +``` + +From NPM: + +```bash +cd /var/www/peertube/peertube-latest +sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run plugin:install -- --npm-name peertube-plugin-myplugin + +# Docker installation +cd /var/www/peertube-docker +docker-compose exec -u peertube peertube npm run plugin:install -- --npm-name peertube-plugin-myplugin +``` + +To uninstall a plugin or a theme: + +```bash +cd /var/www/peertube/peertube-latest +sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run plugin:uninstall -- --npm-name peertube-plugin-myplugin + +# Docker installation +cd /var/www/peertube-docker +docker-compose exec -u peertube peertube npm run plugin:uninstall -- --npm-name peertube-plugin-myplugin +``` diff --git a/support/nginx/peertube b/support/nginx/peertube index 5ce59a112..7028566c7 100644 --- a/support/nginx/peertube +++ b/support/nginx/peertube @@ -183,7 +183,7 @@ server { #client_body_temp_path /var/www/peertube/storage/nginx/; # Bypass PeerTube for performance reasons. Optional. - # Should be consistent with client-overrides assets list in /server/controllers/client.ts + # Should be consistent with client-overrides assets list in client.ts server controller location ~ ^/client/(assets/images/(icons/icon-36x36\.png|icons/icon-48x48\.png|icons/icon-72x72\.png|icons/icon-96x96\.png|icons/icon-144x144\.png|icons/icon-192x192\.png|icons/icon-512x512\.png|logo\.svg|favicon\.png|default-playlist\.jpg|default-avatar-account\.png|default-avatar-account-48x48\.png|default-avatar-video-channel\.png|default-avatar-video-channel-48x48\.png))$ { add_header Cache-Control "public, max-age=31536000, immutable"; # Cache 1 year diff --git a/tsconfig.base.json b/tsconfig.base.json index 18ba8f06c..cce74235b 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1,11 +1,12 @@ { "compilerOptions": { - "module": "commonjs", - "target": "es2015", + "module": "NodeNext", + "target": "ES2017", "noImplicitAny": false, "sourceMap": true, "experimentalDecorators": true, "emitDecoratorMetadata": true, + "isolatedModules": true, "importHelpers": true, "removeComments": true, "esModuleInterop": true, @@ -19,11 +20,6 @@ "es2019" ], "baseUrl": "./", - "paths": { - "@server/*": [ "server/*" ], - "@shared/*": [ "shared/*" ], - "@client/*": [ "client/src/*" ] - }, "resolveJsonModule": true, "strict": false, "strictBindCallApply": true, diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json new file mode 100644 index 000000000..c2e868173 --- /dev/null +++ b/tsconfig.eslint.json @@ -0,0 +1,32 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "outDir": "./dist/", + "baseUrl": "./", + "paths": { + "@server/*": [ "server/*" ] + }, + "typeRoots": [ + "node_modules/@types" + ] + }, + "include": [ + "./server.ts", + "server/**/*.ts", + "packages/**/*.ts", + "apps/**/*.ts", + "scripts/**/*.ts" + ], + "references": [ + { "path": "./server" }, + { "path": "./scripts" }, + { "path": "./apps/peertube-runner" }, + { "path": "./apps/peertube-cli" }, + { "path": "./packages/core-utils" }, + { "path": "./packages/ffmpeg" }, + { "path": "./packages/models" }, + { "path": "./packages/node-utils" }, + { "path": "./packages/server-commands" }, + { "path": "./packages/typescript-utils" } + ] +} diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index 8bcd944e3..000000000 --- a/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/", - "baseUrl": "./", - "paths": { - "@server/*": [ "server/*" ], - "@shared/*": [ "shared/*" ] - }, - "typeRoots": [ - "node_modules/@types" - ] - }, - "references": [ - { "path": "./shared" }, - { "path": "./server" }, - { "path": "./scripts" } - ], - "files": [ "server.ts", "server/types/express.d.ts", "server/types/lib.d.ts" ] -} diff --git a/yarn.lock b/yarn.lock index 2686c4d4a..e9c5c22d1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1269,12 +1269,10 @@ resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9" integrity sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ== -"@cspotcode/source-map-support@^0.8.0": - version "0.8.1" - resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" - integrity sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw== - dependencies: - "@jridgewell/trace-mapping" "0.3.9" +"@commander-js/extra-typings@^11.0.0": + version "11.0.0" + resolved "https://registry.yarnpkg.com/@commander-js/extra-typings/-/extra-typings-11.0.0.tgz#eb922a59550454cad1f319d3d33e675e12e92fa0" + integrity sha512-06ol6Kn5gPjFY6v0vWOZ84nQwyqhZdaeZCHYH3vhwewjpOEjniF1KHZxh18887G3poWiJ8qyq5pb6ANuiddfPQ== "@dabh/diagnostics@^2.0.2": version "2.0.3" @@ -1294,6 +1292,250 @@ ky-universal "^0.11.0" undici "^5.21.2" +"@esbuild-kit/cjs-loader@^2.4.2": + version "2.4.2" + resolved "https://registry.yarnpkg.com/@esbuild-kit/cjs-loader/-/cjs-loader-2.4.2.tgz#cb4dde00fbf744a68c4f20162ea15a8242d0fa54" + integrity sha512-BDXFbYOJzT/NBEtp71cvsrGPwGAMGRB/349rwKuoxNSiKjPraNNnlK6MIIabViCjqZugu6j+xeMDlEkWdHHJSg== + dependencies: + "@esbuild-kit/core-utils" "^3.0.0" + get-tsconfig "^4.4.0" + +"@esbuild-kit/core-utils@^3.0.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@esbuild-kit/core-utils/-/core-utils-3.1.0.tgz#49945d533dbd5e1b7620aa0fc522c15e6ec089c5" + integrity sha512-Uuk8RpCg/7fdHSceR1M6XbSZFSuMrxcePFuGgyvsBn+u339dk5OeL4jv2EojwTN2st/unJGsVm4qHWjWNmJ/tw== + dependencies: + esbuild "~0.17.6" + source-map-support "^0.5.21" + +"@esbuild-kit/esm-loader@^2.5.5": + version "2.5.5" + resolved "https://registry.yarnpkg.com/@esbuild-kit/esm-loader/-/esm-loader-2.5.5.tgz#b82da14fcee3fc1d219869756c06f43f67d1ca71" + integrity sha512-Qwfvj/qoPbClxCRNuac1Du01r9gvNOT+pMYtJDapfB1eoGN1YlJ1BixLyL9WVENRx5RXgNLdfYdx/CuswlGhMw== + dependencies: + "@esbuild-kit/core-utils" "^3.0.0" + get-tsconfig "^4.4.0" + +"@esbuild/android-arm64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.17.19.tgz#bafb75234a5d3d1b690e7c2956a599345e84a2fd" + integrity sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA== + +"@esbuild/android-arm64@0.19.0": + version "0.19.0" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.19.0.tgz#c5ea635bdbe9b83d1f78a711120814e716439029" + integrity sha512-AzsozJnB+RNaDncBCs3Ys5g3kqhPFUueItfEaCpp89JH2naFNX2mYDIvUgPYMqqjm8hiFoo+jklb3QHZyR3ubw== + +"@esbuild/android-arm@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.17.19.tgz#5898f7832c2298bc7d0ab53701c57beb74d78b4d" + integrity sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A== + +"@esbuild/android-arm@0.19.0": + version "0.19.0" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.19.0.tgz#6eb6e1fbc0dbfafa035aaef8b5ecde25b539fcf9" + integrity sha512-GAkjUyHgWTYuex3evPd5V7uV/XS4LMKr1PWHRPW1xNyy/Jx08x3uTrDFRefBYLKT/KpaWM8/YMQcwbp5a3yIDA== + +"@esbuild/android-x64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.17.19.tgz#658368ef92067866d95fb268719f98f363d13ae1" + integrity sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww== + +"@esbuild/android-x64@0.19.0": + version "0.19.0" + resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.19.0.tgz#99f154f71f5b92e778468bcf0f425d166c17bf20" + integrity sha512-SUG8/qiVhljBDpdkHQ9DvOWbp7hFFIP0OzxOTptbmVsgBgzY6JWowmMd6yJuOhapfxmj/DrvwKmjRLvVSIAKZg== + +"@esbuild/darwin-arm64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz#584c34c5991b95d4d48d333300b1a4e2ff7be276" + integrity sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg== + +"@esbuild/darwin-arm64@0.19.0": + version "0.19.0" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.19.0.tgz#2fcc11abf95fbabbf9167db6a11d899385bd777b" + integrity sha512-HkxZ8k3Jvcw0FORPNTavA8BMgQjLOB6AajT+iXmil7BwY3gU1hWvJJAyWyEogCmA4LdbGvKF8vEykdmJ4xNJJQ== + +"@esbuild/darwin-x64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.17.19.tgz#7751d236dfe6ce136cce343dce69f52d76b7f6cb" + integrity sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw== + +"@esbuild/darwin-x64@0.19.0": + version "0.19.0" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.19.0.tgz#b5bbde35468db093fdf994880b0eb4b62613b67c" + integrity sha512-9IRWJjqpWFHM9a5Qs3r3bK834NCFuDY5ZaLrmTjqE+10B6w65UMQzeZjh794JcxpHolsAHqwsN/33crUXNCM2Q== + +"@esbuild/freebsd-arm64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.19.tgz#cacd171665dd1d500f45c167d50c6b7e539d5fd2" + integrity sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ== + +"@esbuild/freebsd-arm64@0.19.0": + version "0.19.0" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.0.tgz#3f64c76dc590f79cc40acef6b22dd5eb89fc2125" + integrity sha512-s7i2WcXcK0V1PJHVBe7NsGddsL62a9Vhpz2U7zapPrwKoFuxPP9jybwX8SXnropR/AOj3ppt2ern4ItblU6UQQ== + +"@esbuild/freebsd-x64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.17.19.tgz#0769456eee2a08b8d925d7c00b79e861cb3162e4" + integrity sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ== + +"@esbuild/freebsd-x64@0.19.0": + version "0.19.0" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.19.0.tgz#14d497e9e858fba2bb9b16130602b7f5944bc09c" + integrity sha512-NMdBSSdgwHCqCsucU5k1xflIIRU0qi1QZnM6+vdGy5fvxm1c8rKh50VzsWsIVTFUG3l91AtRxVwoz3Lcvy3I5w== + +"@esbuild/linux-arm64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.17.19.tgz#38e162ecb723862c6be1c27d6389f48960b68edb" + integrity sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg== + +"@esbuild/linux-arm64@0.19.0": + version "0.19.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.19.0.tgz#0f2f4d8889f7dc89681c306d7312aa76445a5f65" + integrity sha512-I4zvE2srSZxRPapFnNqj+NL3sDJ1wkvEZqt903OZUlBBgigrQMvzUowvP/TTTu2OGYe1oweg5MFilfyrElIFag== + +"@esbuild/linux-arm@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.17.19.tgz#1a2cd399c50040184a805174a6d89097d9d1559a" + integrity sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA== + +"@esbuild/linux-arm@0.19.0": + version "0.19.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.19.0.tgz#0b0f79dc72884f0ad02c0aabfc969a0bee7f6775" + integrity sha512-2F1+lH7ZBcCcgxiSs8EXQV0PPJJdTNiNcXxDb61vzxTRJJkXX1I/ye9mAhfHyScXzHaEibEXg1Jq9SW586zz7w== + +"@esbuild/linux-ia32@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.17.19.tgz#e28c25266b036ce1cabca3c30155222841dc035a" + integrity sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ== + +"@esbuild/linux-ia32@0.19.0": + version "0.19.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.19.0.tgz#dfcece1f5e74d0e7db090475e48b28d9aa270687" + integrity sha512-dz2Q7+P92r1Evc8kEN+cQnB3qqPjmCrOZ+EdBTn8lEc1yN8WDgaDORQQiX+mxaijbH8npXBT9GxUqE52Gt6Y+g== + +"@esbuild/linux-loong64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.17.19.tgz#0f887b8bb3f90658d1a0117283e55dbd4c9dcf72" + integrity sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ== + +"@esbuild/linux-loong64@0.19.0": + version "0.19.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.19.0.tgz#710f5bd55db3f5d9ebac8773ea49795261a35ca7" + integrity sha512-IcVJovJVflih4oFahhUw+N7YgNbuMSVFNr38awb0LNzfaiIfdqIh518nOfYaNQU3aVfiJnOIRVJDSAP4k35WxA== + +"@esbuild/linux-mips64el@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.17.19.tgz#f5d2a0b8047ea9a5d9f592a178ea054053a70289" + integrity sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A== + +"@esbuild/linux-mips64el@0.19.0": + version "0.19.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.19.0.tgz#a918b310f9bf31fced3853ca52fee6e7acc09824" + integrity sha512-bZGRAGySMquWsKw0gIdsClwfvgbsSq/7oq5KVu1H1r9Il+WzOcfkV1hguntIuBjRVL8agI95i4AukjdAV2YpUw== + +"@esbuild/linux-ppc64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.17.19.tgz#876590e3acbd9fa7f57a2c7d86f83717dbbac8c7" + integrity sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg== + +"@esbuild/linux-ppc64@0.19.0": + version "0.19.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.19.0.tgz#104771ef6ce2719ac17031f6b9ed8aa98f8e5faf" + integrity sha512-3LC6H5/gCDorxoRBUdpLV/m7UthYSdar0XcCu+ypycQxMS08MabZ06y1D1yZlDzL/BvOYliRNRWVG/YJJvQdbg== + +"@esbuild/linux-riscv64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.17.19.tgz#7f49373df463cd9f41dc34f9b2262d771688bf09" + integrity sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA== + +"@esbuild/linux-riscv64@0.19.0": + version "0.19.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.19.0.tgz#83beafa472ad4224adcd4d7469e3a17ba1fbd976" + integrity sha512-jfvdKjWk+Cp2sgLtEEdSHXO7qckrw2B2eFBaoRdmfhThqZs29GMMg7q/LsQpybA7BxCLLEs4di5ucsWzZC5XPA== + +"@esbuild/linux-s390x@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.17.19.tgz#e2afd1afcaf63afe2c7d9ceacd28ec57c77f8829" + integrity sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q== + +"@esbuild/linux-s390x@0.19.0": + version "0.19.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.19.0.tgz#edc26cb41d8745716bda9c26bac1f0001eaad029" + integrity sha512-ofcucfNLkoXmcnJaw9ugdEOf40AWKGt09WBFCkpor+vFJVvmk/8OPjl/qRtks2Z7BuZbG3ztJuK1zS9z5Cgx9A== + +"@esbuild/linux-x64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz#8a0e9738b1635f0c53389e515ae83826dec22aa4" + integrity sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw== + +"@esbuild/linux-x64@0.19.0": + version "0.19.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.19.0.tgz#80a6b5e55ad454e0c0af5bdb267335287e331007" + integrity sha512-Fpf7zNDBti3xrQKQKLdXT0hTyOxgFdRJIMtNy8x1az9ATR9/GJ1brYbB/GLWoXhKiHsoWs+2DLkFVNNMTCLEwA== + +"@esbuild/netbsd-x64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.17.19.tgz#c29fb2453c6b7ddef9a35e2c18b37bda1ae5c462" + integrity sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q== + +"@esbuild/netbsd-x64@0.19.0": + version "0.19.0" + resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.19.0.tgz#2e6e8d869b58aea34bab9c0c47f15ae1bda29a90" + integrity sha512-AMQAp/5oENgDOvVhvOlbhVe1pWii7oFAMRHlmTjSEMcpjTpIHtFXhv9uAFgUERHm3eYtNvS9Vf+gT55cwuI6Aw== + +"@esbuild/openbsd-x64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.17.19.tgz#95e75a391403cb10297280d524d66ce04c920691" + integrity sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g== + +"@esbuild/openbsd-x64@0.19.0": + version "0.19.0" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.19.0.tgz#ca0817d3ab332afb0d8d96a2eb42b4d8ebaa8715" + integrity sha512-fDztEve1QUs3h/Dw2AUmBlWGkNQbhDoD05ppm5jKvzQv+HVuV13so7m5RYeiSMIC2XQy7PAjZh+afkxAnCRZxA== + +"@esbuild/sunos-x64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.17.19.tgz#722eaf057b83c2575937d3ffe5aeb16540da7273" + integrity sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg== + +"@esbuild/sunos-x64@0.19.0": + version "0.19.0" + resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.19.0.tgz#8de27de2563cb3eb6c1af066b6d7fcb1229fe3d4" + integrity sha512-bKZzJ2/rvUjDzA5Ddyva2tMk89WzNJEibZEaq+wY6SiqPlwgFbqyQLimouxLHiHh1itb5P3SNCIF1bc2bw5H9w== + +"@esbuild/win32-arm64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.17.19.tgz#9aa9dc074399288bdcdd283443e9aeb6b9552b6f" + integrity sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag== + +"@esbuild/win32-arm64@0.19.0": + version "0.19.0" + resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.19.0.tgz#67c2b410ff8862be2cd61145ad21e11be00fb914" + integrity sha512-NQJ+4jmnA79saI+sE+QzcEls19uZkoEmdxo7r//PDOjIpX8pmoWtTnWg6XcbnO7o4fieyAwb5U2LvgWynF4diA== + +"@esbuild/win32-ia32@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.17.19.tgz#95ad43c62ad62485e210f6299c7b2571e48d2b03" + integrity sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw== + +"@esbuild/win32-ia32@0.19.0": + version "0.19.0" + resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.19.0.tgz#cac8992219c6d943bb22226e4afeb3774a29cca1" + integrity sha512-uyxiZAnsfu9diHm9/rIH2soecF/HWLXYUhJKW4q1+/LLmNQ+55lRjvSUDhUmsgJtSUscRJB/3S4RNiTb9o9mCg== + +"@esbuild/win32-x64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz#8cfaf2ff603e9aabb910e9c0558c26cf32744061" + integrity sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA== + +"@esbuild/win32-x64@0.19.0": + version "0.19.0" + resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.19.0.tgz#fa5f12c96811cec3233a53bdbf61d1a05ba9018f" + integrity sha512-jl+NXUjK2StMgqnZnqgNjZuerFG8zQqWXMBZdMMv4W/aO1ZKQaYWZBxTrtWKphkCBVEMh0wMVfGgOd2BjOZqUQ== + "@eslint-community/eslint-utils@^4.1.2", "@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0": version "4.4.0" resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59" @@ -1634,11 +1876,6 @@ resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78" integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w== -"@jridgewell/resolve-uri@^3.0.3": - version "3.1.1" - resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz#c08679063f279615a3326583ba3a90d1d82cc721" - integrity sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA== - "@jridgewell/set-array@^1.0.1": version "1.1.2" resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72" @@ -1654,14 +1891,6 @@ resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32" integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg== -"@jridgewell/trace-mapping@0.3.9": - version "0.3.9" - resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz#6534fd5933a53ba7cbf3a17615e273a0d1273ff9" - integrity sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ== - dependencies: - "@jridgewell/resolve-uri" "^3.0.3" - "@jridgewell/sourcemap-codec" "^1.4.10" - "@jridgewell/trace-mapping@^0.3.17", "@jridgewell/trace-mapping@^0.3.9": version "0.3.18" resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.18.tgz#25783b2086daf6ff1dcb53c9249ae480e4dd4cd6" @@ -1828,176 +2057,196 @@ resolved "https://registry.yarnpkg.com/@opentelemetry/api/-/api-1.4.1.tgz#ff22eb2e5d476fbc2450a196e40dd243cc20c28f" integrity sha512-O2yRJce1GOc6PAy3QxFM4NzFiWzvScDC1/5ihYBL6BUEVdq0XMWN01sppE+H6bBXbaFYipjwFLEWLg5PaSOThA== -"@opentelemetry/context-async-hooks@1.13.0": - version "1.13.0" - resolved "https://registry.yarnpkg.com/@opentelemetry/context-async-hooks/-/context-async-hooks-1.13.0.tgz#b697317c1670eaa9b1c23201d09dd29250dcc8fa" - integrity sha512-pS5fU4lrRjOIPZQqA2V1SUM9QUFXbO+8flubAiy6ntLjnAjJJUdRFOUOxK6v86ZHI2p2S8A0vD0BTu95FZYvjA== +"@opentelemetry/context-async-hooks@1.15.1": + version "1.15.1" + resolved "https://registry.yarnpkg.com/@opentelemetry/context-async-hooks/-/context-async-hooks-1.15.1.tgz#694798afeb83eab5fe31c6e15762815b27615c65" + integrity sha512-JHPs/o15OO902lI5jkWWPz0JyOpQav7hfOY20MZFH/elq6kSvjBTw5cCu1v7SJwN0Ac3n08fOjYK+jtNlYP0LA== -"@opentelemetry/core@1.13.0", "@opentelemetry/core@^1.8.0": +"@opentelemetry/core@1.15.1", "@opentelemetry/core@^1.1.0", "@opentelemetry/core@^1.13.0": + version "1.15.1" + resolved "https://registry.yarnpkg.com/@opentelemetry/core/-/core-1.15.1.tgz#a580a547c1006cc411ae7aacd4991b52555b3f1d" + integrity sha512-V6GoRTY6aANMDDOQ9CiHOiLWEK2b2b3OGZK+zk05Li5merb9jadFeV5ooTSGtjxfxVNMpQUaQERO1cdbdbeEGg== + dependencies: + "@opentelemetry/semantic-conventions" "1.15.1" + +"@opentelemetry/core@^1.8.0": version "1.13.0" resolved "https://registry.yarnpkg.com/@opentelemetry/core/-/core-1.13.0.tgz#7cdcb4176d260d279b0aa31456c4ce2ba7f410aa" integrity sha512-2dBX3Sj99H96uwJKvc2w9NOiNgbvAO6mOFJFramNkKfS9O4Um+VWgpnlAazoYjT6kUJ1MP70KQ5ngD4ed+4NUw== dependencies: "@opentelemetry/semantic-conventions" "1.13.0" -"@opentelemetry/exporter-jaeger@^1.3.1": - version "1.13.0" - resolved "https://registry.yarnpkg.com/@opentelemetry/exporter-jaeger/-/exporter-jaeger-1.13.0.tgz#e96436438d3f8cc7b262ab4e517d55f96f413161" - integrity sha512-ke/STs/erRDqKmNv6Dv+5SetXsVD+Zm1/Wo8cLdAGrZn6kG6Fyp5EXVO/BJuzx6q+jHCdODm8jV4veXl4m71nQ== +"@opentelemetry/exporter-jaeger@^1.15.1": + version "1.15.1" + resolved "https://registry.yarnpkg.com/@opentelemetry/exporter-jaeger/-/exporter-jaeger-1.15.1.tgz#2081eae6ea7906ff39ad82b4aeed0f8913692fe9" + integrity sha512-Rh+0OQXeOzyTpDJ48+iJRIp7Sq1RKTycG9seoiBecwxyevnNLPghAZvj/DgOc7SGK8kmK2CQ0aqkhBE3kT6hKw== dependencies: - "@opentelemetry/core" "1.13.0" - "@opentelemetry/sdk-trace-base" "1.13.0" - "@opentelemetry/semantic-conventions" "1.13.0" + "@opentelemetry/core" "1.15.1" + "@opentelemetry/sdk-trace-base" "1.15.1" + "@opentelemetry/semantic-conventions" "1.15.1" jaeger-client "^3.15.0" -"@opentelemetry/exporter-prometheus@~0.39.1": - version "0.39.1" - resolved "https://registry.yarnpkg.com/@opentelemetry/exporter-prometheus/-/exporter-prometheus-0.39.1.tgz#2ce574e54faae628a260579b4ffa7b73456fb331" - integrity sha512-FRedkVIUgLApKd9aF7cpflXzXRkHxKiV9pJwvY8dqk9amP5QuZKZgP3d+2L1IIKe10+JbcKIrijddZnT9jID2g== +"@opentelemetry/exporter-prometheus@~0.41.1": + version "0.41.1" + resolved "https://registry.yarnpkg.com/@opentelemetry/exporter-prometheus/-/exporter-prometheus-0.41.1.tgz#1721c918908f71cdfc5174bb8d2fa0b59eb760e9" + integrity sha512-6XpRLbzZ0AWmECSa3mpHcN7E5ilfUf2dbBB0VhdnNvTycBnLNMbFFJ06lVVLFLg8BgnxH+S30KaPP8Jng979pA== dependencies: - "@opentelemetry/core" "1.13.0" - "@opentelemetry/resources" "1.13.0" - "@opentelemetry/sdk-metrics" "1.13.0" + "@opentelemetry/core" "1.15.1" + "@opentelemetry/resources" "1.15.1" + "@opentelemetry/sdk-metrics" "1.15.1" -"@opentelemetry/instrumentation-dns@^0.31.2": - version "0.31.4" - resolved "https://registry.yarnpkg.com/@opentelemetry/instrumentation-dns/-/instrumentation-dns-0.31.4.tgz#515dc3afac32fdf192e3b91553baade738634145" - integrity sha512-TUNybmyCYxKQwvFo+6gzaTBYP5aO9i2wqo/gBCAgd/TnHZzzEpRl4PZIwU1qzNRTcHUzpHXYA05F7GyQGebEVw== +"@opentelemetry/instrumentation-dns@^0.32.0": + version "0.32.0" + resolved "https://registry.yarnpkg.com/@opentelemetry/instrumentation-dns/-/instrumentation-dns-0.32.0.tgz#2262e6b68bb415508cde4958b914a17ea5356c0b" + integrity sha512-Q6RHePHnMQdKsAKzKvPSN0nPfKVlzFlbPa9/nb3r0FhThCP/Ucjob138X4LEDy0ZyZs3mq8Vqr9riyyRHIW6iA== dependencies: - "@opentelemetry/instrumentation" "^0.39.1" + "@opentelemetry/instrumentation" "^0.41.0" "@opentelemetry/semantic-conventions" "^1.0.0" semver "^7.3.2" + tslib "^2.3.1" -"@opentelemetry/instrumentation-express@^0.32.1": - version "0.32.3" - resolved "https://registry.yarnpkg.com/@opentelemetry/instrumentation-express/-/instrumentation-express-0.32.3.tgz#cd381cbcf048146731f407ce7aaef19e272ae197" - integrity sha512-/A9eJAA7XXj6GkktlsM9YKORQiIpgFRZT3J79MEGNbMwNHTPh4sOuzjAnARcpUQ3JKuYs7T98fs35aRH+Ms43w== +"@opentelemetry/instrumentation-express@^0.33.0": + version "0.33.0" + resolved "https://registry.yarnpkg.com/@opentelemetry/instrumentation-express/-/instrumentation-express-0.33.0.tgz#d972ef43420759761f7dbfe78a6ae159cd925a69" + integrity sha512-Cem3AssubzUoBK5ab89rBt2kY90i/FFyQwMC9wPjBQldkOaT4cR+5ufvWritXRfoPltqEeX2imLavujNH6EzCw== dependencies: "@opentelemetry/core" "^1.8.0" - "@opentelemetry/instrumentation" "^0.39.1" + "@opentelemetry/instrumentation" "^0.41.0" "@opentelemetry/semantic-conventions" "^1.0.0" "@types/express" "4.17.13" + tslib "^2.3.1" -"@opentelemetry/instrumentation-fs@^0.7.0": - version "0.7.3" - resolved "https://registry.yarnpkg.com/@opentelemetry/instrumentation-fs/-/instrumentation-fs-0.7.3.tgz#3fd631f0606ea25fc08936b7e8a89f6eb3571cb3" - integrity sha512-GUJvcU6/lZI4gpA3Mu7FP7hVHYk9IS6C2gGJlEhzzBOrStIw+xWzupFbra+sA2+ds1IPDUdAOBvNp0fhBrou5A== +"@opentelemetry/instrumentation-fs@^0.8.0": + version "0.8.0" + resolved "https://registry.yarnpkg.com/@opentelemetry/instrumentation-fs/-/instrumentation-fs-0.8.0.tgz#63d6936b7e5d3de6aeffb4a37b0c5f65accd132c" + integrity sha512-uZMLqy1LKkLlRKC84HkjU3DYmVixTzRlxdfINHFyStBEEw345fI4xPs0cXg1KcQDoxWscFyX2nhB/Q6cpHurbA== dependencies: "@opentelemetry/core" "^1.8.0" - "@opentelemetry/instrumentation" "^0.39.1" + "@opentelemetry/instrumentation" "^0.41.0" "@opentelemetry/semantic-conventions" "^1.0.0" + tslib "^2.3.1" -"@opentelemetry/instrumentation-http@^0.39.1": - version "0.39.1" - resolved "https://registry.yarnpkg.com/@opentelemetry/instrumentation-http/-/instrumentation-http-0.39.1.tgz#1bc63d4773fe7996a933a1351877e9a6ea73859a" - integrity sha512-JX1HTvNOqqel2fuMSRiSzFREyk2iMQ2B4/1Y46AGa0u6i4XQRCbCuy64FZ1YYMrQ2e5P917iiGrEUFkB+33Tlw== +"@opentelemetry/instrumentation-http@^0.41.1": + version "0.41.1" + resolved "https://registry.yarnpkg.com/@opentelemetry/instrumentation-http/-/instrumentation-http-0.41.1.tgz#94bc5df488db9f46d65ce22d83bf7dbe256205bd" + integrity sha512-fhLBlSxTg+jw5HZVzOvH4tIUQHJkP8L2dyYYXu60sppYZHFVltL/DyfoMErdq5cSn97WHWfRqnbYrG0wlPJedA== dependencies: - "@opentelemetry/core" "1.13.0" - "@opentelemetry/instrumentation" "0.39.1" - "@opentelemetry/semantic-conventions" "1.13.0" - semver "^7.3.5" + "@opentelemetry/core" "1.15.1" + "@opentelemetry/instrumentation" "0.41.1" + "@opentelemetry/semantic-conventions" "1.15.1" + semver "^7.5.1" -"@opentelemetry/instrumentation-ioredis@^0.34.2": - version "0.34.2" - resolved "https://registry.yarnpkg.com/@opentelemetry/instrumentation-ioredis/-/instrumentation-ioredis-0.34.2.tgz#3810c34cd30bd39523fcaae6c6250048f92eb5ad" - integrity sha512-tlXYJzBUytjN3UbFFVxuCJkZc6y/OmeAuH4VKoCV1fwx8iveQar1I9+mzf6H2Ur8CnzoCv4cq7bEhZAJepLN8g== +"@opentelemetry/instrumentation-ioredis@^0.35.0": + version "0.35.0" + resolved "https://registry.yarnpkg.com/@opentelemetry/instrumentation-ioredis/-/instrumentation-ioredis-0.35.0.tgz#aa6fb1ff9965980e407950bc44f6e5127eb877df" + integrity sha512-tdM1BkrYmx+fXH+t1DViTXqFr9LUJHl0Qdcr6G8PjscsK+bVssSHhi5a3zYPFFFHpjks1mXMZHMr/Vsj2hNQAw== dependencies: - "@opentelemetry/instrumentation" "^0.39.1" - "@opentelemetry/redis-common" "^0.35.1" + "@opentelemetry/instrumentation" "^0.41.0" + "@opentelemetry/redis-common" "^0.36.0" "@opentelemetry/semantic-conventions" "^1.0.0" "@types/ioredis4" "npm:@types/ioredis@^4.28.10" + tslib "^2.3.1" -"@opentelemetry/instrumentation-pg@^0.35.2": - version "0.35.2" - resolved "https://registry.yarnpkg.com/@opentelemetry/instrumentation-pg/-/instrumentation-pg-0.35.2.tgz#2eb56e24318aa67f8b8a3ac4d8314a1622385c82" - integrity sha512-DsRHUgacDZKc2obohpgCeVSyew3lWH7QHqk6awfz/e2/i+Zl6KvhcOUH3H3pFbcXScWliJlLlNa8XE6omFiI/Q== +"@opentelemetry/instrumentation-pg@^0.36.0": + version "0.36.0" + resolved "https://registry.yarnpkg.com/@opentelemetry/instrumentation-pg/-/instrumentation-pg-0.36.0.tgz#43270d2849a0e074ec6eb705dc12216e5c7cc84c" + integrity sha512-S9RmzTILWTl7AVfdp/e8lWQTlpwrpoPbpxAfEJ1ENzTlPMmdw0jWPAQTgrTLQa6cpzhiypDHts3g2b6hc1zFYQ== dependencies: "@opentelemetry/core" "^1.8.0" - "@opentelemetry/instrumentation" "^0.39.1" + "@opentelemetry/instrumentation" "^0.41.0" "@opentelemetry/semantic-conventions" "^1.0.0" + "@opentelemetry/sql-common" "^0.40.0" "@types/pg" "8.6.1" "@types/pg-pool" "2.0.3" + tslib "^2.3.1" -"@opentelemetry/instrumentation@0.39.1", "@opentelemetry/instrumentation@^0.39.1": - version "0.39.1" - resolved "https://registry.yarnpkg.com/@opentelemetry/instrumentation/-/instrumentation-0.39.1.tgz#46d03b4c7ce9f8d08f575d756acc801fa1283615" - integrity sha512-s7/9tPmM0l5KCd07VQizC4AO2/5UJdkXq5gMSHPdCeiMKSeBEdyDyQX7A+Cq+RYZM452qzFmrJ4ut628J5bnSg== +"@opentelemetry/instrumentation@0.41.1", "@opentelemetry/instrumentation@^0.41.0", "@opentelemetry/instrumentation@^0.41.1": + version "0.41.1" + resolved "https://registry.yarnpkg.com/@opentelemetry/instrumentation/-/instrumentation-0.41.1.tgz#20b8b1b15812a18acfa3b744abf90223b1d26eb0" + integrity sha512-IsOidIIgI7Sg2NhWGYRZRifiv9kLyrxT89hBK1YVPDetuBEBUgFzD5VXdwqwfOKL3kgT4KiERMmLJ8gqig0o1A== dependencies: - require-in-the-middle "^7.1.0" - semver "^7.3.2" + "@types/shimmer" "^1.0.2" + import-in-the-middle "1.4.1" + require-in-the-middle "^7.1.1" + semver "^7.5.1" shimmer "^1.2.1" -"@opentelemetry/instrumentation@^0.35.1": - version "0.35.1" - resolved "https://registry.yarnpkg.com/@opentelemetry/instrumentation/-/instrumentation-0.35.1.tgz#065bdbc4771137347e648eb4c6c6de6e9e97e4d1" - integrity sha512-EZsvXqxenbRTSNsft6LDcrT4pjAiyZOx3rkDNeqKpwZZe6GmZtsXaZZKuDkJtz9fTjOGjDHjZj9/h80Ya9iIJw== +"@opentelemetry/propagator-b3@1.15.1": + version "1.15.1" + resolved "https://registry.yarnpkg.com/@opentelemetry/propagator-b3/-/propagator-b3-1.15.1.tgz#d3c625d18945c9fd501ed7e2a628f56d0a80c378" + integrity sha512-Rgzp5CgxSLDLdtiUx/nv+1jkyyU/qbhTqTBxMUvk4fqPfddzQNZyllyJ9IMNp9Xh4pzYlPP5ZBlN5Sw5isjuaw== dependencies: - require-in-the-middle "^5.0.3" - semver "^7.3.2" - shimmer "^1.2.1" + "@opentelemetry/core" "1.15.1" -"@opentelemetry/propagator-b3@1.13.0": - version "1.13.0" - resolved "https://registry.yarnpkg.com/@opentelemetry/propagator-b3/-/propagator-b3-1.13.0.tgz#30a19a24e61ae8dbc26c2d7d7d3423d804d48f07" - integrity sha512-HOo91EI4UbuG8xQVLFziTzrcIn0MJQhy8m9jorh8aonb94jFVFi3CFNIiAnIGOabmnshJLOABxpYXsiPB8Xnzg== +"@opentelemetry/propagator-jaeger@1.15.1": + version "1.15.1" + resolved "https://registry.yarnpkg.com/@opentelemetry/propagator-jaeger/-/propagator-jaeger-1.15.1.tgz#1af170b9cee5cba556ccb2e21d547260cb5c33ad" + integrity sha512-27cljZFnbUv5e459e2BhcsHCn2yePYq+07dZNW51e6F05GDWHC86fpwdh+WKvrfKSRMddUMkufHyoBWxtUN/Vg== dependencies: - "@opentelemetry/core" "1.13.0" + "@opentelemetry/core" "1.15.1" -"@opentelemetry/propagator-jaeger@1.13.0": - version "1.13.0" - resolved "https://registry.yarnpkg.com/@opentelemetry/propagator-jaeger/-/propagator-jaeger-1.13.0.tgz#94a79d5301409d49b149227ee5568fcf6b21f9fe" - integrity sha512-IV9TO+u1Jzm9mUDAD3gyXf89eyvgEJUY1t+GB5QmS4wjVeWrSMUtD0JjH3yG9SNqkrQOqOGJq7YUSSetW+Lf5Q== +"@opentelemetry/redis-common@^0.36.0": + version "0.36.0" + resolved "https://registry.yarnpkg.com/@opentelemetry/redis-common/-/redis-common-0.36.0.tgz#5b992d76838a385820f452235b7714e0f270e4ac" + integrity sha512-rTKuBszerwzKm0uBmffJ8j47+5YBGu6HGUWnez5gev2B4by8TKkY37E/QMq7/3KRL9NkZ08VJCtl3piCCFW30g== dependencies: - "@opentelemetry/core" "1.13.0" + tslib "^2.3.1" -"@opentelemetry/redis-common@^0.35.1": - version "0.35.1" - resolved "https://registry.yarnpkg.com/@opentelemetry/redis-common/-/redis-common-0.35.1.tgz#01356f6845d4f9f9fdfd2c4c562a74316d2d24d3" - integrity sha512-qLXe7h9VzFLx3LaizFiUlpuohCRyvHlDW5b9synE6omHKTZr/n0EHEdmhp3GezBeAqMGI+q499Mht4SmStaSqQ== - -"@opentelemetry/resources@1.13.0", "@opentelemetry/resources@^1.3.1": - version "1.13.0" - resolved "https://registry.yarnpkg.com/@opentelemetry/resources/-/resources-1.13.0.tgz#436b33ea950004e66fce6575f2776a05faca7f8e" - integrity sha512-euqjOkiN6xhjE//0vQYGvbStxoD/WWQRhDiO0OTLlnLBO9Yw2Gd/VoSx2H+svsebjzYk5OxLuREBmcdw6rbUNg== +"@opentelemetry/resources@1.15.1", "@opentelemetry/resources@^1.15.1": + version "1.15.1" + resolved "https://registry.yarnpkg.com/@opentelemetry/resources/-/resources-1.15.1.tgz#6a0da2eb5d394d302701d428a1cbbb2cd924ac50" + integrity sha512-15JcpyKZHhFYQ1uiC08vR02sRY/2seSnqSJ0tIUhcdYDzOhd0FrqPYpLj3WkLhVdQP6vgJ+pelAmSaOrCxCpKA== dependencies: - "@opentelemetry/core" "1.13.0" - "@opentelemetry/semantic-conventions" "1.13.0" + "@opentelemetry/core" "1.15.1" + "@opentelemetry/semantic-conventions" "1.15.1" -"@opentelemetry/sdk-metrics@1.13.0", "@opentelemetry/sdk-metrics@^1.8.0": - version "1.13.0" - resolved "https://registry.yarnpkg.com/@opentelemetry/sdk-metrics/-/sdk-metrics-1.13.0.tgz#4e859107a7a4389bcda7b37d3952bc7dd34211d7" - integrity sha512-MOjZX6AnSOqLliCcZUrb+DQKjAWXBiGeICGbHAGe5w0BB18PJIeIo995lO5JSaFfHpmUMgJButTPfJJD27W3Vg== +"@opentelemetry/sdk-metrics@1.15.1", "@opentelemetry/sdk-metrics@^1.15.1": + version "1.15.1" + resolved "https://registry.yarnpkg.com/@opentelemetry/sdk-metrics/-/sdk-metrics-1.15.1.tgz#e0d2844191ecd7fce3fccf18ae50ed35389f0885" + integrity sha512-ojcrzexOQfto83NvKfIvsJap4SHH3ZvLjsDGhQ04AfvWWGR7mPcqLSlLedoSkEdIe0k1H6uBEsHBtIprkMpTHA== dependencies: - "@opentelemetry/core" "1.13.0" - "@opentelemetry/resources" "1.13.0" - lodash.merge "4.6.2" + "@opentelemetry/core" "1.15.1" + "@opentelemetry/resources" "1.15.1" + lodash.merge "^4.6.2" -"@opentelemetry/sdk-trace-base@1.13.0", "@opentelemetry/sdk-trace-base@^1.3.1": - version "1.13.0" - resolved "https://registry.yarnpkg.com/@opentelemetry/sdk-trace-base/-/sdk-trace-base-1.13.0.tgz#096cc2759430d880c5d886e009df2605097403dc" - integrity sha512-moTiQtc0uPR1hQLt6gLDJH9IIkeBhgRb71OKjNHZPE1VF45fHtD6nBDi5J/DkTHTwYP5X3kBJLa3xN7ub6J4eg== +"@opentelemetry/sdk-trace-base@1.15.1", "@opentelemetry/sdk-trace-base@^1.15.1": + version "1.15.1" + resolved "https://registry.yarnpkg.com/@opentelemetry/sdk-trace-base/-/sdk-trace-base-1.15.1.tgz#8eabc0827769d91ac86cde8a86ebf0bf2a7d22ad" + integrity sha512-5hccBe2yXzzXyExJNkTsIzDe1AM7HK0al+y/D2yEpslJqS1HUzsUSuCMY7Z4+Sfz5Gf0kTa6KYEt1QUQppnoBA== dependencies: - "@opentelemetry/core" "1.13.0" - "@opentelemetry/resources" "1.13.0" - "@opentelemetry/semantic-conventions" "1.13.0" + "@opentelemetry/core" "1.15.1" + "@opentelemetry/resources" "1.15.1" + "@opentelemetry/semantic-conventions" "1.15.1" -"@opentelemetry/sdk-trace-node@^1.3.1": - version "1.13.0" - resolved "https://registry.yarnpkg.com/@opentelemetry/sdk-trace-node/-/sdk-trace-node-1.13.0.tgz#baadf62218ca69e37486debfbcf15b2563f75979" - integrity sha512-FXA85lXKTsnbOflA/TBuBf2pmhD3c8uDjNjG0YqK+ap8UayfALmfJhf+aG1yBOUHevCY0JXJ4/xtbXExxpsMog== +"@opentelemetry/sdk-trace-node@^1.15.1": + version "1.15.1" + resolved "https://registry.yarnpkg.com/@opentelemetry/sdk-trace-node/-/sdk-trace-node-1.15.1.tgz#d1589ead5fe8aa2dc6789ec31e16965b4dcaf259" + integrity sha512-aZDcuYHwh+qyOD/FLFAEAh32V2DlAp8Ubyaohh51oSssC3cxmN9JmpkyPbp2PQX3Mn48gBubwTXr9g++3+NB5w== dependencies: - "@opentelemetry/context-async-hooks" "1.13.0" - "@opentelemetry/core" "1.13.0" - "@opentelemetry/propagator-b3" "1.13.0" - "@opentelemetry/propagator-jaeger" "1.13.0" - "@opentelemetry/sdk-trace-base" "1.13.0" - semver "^7.3.5" + "@opentelemetry/context-async-hooks" "1.15.1" + "@opentelemetry/core" "1.15.1" + "@opentelemetry/propagator-b3" "1.15.1" + "@opentelemetry/propagator-jaeger" "1.15.1" + "@opentelemetry/sdk-trace-base" "1.15.1" + semver "^7.5.1" -"@opentelemetry/semantic-conventions@1.13.0", "@opentelemetry/semantic-conventions@^1.0.0", "@opentelemetry/semantic-conventions@^1.3.1", "@opentelemetry/semantic-conventions@^1.8.0": +"@opentelemetry/semantic-conventions@1.13.0", "@opentelemetry/semantic-conventions@^1.0.0": version "1.13.0" resolved "https://registry.yarnpkg.com/@opentelemetry/semantic-conventions/-/semantic-conventions-1.13.0.tgz#0290398b3eaebc6029c348988a78c3b688fe9219" integrity sha512-LMGqfSZkaMQXqewO0o1wvWr/2fQdCh4a3Sqlxka/UsJCe0cfLulh6x2aqnKLnsrSGiCq5rSCwvINd152i0nCqw== +"@opentelemetry/semantic-conventions@1.15.1", "@opentelemetry/semantic-conventions@^1.14.0", "@opentelemetry/semantic-conventions@^1.15.1": + version "1.15.1" + resolved "https://registry.yarnpkg.com/@opentelemetry/semantic-conventions/-/semantic-conventions-1.15.1.tgz#3d745996b2bd11095b515515fd3d68d46092a02d" + integrity sha512-n8Kur1/CZlYG32YCEj30CoUqA8R7UyDVZzoEU6SDP+13+kXDT2kFVu6MpcnEUTyGP3i058ID6Qjp5h6IJxdPPQ== + +"@opentelemetry/sql-common@^0.40.0": + version "0.40.0" + resolved "https://registry.yarnpkg.com/@opentelemetry/sql-common/-/sql-common-0.40.0.tgz#8cbed0722354d62997c3b9e1adf0e16257be6b15" + integrity sha512-vSqRJYUPJVjMFQpYkQS3ruexCPSZJ8esne3LazLwtCPaPRvzZ7WG3tX44RouAn7w4wMp8orKguBqtt+ng2UTnw== + dependencies: + "@opentelemetry/core" "^1.1.0" + "@peertube/feed@^5.1.0": version "5.1.0" resolved "https://registry.yarnpkg.com/@peertube/feed/-/feed-5.1.0.tgz#e2fec950459ebaa32ea35791c45177f8b6fa85e9" @@ -2026,6 +2275,15 @@ smtp-server "^3.9.0" wildstring "1.0.9" +"@peertube/resolve-tspaths@^0.8.14": + version "0.8.14" + resolved "https://registry.yarnpkg.com/@peertube/resolve-tspaths/-/resolve-tspaths-0.8.14.tgz#a4acee0b6ff713fe38c92e6e7f4f4c0c3eabce3c" + integrity sha512-EnYh2GSY5qDPJ0TVt/UexuLQrB1vshOFXOM6OnqaV4e1WOYpxmtzu5amPFBRBLcGH9aJ4HM5eyDR3ka7Corjjw== + dependencies: + ansi-colors "4.1.3" + commander "11.0.0" + fast-glob "3.3.1" + "@selderee/plugin-htmlparser2@^0.10.0": version "0.10.0" resolved "https://registry.yarnpkg.com/@selderee/plugin-htmlparser2/-/plugin-htmlparser2-0.10.0.tgz#8a304d18df907e086f3cfc71ea0ced52d6524430" @@ -2042,10 +2300,10 @@ domhandler "^5.0.3" selderee "^0.11.0" -"@sindresorhus/is@^4.0.0": - version "4.6.0" - resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-4.6.0.tgz#3c7c9c46e678feefe7a2e5bb609d3dbd665ffb3f" - integrity sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw== +"@sindresorhus/is@^5.2.0": + version "5.6.0" + resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-5.6.0.tgz#41dd6093d34652cddb5d5bdeee04eafc33826668" + integrity sha512-TV7t8GKYaJWsn00tFDqBw8+Uqmr8A0fRU1tvTQhyZzGv0sJCGRQL3JGMI3ucuKo3XIZdUP+Lx7/gh2t3lewy7g== "@smithy/protocol-http@^1.0.1": version "1.0.1" @@ -2067,38 +2325,18 @@ resolved "https://registry.yarnpkg.com/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz#96116f2a912e0c02817345b3c10751069920d553" integrity sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg== -"@szmarczak/http-timer@^4.0.5": - version "4.0.6" - resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-4.0.6.tgz#b4a914bb62e7c272d4e5989fe4440f812ab1d807" - integrity sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w== +"@szmarczak/http-timer@^5.0.1": + version "5.0.1" + resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-5.0.1.tgz#c7c1bf1141cdd4751b0399c8fc7b8b664cd5be3a" + integrity sha512-+PmQX0PiAYPMeVYe237LJAYvOMYW1j2rH5YROyS3b4CTVJum34HfRvKvAzozHAQG0TnHNdUfY9nCeUyRAs//cw== dependencies: - defer-to-connect "^2.0.0" + defer-to-connect "^2.0.1" "@tokenizer/token@^0.3.0": version "0.3.0" resolved "https://registry.yarnpkg.com/@tokenizer/token/-/token-0.3.0.tgz#fe98a93fe789247e998c75e74e9c7c63217aa276" integrity sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A== -"@tsconfig/node10@^1.0.7": - version "1.0.9" - resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.9.tgz#df4907fc07a886922637b15e02d4cebc4c0021b2" - integrity sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA== - -"@tsconfig/node12@^1.0.7": - version "1.0.11" - resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.11.tgz#ee3def1f27d9ed66dac6e46a295cffb0152e058d" - integrity sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag== - -"@tsconfig/node14@^1.0.0": - version "1.0.3" - resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.3.tgz#e4386316284f00b98435bf40f72f75a09dabf6c1" - integrity sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow== - -"@tsconfig/node16@^1.0.2": - version "1.0.4" - resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.4.tgz#0b92dcc0cc1c81f6f306a381f28e31b1a56536e9" - integrity sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA== - "@types/bcrypt@^5.0.0": version "5.0.0" resolved "https://registry.yarnpkg.com/@types/bcrypt/-/bcrypt-5.0.0.tgz#a835afa2882d165aff5690893db314eaa98b9f20" @@ -2138,16 +2376,6 @@ resolved "https://registry.yarnpkg.com/@types/bytes/-/bytes-3.1.1.tgz#67a876422e660dc4c10a27f3e5bcfbd5455f01d0" integrity sha512-lOGyCnw+2JVPKU3wIV0srU0NyALwTBJlVSx5DfMQOFuuohA8y9S8orImpuIQikZ0uIQ8gehrRjxgQC1rLRi11w== -"@types/cacheable-request@^6.0.1": - version "6.0.3" - resolved "https://registry.yarnpkg.com/@types/cacheable-request/-/cacheable-request-6.0.3.tgz#a430b3260466ca7b5ca5bfd735693b36e7a9d183" - integrity sha512-IQ3EbTzGxIigb1I3qPZc1rWJnH0BmSKv5QYTalEwweFvyBDLSAe24zP0le/hyi7ecGfZVlIVAg4BZqb8WBwKqw== - dependencies: - "@types/http-cache-semantics" "*" - "@types/keyv" "^3.1.4" - "@types/node" "*" - "@types/responselike" "^1.0.0" - "@types/caseless@*": version "0.12.2" resolved "https://registry.yarnpkg.com/@types/caseless/-/caseless-0.12.2.tgz#f65d3d6389e01eeb458bd54dc8f52b95a9463bc8" @@ -2270,7 +2498,7 @@ "@types/jsonfile" "*" "@types/node" "*" -"@types/http-cache-semantics@*": +"@types/http-cache-semantics@^4.0.1": version "4.0.1" resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz#0ea7b61496902b95890dc4c3a116b60cb8dae812" integrity sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ== @@ -2299,17 +2527,22 @@ dependencies: "@types/node" "*" -"@types/keyv@^3.1.4": - version "3.1.4" - resolved "https://registry.yarnpkg.com/@types/keyv/-/keyv-3.1.4.tgz#3ccdb1c6751b0c7e52300bcdacd5bcbf8faa75b6" - integrity sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg== - dependencies: - "@types/node" "*" +"@types/jsonld@^1.5.9": + version "1.5.9" + resolved "https://registry.yarnpkg.com/@types/jsonld/-/jsonld-1.5.9.tgz#aca18d90b91488d15f8b4e941f660da4093be783" + integrity sha512-K76ImkErPYL2wGPZpNFSKp6wE+h/APecZLJrU7UfDaGqt/f+D9Rrg1aR7VdRrQ6k5DUNRZ2vn9yACwmpOr9QcA== -"@types/lodash@^4.14.64": - version "4.14.194" - resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.194.tgz#b71eb6f7a0ff11bff59fc987134a093029258a76" - integrity sha512-r22s9tAS7imvBt2lyHC9B8AGwWnXaYb1tY09oyLkXDs4vArpYJzw09nj8MLx5VfciBPGIb+ZwG0ssYnEPJxn/g== +"@types/lodash-es@^4.17.8": + version "4.17.8" + resolved "https://registry.yarnpkg.com/@types/lodash-es/-/lodash-es-4.17.8.tgz#cfffd0969507830c22da18dbb20d2ca126fdaa8b" + integrity sha512-euY3XQcZmIzSy7YH5+Unb3b2X12Wtk54YWINBvvGQ5SmMvwb11JQskGsfkH/5HXK77Kr8GF0wkVDIxzAisWtog== + dependencies: + "@types/lodash" "*" + +"@types/lodash@*": + version "4.14.196" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.196.tgz#a7c3d6fc52d8d71328b764e28e080b4169ec7a95" + integrity sha512-22y3o88f4a94mKljsZcanlNWPzO0uBsBdzLAngf2tp533LzZcQzb6+eZPJ+vCTt+bqF2XnvT9gejTLsAcJAJyQ== "@types/magnet-uri@*", "@types/magnet-uri@^5.1.1": version "5.1.3" @@ -2385,9 +2618,9 @@ integrity sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw== "@types/node@^18.13.0": - version "18.16.14" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.16.14.tgz#ab67bb907f1146afc6fedb9ce60ae8a99c989631" - integrity sha512-+ImzUB3mw2c5ISJUq0punjDilUQ5GnUim0ZRvchHIWJmOC0G+p0kzhXBqj6cDjK0QdPFwzrHWgrJp3RPvCG5qg== + version "18.17.1" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.17.1.tgz#84c32903bf3a09f7878c391d31ff08f6fe7d8335" + integrity sha512-xlR1jahfizdplZYRU59JlUx9uzF1ARa8jbhM11ccpCJya8kvos5jwdm2ZAgxSCwOl0fq21svP18EVwPBXMQudw== "@types/nodemailer@^6.2.0": version "6.4.8" @@ -2469,13 +2702,6 @@ "@types/tough-cookie" "*" form-data "^2.5.0" -"@types/responselike@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@types/responselike/-/responselike-1.0.0.tgz#251f4fe7d154d2bad125abe1b429b23afd262e29" - integrity sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA== - dependencies: - "@types/node" "*" - "@types/sax@^1.2.1": version "1.2.4" resolved "https://registry.yarnpkg.com/@types/sax/-/sax-1.2.4.tgz#8221affa7f4f3cb21abd22f244cfabfa63e6a69e" @@ -2504,6 +2730,11 @@ "@types/mime" "*" "@types/node" "*" +"@types/shimmer@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@types/shimmer/-/shimmer-1.0.2.tgz#93eb2c243c351f3f17d5c580c7467ae5d686b65f" + integrity sha512-dKkr1bTxbEsFlh2ARpKzcaAmsYixqt9UyCdoEZk8rHyE4iQYcDCyvSjDSf7JUWJHlJiTtbIoQjxKh6ViywqDAg== + "@types/simple-peer@*": version "9.11.5" resolved "https://registry.yarnpkg.com/@types/simple-peer/-/simple-peer-9.11.5.tgz#6baa00edbbd0f632f8561e8fb03b4d21d62f076e" @@ -2541,11 +2772,16 @@ resolved "https://registry.yarnpkg.com/@types/tv4/-/tv4-1.2.31.tgz#b33f3e6f082782a90f1fc5f414ad8722db8c9baa" integrity sha512-P97XU07fcpauSw3/fE2Q7eF6bHl4oHhwkikjnM7zlQLENrdC2rZuHSdNlMBhnW82NyBEsVJHII1Jk3d/MtQsQQ== -"@types/validator@^13.0.0", "@types/validator@^13.7.1": +"@types/validator@^13.7.1": version "13.7.17" resolved "https://registry.yarnpkg.com/@types/validator/-/validator-13.7.17.tgz#0a6d1510395065171e3378a4afc587a3aefa7cc1" integrity sha512-aqayTNmeWrZcvnG2MG9eGYI6b7S5fl+yKgPs6bAjOTwPS316R5SxBGKvtSExfyoJU7pIeHJfsHI0Ji41RVMkvQ== +"@types/validator@^13.9.0": + version "13.9.0" + resolved "https://registry.yarnpkg.com/@types/validator/-/validator-13.9.0.tgz#e7a96da3ea6a936222c6e76bb54abdd3dc4c9e4a" + integrity sha512-NclP0IbzHj/4tJZKFqKh8E7kZdgss+MCUYV9G+TLltFfDA4lFgE4PKPpDIyS2FlcdANIfSx273emkupvChigbw== + "@types/webtorrent@^0.109.0": version "0.109.3" resolved "https://registry.yarnpkg.com/@types/webtorrent/-/webtorrent-0.109.3.tgz#95df708d98bcea235b37f49a9a348b11f3511670" @@ -2742,26 +2978,31 @@ accepts@~1.3.4, accepts@~1.3.8: mime-types "~2.1.34" negotiator "0.6.3" +acorn-import-assertions@^1.9.0: + version "1.9.0" + resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz#507276249d684797c84e0734ef84860334cfb1ac" + integrity sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA== + acorn-jsx@^5.3.2: version "5.3.2" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== -acorn-walk@^8.1.1: - version "8.2.0" - resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" - integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== - acorn@^7.1.1: version "7.4.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== -acorn@^8.4.1, acorn@^8.8.0: +acorn@^8.8.0: version "8.8.2" resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a" integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw== +acorn@^8.8.2: + version "8.10.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.10.0.tgz#8be5b3907a67221a81ab23c7889c4c5526b62ec5" + integrity sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw== + addr-to-ip-port@^1.0.1, addr-to-ip-port@^1.5.4: version "1.5.4" resolved "https://registry.yarnpkg.com/addr-to-ip-port/-/addr-to-ip-port-1.5.4.tgz#9542b1c6219fdb8c9ce6cc72c14ee880ab7ddd88" @@ -2877,11 +3118,6 @@ are-we-there-yet@^2.0.0: delegates "^1.0.0" readable-stream "^3.6.0" -arg@^4.1.0: - version "4.1.3" - resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" - integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== - arg@^5.0.0: version "5.0.2" resolved "https://registry.yarnpkg.com/arg/-/arg-5.0.2.tgz#c81433cc427c92c4dcf4865142dbca6f15acd59c" @@ -3087,6 +3323,11 @@ base32.js@0.1.0: resolved "https://registry.yarnpkg.com/base32.js/-/base32.js-0.1.0.tgz#b582dec693c2f11e893cf064ee6ac5b6131a2202" integrity sha512-n3TkB02ixgBOhTvANakDb4xaMXnYUVkNoRFJjQflcqMQhyEKxEHdj3E6N8t8sUQ0mjH/3/JxzlXuz3ul/J90pQ== +base64-arraybuffer@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/base64-arraybuffer/-/base64-arraybuffer-1.0.2.tgz#1c37589a7c4b0746e34bd1feb951da2df01c1bdc" + integrity sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ== + base64-js@^1.0.2, base64-js@^1.2.0, base64-js@^1.3.1: version "1.5.1" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" @@ -3134,6 +3375,13 @@ bencode@^2.0.0, bencode@^2.0.1, bencode@^2.0.2, bencode@^2.0.3: resolved "https://registry.yarnpkg.com/bencode/-/bencode-2.0.3.tgz#89b9c80ea1b8573554915a7d0c15f62b0aa7fc52" integrity sha512-D/vrAD4dLVX23NalHwb8dSvsUsxeRPO8Y7ToKA015JQYq69MLDOMkC0uGZYA/MPpltLO8rt8eqFC2j8DxjTZ/w== +bencode@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/bencode/-/bencode-3.1.1.tgz#359901f9a93724ee0c709f9f8265456b368c60e6" + integrity sha512-btsxX9201yoWh45TdqYg6+OZ5O1xTYKTYSGvJndICDFtznE/9zXgow8yjMvvhOqKKuzuL7h+iiCMpfkG8+QuBA== + dependencies: + uint8-util "^2.1.6" + bep53-range@^1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/bep53-range/-/bep53-range-1.1.1.tgz#20fd125b00a413254a77d42f63a43750ca7e64ac" @@ -3446,23 +3694,23 @@ cache-chunk-store@^3.2.2: lru "^3.1.0" queue-microtask "^1.2.3" -cacheable-lookup@^5.0.3: - version "5.0.4" - resolved "https://registry.yarnpkg.com/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz#5a6b865b2c44357be3d5ebc2a467b032719a7005" - integrity sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA== +cacheable-lookup@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/cacheable-lookup/-/cacheable-lookup-7.0.0.tgz#3476a8215d046e5a3202a9209dd13fec1f933a27" + integrity sha512-+qJyx4xiKra8mZrcwhjMRMUhD5NR1R8esPkzIYxX96JiecFoxAXFuz/GpR3+ev4PE1WamHip78wV0vcmPQtp8w== -cacheable-request@^7.0.2: - version "7.0.2" - resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-7.0.2.tgz#ea0d0b889364a25854757301ca12b2da77f91d27" - integrity sha512-pouW8/FmiPQbuGpkXQ9BAPv/Mo5xDGANgSNXzTzJ8DrKGuXOssM4wIQRjfanNRh3Yu5cfYPvcorqbhg2KIJtew== +cacheable-request@^10.2.8: + version "10.2.13" + resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-10.2.13.tgz#b7012bb4a2acdb18cb54d2dff751d766b3500842" + integrity sha512-3SD4rrMu1msNGEtNSt8Od6enwdo//U9s4ykmXfA2TD58kcLkCobtCDiby7kNyj7a/Q7lz/mAesAFI54rTdnvBA== dependencies: - clone-response "^1.0.2" - get-stream "^5.1.0" - http-cache-semantics "^4.0.0" - keyv "^4.0.0" - lowercase-keys "^2.0.0" - normalize-url "^6.0.1" - responselike "^2.0.0" + "@types/http-cache-semantics" "^4.0.1" + get-stream "^6.0.1" + http-cache-semantics "^4.1.1" + keyv "^4.5.3" + mimic-response "^4.0.0" + normalize-url "^8.0.0" + responselike "^3.0.0" call-bind@^1.0.0, call-bind@^1.0.2: version "1.0.2" @@ -3664,6 +3912,11 @@ cidr-regex@^3.1.1: dependencies: ip-regex "^4.1.0" +cjs-module-lexer@^1.2.2: + version "1.2.3" + resolved "https://registry.yarnpkg.com/cjs-module-lexer/-/cjs-module-lexer-1.2.3.tgz#6c370ab19f8a3394e318fe682686ec0ac684d107" + integrity sha512-0TNiGstbQmCFwt4akjjBg5pLRTSyj/PkWQ1ZoO2zntmg9yLqSRxwEa4iCfQLGjqhiqBfOJa7W/E8wfGrTDmlZQ== + cli-table3@^0.6.0: version "0.6.3" resolved "https://registry.yarnpkg.com/cli-table3/-/cli-table3-0.6.3.tgz#61ab765aac156b52f222954ffc607a6f01dbeeb2" @@ -3700,13 +3953,6 @@ cliui@^8.0.1: strip-ansi "^6.0.1" wrap-ansi "^7.0.0" -clone-response@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/clone-response/-/clone-response-1.0.3.tgz#af2032aa47816399cf5f0a1d0db902f517abb8c3" - integrity sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA== - dependencies: - mimic-response "^1.0.0" - clone@^2.0.0: version "2.1.2" resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f" @@ -3795,10 +4041,10 @@ combined-stream@^1.0.6, combined-stream@^1.0.8: dependencies: delayed-stream "~1.0.0" -commander@10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-10.0.0.tgz#71797971162cd3cf65f0b9d24eb28f8d303acdf1" - integrity sha512-zS5PnTI22FIRM6ylNW8G4Ap0IEOyk62fhLSD0+uHRT9McRCLGpkVNvao4bjimpK/GShynyQkFFxHhwMcETmduA== +commander@11.0.0: + version "11.0.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-11.0.0.tgz#43e19c25dbedc8256203538e8d7e9346877a6f67" + integrity sha512-9HMlXtt/BNoYr8ooyjjNRdIilOTkVJXB+GhxMTtOKwk0R4j4lS4NpjuqmRxroBfnfTSHQIHQB7wryHhXarNjmQ== commander@^10.0.0: version "10.0.1" @@ -3968,11 +4214,6 @@ cpus@^1.0.3: resolved "https://registry.yarnpkg.com/cpus/-/cpus-1.0.3.tgz#4ef6deea461968d6329d07dd01205685df2934a2" integrity sha512-PXHBvGLuL69u55IkLa5e5838fLhIMHxmkV4ge42a8alGyn7BtawYgI0hQ849EedvtHIOLNNH3i6eQU1BiE9SUA== -create-require@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" - integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== - create-torrent@^5, create-torrent@^5.0.9: version "5.0.9" resolved "https://registry.yarnpkg.com/create-torrent/-/create-torrent-5.0.9.tgz#850f198f7568e3d0e1e73b6858d43d44659a69d0" @@ -4140,7 +4381,7 @@ deepmerge@^4.2.2, deepmerge@^4.3.0, deepmerge@^4.3.1: resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.3.1.tgz#44b5f2147cd3b00d4b56137685966f26fd25dd4a" integrity sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A== -defer-to-connect@^2.0.0: +defer-to-connect@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/defer-to-connect/-/defer-to-connect-2.0.1.tgz#8016bdb4143e4632b77a3449c6236277de520587" integrity sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg== @@ -4245,11 +4486,6 @@ diff@5.0.0: resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b" integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w== -diff@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" - integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== - dir-glob@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f" @@ -4605,6 +4841,62 @@ es6-weak-map@^2.0.3: es6-iterator "^2.0.3" es6-symbol "^3.1.1" +esbuild@^0.19.0: + version "0.19.0" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.19.0.tgz#f187e4ce3bcc7396d13f408a991655efeba65282" + integrity sha512-i7i8TP4vuG55bKeLyqqk5sTPu1ZjPH3wkcLvAj/0X/222iWFo3AJUYRKjbOoY6BWFMH3teizxHEdV9Su5ESl0w== + optionalDependencies: + "@esbuild/android-arm" "0.19.0" + "@esbuild/android-arm64" "0.19.0" + "@esbuild/android-x64" "0.19.0" + "@esbuild/darwin-arm64" "0.19.0" + "@esbuild/darwin-x64" "0.19.0" + "@esbuild/freebsd-arm64" "0.19.0" + "@esbuild/freebsd-x64" "0.19.0" + "@esbuild/linux-arm" "0.19.0" + "@esbuild/linux-arm64" "0.19.0" + "@esbuild/linux-ia32" "0.19.0" + "@esbuild/linux-loong64" "0.19.0" + "@esbuild/linux-mips64el" "0.19.0" + "@esbuild/linux-ppc64" "0.19.0" + "@esbuild/linux-riscv64" "0.19.0" + "@esbuild/linux-s390x" "0.19.0" + "@esbuild/linux-x64" "0.19.0" + "@esbuild/netbsd-x64" "0.19.0" + "@esbuild/openbsd-x64" "0.19.0" + "@esbuild/sunos-x64" "0.19.0" + "@esbuild/win32-arm64" "0.19.0" + "@esbuild/win32-ia32" "0.19.0" + "@esbuild/win32-x64" "0.19.0" + +esbuild@~0.17.6: + version "0.17.19" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.17.19.tgz#087a727e98299f0462a3d0bcdd9cd7ff100bd955" + integrity sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw== + optionalDependencies: + "@esbuild/android-arm" "0.17.19" + "@esbuild/android-arm64" "0.17.19" + "@esbuild/android-x64" "0.17.19" + "@esbuild/darwin-arm64" "0.17.19" + "@esbuild/darwin-x64" "0.17.19" + "@esbuild/freebsd-arm64" "0.17.19" + "@esbuild/freebsd-x64" "0.17.19" + "@esbuild/linux-arm" "0.17.19" + "@esbuild/linux-arm64" "0.17.19" + "@esbuild/linux-ia32" "0.17.19" + "@esbuild/linux-loong64" "0.17.19" + "@esbuild/linux-mips64el" "0.17.19" + "@esbuild/linux-ppc64" "0.17.19" + "@esbuild/linux-riscv64" "0.17.19" + "@esbuild/linux-s390x" "0.17.19" + "@esbuild/linux-x64" "0.17.19" + "@esbuild/netbsd-x64" "0.17.19" + "@esbuild/openbsd-x64" "0.17.19" + "@esbuild/sunos-x64" "0.17.19" + "@esbuild/win32-arm64" "0.17.19" + "@esbuild/win32-ia32" "0.17.19" + "@esbuild/win32-x64" "0.17.19" + escalade@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" @@ -4904,7 +5196,7 @@ eventemitter-asyncresource@^1.0.0: resolved "https://registry.yarnpkg.com/eventemitter-asyncresource/-/eventemitter-asyncresource-1.0.0.tgz#734ff2e44bf448e627f7748f905d6bdd57bdb65b" integrity sha512-39F7TBIV0G7gTelxwbEqnwhp90eqCPON1k0NwNfwhgKn4Co4ybUbj2pECcXT0B3ztRKZ7Pw1JujUUgmQJHcVAQ== -eventemitter3@^4.0.4: +eventemitter3@^4.0.7: version "4.0.7" resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== @@ -5047,7 +5339,18 @@ fast-fifo@^1.1.0: resolved "https://registry.yarnpkg.com/fast-fifo/-/fast-fifo-1.2.0.tgz#2ee038da2468e8623066dee96958b0c1763aa55a" integrity sha512-NcvQXt7Cky1cNau15FWy64IjuO8X0JijhTBBrJj1YlxlDfRkJXNaK9RFUjwpfDPzMdv7wB38jr53l9tkNLxnWg== -fast-glob@3.2.12, fast-glob@^3.2.9: +fast-glob@3.3.1: + version "3.3.1" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.1.tgz#784b4e897340f3dbbef17413b3f11acf03c874c4" + integrity sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg== + dependencies: + "@nodelib/fs.stat" "^2.0.2" + "@nodelib/fs.walk" "^1.2.3" + glob-parent "^5.1.2" + merge2 "^1.3.0" + micromatch "^4.0.4" + +fast-glob@^3.2.9: version "3.2.12" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.12.tgz#7f39ec99c2e6ab030337142da9e0c18f37afae80" integrity sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w== @@ -5221,6 +5524,11 @@ for-each@^0.3.3: dependencies: is-callable "^1.1.3" +form-data-encoder@^2.1.2: + version "2.1.4" + resolved "https://registry.yarnpkg.com/form-data-encoder/-/form-data-encoder-2.1.4.tgz#261ea35d2a70d48d30ec7a9603130fa5515e9cd5" + integrity sha512-yDYSgNMraqvnxiEXO4hi88+YZxaHC6QKzb5N84iRCTDeRO7ZALpir/lVmf/uXUhnwUr2O4HU8s/n6x+yNjQkHw== + form-data@^2.5.0: version "2.5.1" resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.5.1.tgz#f2cbec57b5e59e23716e128fe44d4e5dd23895f4" @@ -5395,14 +5703,7 @@ get-stream@^3.0.0: resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" integrity sha512-GlhdIUuVakc8SJ6kK0zAFbiGzRFzNnY4jUuEbV9UROo4Y+0Ny4fjvcZFVTeDA4odpFyOQzaw6hXukJSq/f28sQ== -get-stream@^5.1.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.2.0.tgz#4966a1795ee5ace65e706c4b7beb71257d6e22d3" - integrity sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA== - dependencies: - pump "^3.0.0" - -get-stream@^6.0.0: +get-stream@^6.0.0, get-stream@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== @@ -5415,6 +5716,13 @@ get-symbol-description@^1.0.0: call-bind "^1.0.2" get-intrinsic "^1.1.1" +get-tsconfig@^4.4.0: + version "4.6.2" + resolved "https://registry.yarnpkg.com/get-tsconfig/-/get-tsconfig-4.6.2.tgz#831879a5e6c2aa24fe79b60340e2233a1e0f472e" + integrity sha512-E5XrT4CbbXcXWy+1jChlZmrmCwd5KGx502kDCXJJ7y898TtWW9FwoG5HfOLVRKmlmDGkWN2HM9Ho+/Y8F0sJDg== + dependencies: + resolve-pkg-maps "^1.0.0" + getpass@^0.1.1: version "0.1.7" resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" @@ -5525,22 +5833,22 @@ gopd@^1.0.1: dependencies: get-intrinsic "^1.1.3" -got@^11.8.2: - version "11.8.6" - resolved "https://registry.yarnpkg.com/got/-/got-11.8.6.tgz#276e827ead8772eddbcfc97170590b841823233a" - integrity sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g== +got@^13.0.0: + version "13.0.0" + resolved "https://registry.yarnpkg.com/got/-/got-13.0.0.tgz#a2402862cef27a5d0d1b07c0fb25d12b58175422" + integrity sha512-XfBk1CxOOScDcMr9O1yKkNaQyy865NbYs+F7dr4H0LZMVgCj2Le59k6PqbNHoL5ToeaEQUYh6c6yMfVcc6SJxA== dependencies: - "@sindresorhus/is" "^4.0.0" - "@szmarczak/http-timer" "^4.0.5" - "@types/cacheable-request" "^6.0.1" - "@types/responselike" "^1.0.0" - cacheable-lookup "^5.0.3" - cacheable-request "^7.0.2" + "@sindresorhus/is" "^5.2.0" + "@szmarczak/http-timer" "^5.0.1" + cacheable-lookup "^7.0.0" + cacheable-request "^10.2.8" decompress-response "^6.0.0" - http2-wrapper "^1.0.0-beta.5.2" - lowercase-keys "^2.0.0" - p-cancelable "^2.0.0" - responselike "^2.0.0" + form-data-encoder "^2.1.2" + get-stream "^6.0.1" + http2-wrapper "^2.1.10" + lowercase-keys "^3.0.0" + p-cancelable "^3.0.0" + responselike "^3.0.0" graceful-fs@^4.1.6, graceful-fs@^4.2.0: version "4.2.11" @@ -5708,7 +6016,7 @@ htmlparser2@^8.0.0, htmlparser2@^8.0.1, htmlparser2@^8.0.2: domutils "^3.0.1" entities "^4.4.0" -http-cache-semantics@^4.0.0: +http-cache-semantics@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz#abe02fcb2985460bf0323be664436ec3476a6d5a" integrity sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ== @@ -5750,13 +6058,13 @@ http-problem-details@^0.1.5: resolved "https://registry.yarnpkg.com/http-problem-details/-/http-problem-details-0.1.5.tgz#f8f94f4ab9d4050749e9f8566fb85bb8caa2be56" integrity sha512-GHxfQZ0POP4FWbAM0guOyZyJNWwbLUXp+4XOJdmitS2tp3gHVSatrSX59Yyq/dCkhk4KiGtTWIlXZC83yCkBkA== -http2-wrapper@^1.0.0-beta.5.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/http2-wrapper/-/http2-wrapper-1.0.3.tgz#b8f55e0c1f25d4ebd08b3b0c2c079f9590800b3d" - integrity sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg== +http2-wrapper@^2.1.10: + version "2.2.0" + resolved "https://registry.yarnpkg.com/http2-wrapper/-/http2-wrapper-2.2.0.tgz#b80ad199d216b7d3680195077bd7b9060fa9d7f3" + integrity sha512-kZB0wxMo0sh1PehyjJUWRFEd99KC5TLjZ2cULC4f9iqJBAmKQQXEICjxl5iPJRwP40dpeHFqqhm7tYCvODpqpQ== dependencies: quick-lru "^5.1.1" - resolve-alpn "^1.0.0" + resolve-alpn "^1.2.0" https-proxy-agent@^5.0.0: version "5.0.1" @@ -5849,6 +6157,16 @@ import-fresh@^3.0.0, import-fresh@^3.2.1: parent-module "^1.0.0" resolve-from "^4.0.0" +import-in-the-middle@1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/import-in-the-middle/-/import-in-the-middle-1.4.1.tgz#31b25123bc35d556986a172bb398a3e6c32af9be" + integrity sha512-hGG0PcCsykVo8MBVH8l0uEWLWW6DXMgJA9jvC0yps6M3uIJ8L/tagTCbyF8Ud5TtqJ8/jmZL1YkyySyeVkVQrA== + dependencies: + acorn "^8.8.2" + acorn-import-assertions "^1.9.0" + cjs-module-lexer "^1.2.2" + module-details-from-path "^1.0.3" + imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" @@ -6193,10 +6511,10 @@ isexe@^2.0.0: resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== -iso-639-3@2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/iso-639-3/-/iso-639-3-2.2.0.tgz#eb01d7734d61396efec934979e8b0806550837f1" - integrity sha512-v9w/U4XDSfXCrXxf4E6ertGC/lTRX8MLLv7XC1j6N5oL3ympe38jp77zgeyMsn3MbufuAAoGeVzDJbOXnPTMhQ== +iso-639-3@3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/iso-639-3/-/iso-639-3-3.0.1.tgz#4be56987c46fbda79da63a3d90d6552d7429dcea" + integrity sha512-SdljCYXOexv/JmbQ0tvigHN43yECoscVpe2y2hlEqy/CStXQlroPhZLj7zKLRiGqLJfw8k7B973UAMDoQczVgQ== isomorphic-fetch@^3.0.0: version "3.0.0" @@ -6314,7 +6632,7 @@ json5@^1.0.2: dependencies: minimist "^1.2.0" -json5@^2.1.3, json5@^2.2.2, json5@^2.2.3: +json5@^2.1.3, json5@^2.2.3: version "2.2.3" resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== @@ -6408,10 +6726,10 @@ k-rpc@^5.1.0: k-rpc-socket "^1.7.2" randombytes "^2.0.5" -keyv@^4.0.0: - version "4.5.2" - resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.2.tgz#0e310ce73bf7851ec702f2eaf46ec4e3805cce56" - integrity sha512-5MHbFaKn8cNSmVW7BYnijeAVlE4cYA/SVkifVgrh7yotnfhKmjuXpDKjrABLnT0SfHWV21P8ow07OGfRrNDg8g== +keyv@^4.5.3: + version "4.5.3" + resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.3.tgz#00873d2b046df737963157bd04f294ca818c9c25" + integrity sha512-QCiSav9WaX1PgETJ+SpNnx2PRRapJ/oRSXM4VO5OGYGSjrxbKPVFVhB3l2OCbLCk329N8qyAtsJjSjvVBWzEug== dependencies: json-buffer "3.0.1" @@ -6542,6 +6860,11 @@ locate-path@^6.0.0: dependencies: p-locate "^5.0.0" +lodash-es@^4.17.21: + version "4.17.21" + resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.21.tgz#43e626c46e6591b7750beb2b50117390c609e3ee" + integrity sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw== + lodash.chunk@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/lodash.chunk/-/lodash.chunk-4.2.0.tgz#66e5ce1f76ed27b4303d8c6512e8d1216e8106bc" @@ -6567,7 +6890,7 @@ lodash.isarguments@^3.1.0: resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" integrity sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg== -lodash.merge@4.6.2, lodash.merge@^4.6.2: +lodash.merge@^4.6.2: version "4.6.2" resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== @@ -6616,10 +6939,10 @@ loupe@^2.3.1: dependencies: get-func-name "^2.0.0" -lowercase-keys@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-2.0.0.tgz#2603e78b7b4b0006cbca2fbcc8a3202558ac9479" - integrity sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA== +lowercase-keys@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-3.0.0.tgz#c5e7d442e37ead247ae9db117a9d0a467c89d4f2" + integrity sha512-ozCC6gdQ+glXOQsveKD0YsDy8DSQFjDTz4zyzEHNV5+JP5D62LmfDZ6o1cycFx9ouG940M5dE8C8CTewdj2YWQ== lru-cache@4.1.x: version "4.1.5" @@ -6724,11 +7047,6 @@ make-dir@^3.1.0: dependencies: semver "^6.0.0" -make-error@^1.1.1: - version "1.3.6" - resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" - integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== - make-plural@^7.0.0: version "7.3.0" resolved "https://registry.yarnpkg.com/make-plural/-/make-plural-7.3.0.tgz#2889dbafca2fb097037c47967d3e3afa7e48a52c" @@ -6878,16 +7196,16 @@ mimic-fn@^2.1.0: resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== -mimic-response@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b" - integrity sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ== - mimic-response@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-3.1.0.tgz#2d1d59af9c1b129815accc2c46a022a5ce1fa3c9" integrity sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ== +mimic-response@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-4.0.0.tgz#35468b19e7c75d10f5165ea25e75a5ceea7cf70f" + integrity sha512-e5ISH9xMYU0DzrT+jl8q2ze9D6eWBto+I8CNpe+VI+K2J/F/k3PdkdTdz4wvGVH4NTpo+NRYTVIuMQEMMcsLqg== + min-document@^2.19.0: version "2.19.0" resolved "https://registry.yarnpkg.com/min-document/-/min-document-2.19.0.tgz#7bd282e3f5842ed295bb748cdd9f1ffa2c824685" @@ -7289,10 +7607,10 @@ normalize-path@^3.0.0, normalize-path@~3.0.0: resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== -normalize-url@^6.0.1: - version "6.1.0" - resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-6.1.0.tgz#40d0885b535deffe3f3147bec877d05fe4c5668a" - integrity sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A== +normalize-url@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-8.0.0.tgz#593dbd284f743e8dcf6a5ddf8fadff149c82701a" + integrity sha512-uVFpKhj5MheNBJRTiMZ9pE/7hD1QTeEvugSJW/OmLzAp78PB5O6adfMNTvmfKhXBkvCzC+rqifWcVYpGFwTjnw== npm-run-path@^2.0.0: version "2.0.2" @@ -7417,14 +7735,14 @@ open@7: is-docker "^2.0.0" is-wsl "^2.1.1" -opentelemetry-instrumentation-sequelize@^0.35.0: - version "0.35.0" - resolved "https://registry.yarnpkg.com/opentelemetry-instrumentation-sequelize/-/opentelemetry-instrumentation-sequelize-0.35.0.tgz#ac583d0a2283e251f71c35b983ffeb06305f8b2b" - integrity sha512-bYcw98dFTbAGcGzIwNa+09mnW7tRgew0qR9L09oo3X3+L6NtA3C6GxGVGBa9ExxHJeokSl5F5ytSMTYVUG4iBA== +opentelemetry-instrumentation-sequelize@^0.39.1: + version "0.39.1" + resolved "https://registry.yarnpkg.com/opentelemetry-instrumentation-sequelize/-/opentelemetry-instrumentation-sequelize-0.39.1.tgz#1fb3e1fa517ef776e749b0c5c5b043c4132c1659" + integrity sha512-LMZ9UxMbD23JhAqrHdzwd6w0khEYNkBK7ic+aP2vTLI06RutfiOmk0OZkKvzCW5ZozAsO2vI4zihJCqJGN98gA== dependencies: - "@opentelemetry/core" "^1.8.0" - "@opentelemetry/instrumentation" "^0.35.1" - "@opentelemetry/semantic-conventions" "^1.8.0" + "@opentelemetry/core" "^1.13.0" + "@opentelemetry/instrumentation" "^0.41.0" + "@opentelemetry/semantic-conventions" "^1.14.0" opentracing@^0.14.4: version "0.14.7" @@ -7455,10 +7773,10 @@ otpauth@^9.0.2: dependencies: jssha "~3.3.0" -p-cancelable@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-2.1.1.tgz#aab7fbd416582fa32a3db49859c122487c5ed2cf" - integrity sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg== +p-cancelable@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-3.0.0.tgz#63826694b54d61ca1c20ebcb6d3ecf5e14cd8050" + integrity sha512-mlVgR3PGuzlo0MmTdk4cXqXWlwQDLnONTAg6sm62XkMJEiRxN3GL3SffkYvqwonbkJBcrI7Uvv5Zh9yjvn2iUw== p-event@4.2.0: version "4.2.0" @@ -7500,21 +7818,26 @@ p-locate@^5.0.0: dependencies: p-limit "^3.0.2" -p-queue@^6: - version "6.6.2" - resolved "https://registry.yarnpkg.com/p-queue/-/p-queue-6.6.2.tgz#2068a9dcf8e67dd0ec3e7a2bcb76810faa85e426" - integrity sha512-RwFpb72c/BhQLEXIZ5K2e+AhgNVmIejGlTgiB9MzZ0e93GRvqZ7uSi0dvRF7/XIXDeNkra2fNHBxTyPDGySpjQ== +p-queue@^7.3.4: + version "7.3.4" + resolved "https://registry.yarnpkg.com/p-queue/-/p-queue-7.3.4.tgz#7ef7d89b6c1a0563596d98adbc9dc404e9ed4a84" + integrity sha512-esox8CWt0j9EZECFvkFl2WNPat8LN4t7WWeXq73D9ha0V96qPRufApZi4ZhPwXAln1uVVal429HVVKPa2X0yQg== dependencies: - eventemitter3 "^4.0.4" - p-timeout "^3.2.0" + eventemitter3 "^4.0.7" + p-timeout "^5.0.2" -p-timeout@^3.0.0, p-timeout@^3.1.0, p-timeout@^3.2.0: +p-timeout@^3.0.0, p-timeout@^3.1.0: version "3.2.0" resolved "https://registry.yarnpkg.com/p-timeout/-/p-timeout-3.2.0.tgz#c7e17abc971d2a7962ef83626b35d635acf23dfe" integrity sha512-rhIwUycgwwKcP9yTOOFK/AKsAopjjCakVqLHePO3CC6Mir1Z99xT+R63jZxAT5lFZLa2inS5h+ZS2GvR99/FBg== dependencies: p-finally "^1.0.0" +p-timeout@^5.0.2: + version "5.1.0" + resolved "https://registry.yarnpkg.com/p-timeout/-/p-timeout-5.1.0.tgz#b3c691cf4415138ce2d9cfe071dba11f0fee085b" + integrity sha512-auFDyzzzGZZZdHz3BtET9VEz0SE/uMEAx7uWfGPucfzEwwe/xH0iVeZibQmANYE/hp9T2+UUZT5m+BKyrDp3Ew== + p-try@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" @@ -8383,19 +8706,10 @@ require-from-string@^2.0.2: resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909" integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw== -require-in-the-middle@^5.0.3: - version "5.2.0" - resolved "https://registry.yarnpkg.com/require-in-the-middle/-/require-in-the-middle-5.2.0.tgz#4b71e3cc7f59977100af9beb76bf2d056a5a6de2" - integrity sha512-efCx3b+0Z69/LGJmm9Yvi4cqEdxnoGnxYxGxBghkkTTFeXRtTCmmhO0AnAfHz59k957uTSuy8WaHqOs8wbYUWg== - dependencies: - debug "^4.1.1" - module-details-from-path "^1.0.3" - resolve "^1.22.1" - -require-in-the-middle@^7.1.0: - version "7.1.0" - resolved "https://registry.yarnpkg.com/require-in-the-middle/-/require-in-the-middle-7.1.0.tgz#8ab4089383e7b7879ed134d8e9d1887bd48195ec" - integrity sha512-6f86Mh0vWCxqKKatRPwgY6VzYmcVay3WUTIpJ1ILBCNh+dTWabMR1swKGKz3XcEZ5mgjndzRu7fQ+44G2H9Gew== +require-in-the-middle@^7.1.1: + version "7.2.0" + resolved "https://registry.yarnpkg.com/require-in-the-middle/-/require-in-the-middle-7.2.0.tgz#b539de8f00955444dc8aed95e17c69b0a4f10fcf" + integrity sha512-3TLx5TGyAY6AOqLBoXmHkNql0HIf2RGbuMgCDT2WO/uGVAPJs6h7Kl+bN6TIZGd9bWhWPwnDnTHGtW8Iu77sdw== dependencies: debug "^4.1.1" module-details-from-path "^1.0.3" @@ -8411,7 +8725,7 @@ require-package-name@^2.0.1: resolved "https://registry.yarnpkg.com/require-package-name/-/require-package-name-2.0.1.tgz#c11e97276b65b8e2923f75dabf5fb2ef0c3841b9" integrity sha512-uuoJ1hU/k6M0779t3VMVIYpb2VMJk05cehCaABFhXaibcbvfgR8wKiozLjVFSzJPmQMRqIcO0HMyTFqfV09V6Q== -resolve-alpn@^1.0.0: +resolve-alpn@^1.2.0: version "1.2.1" resolved "https://registry.yarnpkg.com/resolve-alpn/-/resolve-alpn-1.2.1.tgz#b7adbdac3546aaaec20b45e7d8265927072726f9" integrity sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g== @@ -8421,14 +8735,10 @@ resolve-from@^4.0.0: resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== -resolve-tspaths@^0.8.8: - version "0.8.13" - resolved "https://registry.yarnpkg.com/resolve-tspaths/-/resolve-tspaths-0.8.13.tgz#83e37d7fb40b0ed241c40e91dbcd15c0fb82224c" - integrity sha512-eHlHinC2qt3jQLFiZyUE4HXZOTlT1abHO2fb+OI9Ybsn8wdhKiAtIFVy1+QVTaIQNphCLvm42EkqJt/+ZAA8Sw== - dependencies: - ansi-colors "4.1.3" - commander "10.0.0" - fast-glob "3.2.12" +resolve-pkg-maps@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz#616b3dc2c57056b5588c31cdf4b3d64db133720f" + integrity sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw== resolve@^1.10.1, resolve@^1.15.1, resolve@^1.18.1, resolve@^1.22.1, resolve@^1.22.2: version "1.22.2" @@ -8439,12 +8749,12 @@ resolve@^1.10.1, resolve@^1.15.1, resolve@^1.18.1, resolve@^1.22.1, resolve@^1.2 path-parse "^1.0.7" supports-preserve-symlinks-flag "^1.0.0" -responselike@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/responselike/-/responselike-2.0.1.tgz#9a0bc8fdc252f3fb1cca68b016591059ba1422bc" - integrity sha512-4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw== +responselike@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/responselike/-/responselike-3.0.0.tgz#20decb6c298aff0dbee1c355ca95461d42823626" + integrity sha512-40yHxbNcl2+rzXvZuVkrYohathsSJlMTXKryG5y8uciHv1+xDLHQpgjG64JUO9nrEq2jGLH6IZ8BcZyw3wrweg== dependencies: - lowercase-keys "^2.0.0" + lowercase-keys "^3.0.0" ret@~0.1.10: version "0.1.15" @@ -8620,6 +8930,13 @@ semver@^7.0.0, semver@^7.3.2, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8, semve dependencies: lru-cache "^6.0.0" +semver@^7.5.1: + version "7.5.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" + integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== + dependencies: + lru-cache "^6.0.0" + send@0.18.0: version "0.18.0" resolved "https://registry.yarnpkg.com/send/-/send-0.18.0.tgz#670167cc654b05f5aa4a767f9113bb371bc706be" @@ -8898,6 +9215,19 @@ socks@^2.0.0: resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c" integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw== +source-map-support@^0.5.21: + version "0.5.21" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" + integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map@^0.6.0: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + spawn-command@0.0.2-1: version "0.0.2-1" resolved "https://registry.yarnpkg.com/spawn-command/-/spawn-command-0.0.2-1.tgz#62f5e9466981c1b796dc5929937e11c9c6921bd0" @@ -9460,25 +9790,6 @@ triple-beam@^1.3.0: resolved "https://registry.yarnpkg.com/triple-beam/-/triple-beam-1.3.0.tgz#a595214c7298db8339eeeee083e4d10bd8cb8dd9" integrity sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw== -ts-node@^10.8.1: - version "10.9.1" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.1.tgz#e73de9102958af9e1f0b168a6ff320e25adcff4b" - integrity sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw== - dependencies: - "@cspotcode/source-map-support" "^0.8.0" - "@tsconfig/node10" "^1.0.7" - "@tsconfig/node12" "^1.0.7" - "@tsconfig/node14" "^1.0.0" - "@tsconfig/node16" "^1.0.2" - acorn "^8.4.1" - acorn-walk "^8.1.1" - arg "^4.1.0" - create-require "^1.1.0" - diff "^4.0.1" - make-error "^1.1.1" - v8-compile-cache-lib "^3.0.1" - yn "3.1.1" - tsc-watch@^6.0.0: version "6.0.4" resolved "https://registry.yarnpkg.com/tsc-watch/-/tsc-watch-6.0.4.tgz#af15229f03cd53086771a97b10653db063bc6c59" @@ -9499,15 +9810,6 @@ tsconfig-paths@^3.14.1: minimist "^1.2.6" strip-bom "^3.0.0" -tsconfig-paths@^4.0.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-4.2.0.tgz#ef78e19039133446d244beac0fd6a1632e2d107c" - integrity sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg== - dependencies: - json5 "^2.2.2" - minimist "^1.2.6" - strip-bom "^3.0.0" - tslib@^1.11.1, tslib@^1.8.1: version "1.14.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" @@ -9525,6 +9827,17 @@ tsutils@^3.21.0: dependencies: tslib "^1.8.1" +tsx@^3.12.7: + version "3.12.7" + resolved "https://registry.yarnpkg.com/tsx/-/tsx-3.12.7.tgz#b3b8b0fc79afc8260d1e14f9e995616c859a91e9" + integrity sha512-C2Ip+jPmqKd1GWVQDvz/Eyc6QJbGfE7NrR3fx5BpEHMZsEHoIxHL1j+lKdGobr8ovEyqeNkPLSKp6SCSOt7gmw== + dependencies: + "@esbuild-kit/cjs-loader" "^2.4.2" + "@esbuild-kit/core-utils" "^3.0.0" + "@esbuild-kit/esm-loader" "^2.5.5" + optionalDependencies: + fsevents "~2.3.2" + tv4@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/tv4/-/tv4-1.3.0.tgz#d020c846fadd50c855abb25ebaecc68fc10f7963" @@ -9608,6 +9921,13 @@ uint64be@^2.0.2: dependencies: buffer-alloc "^1.1.0" +uint8-util@^2.1.6: + version "2.2.2" + resolved "https://registry.yarnpkg.com/uint8-util/-/uint8-util-2.2.2.tgz#d1830e02957c7b5e1913c519174ff2c63fb7e2a3" + integrity sha512-zqDacLmV6UPJguIUKezcW8V9NzWJQxF6KX0hHiJWq2YbgHcTS8RnsfcganIRI51Pla59OIq6MjjjEMDEBnEW0A== + dependencies: + base64-arraybuffer "^1.0.2" + unbox-primitive@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.2.tgz#29032021057d5e6cdbd08c5129c226dff8ed6f9e" @@ -9747,11 +10067,6 @@ uuid@^9.0.0: resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.0.tgz#592f550650024a38ceb0c562f2f6aa435761efb5" integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg== -v8-compile-cache-lib@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" - integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== - valid-data-url@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/valid-data-url/-/valid-data-url-3.0.1.tgz#826c1744e71b5632e847dd15dbd45b9fb38aa34f" @@ -10208,11 +10523,6 @@ yargs@^17.7.1: y18n "^5.0.5" yargs-parser "^21.1.1" -yn@3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" - integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== - yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"